How to reset the simulation ?
Hi,
I need to reset the hole state of the simulation (the world and all models)
According to this link the Reset() function of the model don't work properly. I thought to do this:
- Delete the robots and put them back
- Stop and restart the physic engine
- quit the simulation and restart again
What is the appropriate way and how to do it from the API ??
Thank you in advance
ps: I'm trying to do evolution of controllers with genetic algorithm to make quadrupeds walk. The ones that travel long distance we will keep them to next generation. So if I don't reset properly the simulation at the beginning of each generation the robots will do a complete different behavior.
Asked by djou07 on 2015-05-26 10:16:42 UTC
Answers
Hello, first I suspect that if you want to reset the world and models you should look at the World class Reset not the Model class Reset. If that does not work you can reset the world using the world_control gazebo topic, this should reset your robot models to the initial positions as well as reset the simulation, but does not reset joint commands.
E.g. supposing you have already run the transport and initialized a node
-Create a publisher for your message:
gazebo::transport::PublisherPtr reset_pub;
reset_pub=node->Advertisegazebo::msgs::WorldControl("~/world_control");
-Create a message and set it to indicate what you want yo control:
gazebo::msgs::WorldControl w_ctrl;
w_ctrl.mutable_reset()->set_all(true); //I believe this is equal to indicating a world reset
reset_pub->Publish(w_ctrl);
BTW I'm evolving controllers for robot locomotion too.
Asked by PML on 2015-05-26 15:46:11 UTC
Comments
Hi, thnks for your answer. the Reset of world class don't work.I suppose that you faced the same problem too. Does world_control gazebo topic worked. Cause I dont want to spend a lot of time on it and then don't work. Any way i'll keep you informed...
Asked by djou07 on 2015-05-26 19:00:19 UTC
using the topic worked fine for me, but I'm using Gazebo 5 and while Im confident that should work on other other versions i cant be 100% sure, good luck.
Asked by PML on 2015-05-26 19:07:41 UTC
thanks, can you please give me some link s to tutorials about world topic because I never used them....
Asked by djou07 on 2015-05-27 11:00:38 UTC
Here is the protobuf message
Asked by nkoenig on 2015-05-27 11:13:57 UTC
Use the code example provided in the answer, the protobuf message structure is the closest to a tutorial at the moment.
Asked by PML on 2015-05-27 19:42:44 UTC
Just my 2 cents: in case you are using ROS together with Gazebo, you can call one of these services depending on exactly what you want.
rosservice call /gazebo/reset_simulation
rosservice call /gazebo/reset_world
Asked by niall on 2015-05-28 03:08:16 UTC
@niall thanks, but I use gazebo stand alone. @PML the topic method doesn't work for me, I use gazebo version 4. For example, if each 20 I save the distance traveled by a robot and reset the simulation I get different distances. But I want the same. I think instead of reset I will quit the. simulation and restart it...If you want to discuss about evolution in gazebo here is my mail adress :) djouakr91@gmail.com
Asked by djou07 on 2015-05-28 09:29:13 UTC
Comments