Gazebo | Ignition | Community
Ask Your Question
0

/gazebo/delete_model ros service is unresponsive

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

zokowc gravatar image

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

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:
            self.make_3d_maze()
        else:
            self.remove_all()

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

def remove_all(self):
        print('starting delete proccess')
        for i in range(self.elements_added+1):
            print(i)
            x = self.del_model_prox("object"+str(i))
            rospy.loginfo(x)
        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>
        <static>true</static>
        <link name="link">
            <inertial>
                <mass>1.0</mass>
                <inertia>
                <ixx>0.083</ixx>
                <ixy>0.0</ixy>
                <ixz>0.0</ixz>
                <iyy>0.083</iyy>
                <iyz>0.0</iyz>
                <izz>0.083</izz>
            </inertia>
        </inertial>
        <collision name="collision">
            <geometry>
                <box>
                    <size>0.71 0.71 0.71</size>
                </box>
            </geometry>
        </collision>
        <visual name="visual">
            <geometry>
                <box>
                    <size>0.71 0.71 0.71</size>
                </box>
            </geometry>
            <material>
                <script>
                    <name>blotchy_0027</name>
                    <uri>model://scripts</uri>
                    <uri>model://textures</uri>
                </script>
            </material>
        </visual>
    </link>
</model>
</sdf>

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

elif shape_selection ==1:
        filename='/home/nvidiaagx/simulation_ws/src/sim/models/sphere.sdf'
        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 = f.read()
        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">
    <static>true</static>
    <link name="terrain_link">
      <collision name="terrain_collision">
        <geometry>
          <heightmap>
            <uri>/home/nvidiaagx/simulation_ws/src/sim/worlds/terrain2.png</uri>
            <size>100 100 0.25</size>
            <pos>0 0 0</pos>
          </heightmap>
        </geometry>
      </collision>
      <visual name="terrain_visual">
        <geometry>
           <heightmap>
              <uri>/home/nvidiaagx/simulation_ws/src/sim/worlds/terrain2.png</uri>
              <size>100 100 0.25</size>
              <pos>0 0 0</pos>
              <use_terrain_paging>false</use_terrain_paging>
              <texture>
                 <size> 1 </size>
                 <diffuse>file://media/materials/textures/dirt_diffusespecular.png</diffuse>
                 <normal>file://media/materials/textures/dirt_normal.png</normal>
              </texture>
           </heightmap>
         </geometry>
    </visual>
 </link>
</model>
</sdf>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

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

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

Comments

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

zokowc gravatar imagezokowc ( 2020-06-05 15:59:14 -0600 )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 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 128 times

Last updated: Jun 05 '20