an instruction for sim.followPath

Typically: "How do I... ", "How can I... " questions
Post Reply
quangabcd
Posts: 17
Joined: 23 May 2017, 02:42

an instruction for sim.followPath

Post by quangabcd »

Hi,

can any body provide an example/instruction how to use sim.followPath (https://www.coppeliarobotics.com/helpFi ... owPath.htm)?

i could not find any path following using this approach

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: an instruction for sim.followPath

Post by coppelia »

Hello,

sim.followPath is deprecated and should not be used anymore. If possible, also try to avoid path objects, since they are not that flexible and there will be a better option in next release (i.e. V4.2.0). But for the time being, do something like:

Code: Select all

    -- init:
    path=sim.getObjectHandle('myPath')
    pathLength=sim.getPathLength(path)

    -- e.g. place an object at 0.1 meter from the start of the path:
    local dist=0.1
    local relDist=dist/pathLength
    local pos=sim.getPositionOnPath(path,relDist)
    local euler=sim.getOrientationOnPath(path,relDist)
    sim.setObjectPosition(myObjectHandle,pos)
    sim.setObjectOrientation(myObjectHandle,euler)
Cheers

quangabcd
Posts: 17
Joined: 23 May 2017, 02:42

Re: an instruction for sim.followPath

Post by quangabcd »

Thanks,
the approach with set-get position works

you may need to update the instruction to avoid confusing people ;)

Hrithik Verma
Posts: 22
Joined: 07 Sep 2020, 21:20
Contact:

Re: an instruction for sim.followPath

Post by Hrithik Verma »

Hello

How to make a object follow path in coppeliasim 4.2.0 (rev5) because the above code is not working and sim.followpath() is already deprecated.

I also tried https://www.coppeliarobotics.com/helpFiles/en/paths.htm follow path method describe in it but that also not working.

I think this particular part should be clearly describe in a post because lots of version having different methods to follow path and people will get lot of confusion.


Thanks in advance

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: an instruction for sim.followPath

Post by coppelia »

Always make sure to use the newest CoppeliaSim version. In CoppeliaSim V4.2 and V4.3, you'll find a demo scene scenes/movingAlongAPath.ttt: there you will find many different examples on how to have an object follow a path.

Cheers

Post Reply