ros: restarting simulation... useless api StartSimulation

Typically: "How do I... ", "How can I... " questions
Post Reply
fferri
Posts: 681
Joined: 09 Sep 2013, 19:28

ros: restarting simulation... useless api StartSimulation

Post by fferri »

I'm running V-REP headless for simulating my robot in ROS.

I sometimes need to restart the simulation (e.g. the robot falls off the simulation scene :D)

but once I stop the simulation with /vrep/simRosStopSimulation, no ros services for controlling V-REP are available anymore, so it is not possible to call /vrep/simRosStartSimulation!

maybe an api for restarting the simulation would help?

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

Re: ros: restarting simulation... useless api StartSimulatio

Post by coppelia »

Hello,

the ROS services are always available, also when simulation is not running. Which is not the case for publishers and subscribers.

so you should be able to restart your simulation with simRosStartSimulation. But remember: when you stop (or request a stop) a simulation, it will not immediately stop. If will go through various intermediate states and simulate a few additional frames before stopping (this, in order to give the chance to scripts to do clean-up and other specific operations before the stop). Have a look at the simulator states. So, before restarting simulation, make sure the simulation has really stopped. You can check this with the info topic which is a publisher that is always active (this is an exception, unlike the other publishers).

Cheers

fferri
Posts: 681
Joined: 09 Sep 2013, 19:28

Re: ros: restarting simulation... useless api StartSimulatio

Post by fferri »

Here is what I do:

simulation now is running:

Code: Select all

$ rosservice list | grep simRosSt.*Simulation
/vrep/simRosStartSimulation
/vrep/simRosStopSimulation
$
services are there... let's stop the simulation:

Code: Select all

$ rosservice call /vrep/simRosStopSimulation "{}"
result: 1
$
now I wait until the /vrep/info effectively shows that the simulation has stopped (and even more)

...

Code: Select all

$ rosservice list | grep simRosSt.*Simulation
$
services are not there anymore

Code: Select all

$ rosservice call /vrep/simRosStartSimulation "{}"
ERROR: Service [/vrep/simRosStartSimulation] is not available.

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

Re: ros: restarting simulation... useless api StartSimulatio

Post by coppelia »

What happens if you try to stop a simulation that is not running (via a service call)? And what happens if you try to run a simulation that is already running?

I would try to rebuild the ROS plugin, that should fix the problem.

Cheers

Post Reply