Page 1 of 1

start and stop Simulation via ROS

Posted: 25 Jan 2018, 08:54
by vrepUser94
Hi everyone,

in order to test my path-planning algorithm (which is actually a standalone ROS Node communicating with my robot) I would like to build an automated test-platform.

My final goal would be to start the simulation by sending a ros-message (and finally some other information like where an obstacle should be placed in the simulation environment etc.), let the simulation run, store some data (rosbags,...) and send information about the successful or not successful end of the simulation(e.g. when my robot has reached a certain point = success / when the robot hits an obstacle = no success). This last information should lead to sending the "stop" - message via ROS in order to finish the simulation.

Whenever the simulation is stopped this way, the next run should begin automatically (with some other parameters concerning the simulation (environment)-setup) and all the mentioned points from above should be executed again.

When everything works as I imagine, I would like to start the whole simulation-series once (e.g. in the evening) and evaluate the results (stored in rosbags, etc.) the next morning. Doing it that way would give me the possibility to concentrate on developing the algorithm during the day and simulate my algorithms at night.

To summarize what i want to achieve:
  • start and stop V-REP simulation several times in a row (ROS or any other approach)
  • send new parameters for changing environment setup at every new start(data e.g. stored in excel file)
  • send trigger from V-REP to stop simulation when certain condition is reached

My setup: ROS kinetic, Ubuntu 16.04, V-REP PRO EDU V3.4.0

I really hope that I can get some useful information or tips how to achieve the idea of such a test-platform.

Thanks a lot for every kind of help!

Re: start and stop Simulation via ROS

Posted: 26 Jan 2018, 00:57
by e2718
Well I won't claim to be an expert, and there are probably multiple ways to do this, but here's what I would do:

How I would do this is to start up ROS (using '$ roscore') and V-Rep and run everything through a ROS python node. In this python node, you would read some data file containing your environment parameters, set up your environment, read outputs from V-Rep, and start/stop your simulations. Next will detail how to do some of the pieces.

To start and stop your simulation, look at the function list ... etical.htm Specifically the functions simxStartSimulation and simxStopSimulation

To set up your environment, I assume most of your environments will have many similar assests. I recommend creating them as scenes and models, loading them through simxLoadModel and simxLoadScene and placing them with like simxSetObjectPosition and simxSetObjectOrientation.

As for communicating with your ROS node, I recommend looking here ... Indigo.htm It might be a bit out of date (was created for ROS indigo, not kinetic). But should at least point you in the right direction.

Finally, if you are doing path planning, V-REP has OMPL built in, it already works pretty well, and if nothing else should serve as a point of comparison to your path-planning algorithm.

So in summary, if I were to do this, I would:
- Build a ROS python node
- First the node would build the scene by loading the scene and corresponding models.
- Then start the simulation
- Use the V-REP ROS interface to get ROS messages out from the scene.
- When desired conditions are met, stop the simulation.
- Maybe consider using OMPL for checking/comparison purposes.

Hope this helps. Best of luck with your work.

Re: start and stop Simulation via ROS

Posted: 27 Jan 2018, 15:49
by coppelia

I strongly suggest you have a look and try the helper model Models/tools/rosInterface helper tool.ttm: it will support most of the needed ROS messages for your application. Simply have a lookat the customization script attached to the model, and add/remove messages as needed. The reason why we are using a customization script for handling those messages is because customization scripts are always running (simulation scripts such as child scripts only run when simulation is running, which is problematic if you want to handle events such as start simulation).


Re: start and stop Simulation via ROS

Posted: 29 Jan 2018, 10:04
by vrepUser94

thanks a lot for the useful hints!

Actually I didn't know about the functionality of customization scripts, but after looking at the helper model everything is clear to me now.
With this useful information the first attempts of my test-platform worked, which is really a big success in my project.