Problems with using rosinterface - synchronous mode

Typically: "How do I... ", "How can I... " questions
Post Reply
Posts: 10
Joined: 03 Jul 2017, 08:32

Problems with using rosinterface - synchronous mode

Post by mthor13 » 22 May 2018, 08:54

Hi all,

I am currently trying to sync my v-rep simulation with a ros-node written in C++. From the C++ ros-node, using the RosInterfaceHelper tool, I am enabling the sync mode and triggering the simulation every time I loop through my controller program in the node. So the C++ node loops the following commands:

Run program - i.e., the controller
rate->sleep() -- (this rate is set to 20hz as the simulation is using 50ms)

To test that the node and the simulation are in fact synchronized I am running a small test where I increment a number in a child script inside the simulation that I publish to a ros topic. However, when reading in the C++ node the sequence is not consistent and is strongly dependent on the rate I use in the C++ node. If the rate is much higher than the simulation step, dt, then I will miss a lot of the numbers in the sequence. If it is set to what the simulation is running at (i.e, 20hz) it is better but still random (sometimes I read the same number twice and other times I am skipping a number).

Do you have any idea about what I am doing wrong?

Best Regards,
Mathias Thor

EDIT: One additional question: "Why is the ros::rate in the C++ node depending on the sim step size, dt, when the C++ node is triggering the simulation for every step?"

Site Admin
Posts: 6625
Joined: 14 Dec 2012, 00:25

Re: Problems with using rosinterface - synchronous mode

Post by coppelia » 24 May 2018, 12:38


my guess is that you are triggering new simulation steps more of then than V-REP can handle. Best would be to trigger a simulation step, then wait to receive a message that the step was successfully executed.

Are you waiting for the message simulationStepDone before trying to trigger a new simulation step?


Post Reply