Gazebo | Ignition | Community
Ask Your Question

How to reset the simulation ?

asked 2015-05-26 10:16:42 -0500

djou07 gravatar image


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:

  1. Delete the robots and put them back
  2. Stop and restart the physic engine
  3. 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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-06-15 10:26:01 -0500

Void gravatar image

do the following in terminal:

rosservice call /gazebo/reset_simulation "{}"

edit flag offensive delete link more


It works for me

bomber40 gravatar imagebomber40 ( 2020-07-27 21:04:49 -0500 )edit

answered 2015-05-26 15:46:11 -0500

PML gravatar image

updated 2015-05-26 16:00:50 -0500

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;


-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


BTW I'm evolving controllers for robot locomotion too.

edit flag offensive delete link more


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

djou07 gravatar imagedjou07 ( 2015-05-26 19:00:19 -0500 )edit

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.

PML gravatar imagePML ( 2015-05-26 19:07:41 -0500 )edit

thanks, can you please give me some link s to tutorials about world topic because I never used them....

djou07 gravatar imagedjou07 ( 2015-05-27 11:00:38 -0500 )edit

Here is the protobuf message

nkoenig gravatar imagenkoenig ( 2015-05-27 11:13:57 -0500 )edit

Use the code example provided in the answer, the protobuf message structure is the closest to a tutorial at the moment.

PML gravatar imagePML ( 2015-05-27 19:42:44 -0500 )edit

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

niall gravatar imageniall ( 2015-05-28 03:08:16 -0500 )edit

@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 :)

djou07 gravatar imagedjou07 ( 2015-05-28 09:29:13 -0500 )edit

Question Tools

1 follower


Asked: 2015-05-26 10:16:42 -0500

Seen: 24,853 times

Last updated: Jun 15 '18