Gazebo | Ignition | Community
Ask Your Question

/gazebo/delete_model ros service is unresponsive

asked 2020-06-05 15:41:55 -0500

zokowc gravatar image

updated 2020-06-05 16:53:23 -0500

System settings:

  • gazebo 9
  • gazebo_ros
  • Ubuntu 18.04
  • Amd 64
  • ROS Melodic

I created a rosservice to create/delete a maze. While creating a maze works great, deleting the maze is unresposive.

 def srvCallback(self,request):
        if request.adddelete == True:

        resp = addDeleteResponse()
        resp.success = "Command acted"
        return resp

def remove_all(self):
        print('starting delete proccess')
        for i in range(self.elements_added+1):
            x = self.del_model_prox("object"+str(i))
        y= self.del_model_prox('the_heightmap')
        self.elements_added = 0

After creating the maze, running the remove_all function outputs the following:

  • "starting delete proccess"
  • "0"

The output stops there until I manually delete the object from the GUI:

  • rospy logs a succesfull deletion
  • "1"

Am i doing something wrong here or is there a bug with deleting the model? (same response if I use the delete model service from terminal). The elements of the maze are simple shapes, the box model can be seen bellow:

<?xml version='1.0' encoding='UTF-8'?>
<sdf version="1.4">
    <model name="the_box">
        <pose> 0 0 0 0 0 0</pose>
        <link name="link">
        <collision name="collision">
                    <size>0.71 0.71 0.71</size>
        <visual name="visual">
                    <size>0.71 0.71 0.71</size>

Part of "make_3d_maze()" can be seen below:

elif shape_selection ==1:
        tree = ET.parse(filename)
        root = tree.getroot()
        for name in root.iter('name'):
            name.text = material_name
        for siz in root.iter('radius'):
            siz.text = size
        tree.write('/home/nvidiaagx/simulation_ws/src/sim/models/sphere.sdf',xml_declaration=True, method='xml',encoding='UTF-8')

        f = open('/home/nvidiaagx/simulation_ws/src/sim/models/sphere.sdf', 'r')
        sdff =
        nome = "object"+str(objnum)
        self.spawn_model_prox(nome, sdff, "simplemodel",pos,"world")

The heightmap can be seen below:

<?xml version='1.0'?>
<sdf version="1.4">
  <model name="the_terrain">
    <link name="terrain_link">
      <collision name="terrain_collision">
            <size>100 100 0.25</size>
            <pos>0 0 0</pos>
      <visual name="terrain_visual">
              <size>100 100 0.25</size>
              <pos>0 0 0</pos>
                 <size> 1 </size>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-06-05 15:49:24 -0500

nlamprian gravatar image

This is a bug. There is a pull request open. Until this is handled, you can find a workaround here.

edit flag offensive delete link more


The workaround works perfectly, thank you for your swift response.

zokowc gravatar imagezokowc ( 2020-06-05 15:59:14 -0500 )edit

Two issues are presented upon further testing:

  1. After deletion, the heightmap is still visually present in gazebo GUI (however it no longer collides with other objects). I have added the heightmap sdf to the questions for reference.
  2. Calling make_3d_maze() after deletion of elements leads to a spawn error(element with the same name already present), this only happens to 4-5 objects randomly. (my maze is made out of 500-700 objects)

Note: gz GUI models tab shows no models after deletion

zokowc gravatar imagezokowc ( 2020-06-05 16:46:12 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2020-06-05 15:41:55 -0500

Seen: 81 times

Last updated: Jun 05 '20