start and stop Simulation via ROS

Typically: "How do I... ", "How can I... " questions
Post Reply
vrepUser94
Posts: 9
Joined: 08 Jan 2018, 08:41

start and stop Simulation via ROS

Post by vrepUser94 » 25 Jan 2018, 08:54

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!

e2718
Posts: 33
Joined: 15 Nov 2015, 05:39

Re: start and stop Simulation via ROS

Post by e2718 » 26 Jan 2018, 00:57

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 http://www.coppeliarobotics.com/helpFil ... 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 http://www.coppeliarobotics.com/helpFil ... 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.

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

Re: start and stop Simulation via ROS

Post by coppelia » 27 Jan 2018, 15:49

Hello,

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).

Cheers

vrepUser94
Posts: 9
Joined: 08 Jan 2018, 08:41

Re: start and stop Simulation via ROS

Post by vrepUser94 » 29 Jan 2018, 10:04

Hello,

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.

Cheers

Post Reply