Home | Tutorials | Wiki | Issues
Ask Your Question

Gazebo World Reset using ROS [closed]

asked 2016-12-23 04:50:23 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.


I need to reset the world in Gazebo. I know it can be done manually using the Gazebo GUI and doing Ctrl-R but I need to do it programmatically. I have genetic algorithms running in Visual Studio in Windows and I am communicating with ROS mater using rosserial_windows. Now after every generation I need to reset the world since I am evolving controllers for the robot. I am using ROS and Gazebo 5.0. How it can be done?


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Imran Zafar
close date 2017-01-03 13:36:26.496647

1 answer

Sort by ยป oldest newest most voted

answered 2017-01-03 04:31:48 -0600

Imran Zafar gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-12-23 04:50:23 -0600

Seen: 135 times

Last updated: Jan 03