How do I follow path at varying velocities?

Typically: "How do I... ", "How can I... " questions
Post Reply
kkim108
Posts: 8
Joined: 23 Mar 2016, 03:13

How do I follow path at varying velocities?

Post by kkim108 » 23 Mar 2016, 16:19

Hi,

I am trying to make an object in vrep adjust the velocity it follows its path in real time.
simFollowPath has a velocity parameter that makes the object follow the entire path at the specified velocity. However, if I want the object to slow down at some point along the path that is unknown until running the simulation, is there a way to do that?
Thank you.

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

Re: How do I follow path at varying velocities?

Post by coppelia » 23 Mar 2016, 18:31

Hello,

yes, in that case you should manually move the object on the path via following API commands:
The first one gives you the total length of the path
The second one gives you the position along the path of the red sphere on the path
The third allows you to change the position along the path of the red sphere
The forth one gives you the absolute X/Y/Z position for a random point on the path. If you want the X/Y/Z position of the red sphere, then you would give as second argument: simGetPathPosition(...)/simGetPathLength(...)
Finally, you can then take that X/Y/Z coordinate and apply it to your object with simSetObjectPosition.

Cheers

kkim108
Posts: 8
Joined: 23 Mar 2016, 03:13

Re: How do I follow path at varying velocities?

Post by kkim108 » 29 Mar 2016, 09:15

Thank you! That is exactly what I needed.

Post Reply