Reset Gazebo with a new world

asked 2020-05-17 22:59:51 -0500

ali gravatar image

I want to run a set of experiments in ROS with Gazebo where each run has a randomized environment. I can write a Python script to randomly assign a pose for the objects and generate the corresponding .world file. However, I can't figure out how to get Gazebo to load the new world. I tried calling the services reset_world and reset_simulation but these do not work.

For example, I roslaunch Gazebo with example.world with an object at location 0,0,0. After the first experiment is done, the Python script overwrites example.world with object now at 1, 1, 0. Then calling reset_world or reset_simulation, the object is at 0, 0, 0 instead of 1, 1, 0. That is, Gazebo does not read example.world anymore, only once when the node is launched.

I could have terminated Gazebo and call roslaunch again but I need this to be automated as I have hundreds of experiments to run off a server. I also tried killing the Gazebo node and make it respawn but it didn't respawn.

edit retag flag offensive close merge delete