Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello Guys,

I found the solution to programmatically reset gazebo. So I am posting it here for others to benefit:

  1. Create a publisher that publishes an empty message using std_msg::Empty
  2. On the ROS side create a subscriber that listens to this topic lets say "reset_world"
  3. Upon hearing the request the subscriber then calls a service that resets the gazebo world. Below is the code for that service:

std_srvs::Empty empty_packet; if(resetworld_client.call(empty_packet)) { ROS_INFO("Reset World); } else { ROS_INFO("Failed to reset the world"); }

And that's it. This particular code should be in the call back function of the subscriber that you made in ROS.