Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

/gazebo/delete_model ros service is unresponsive

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")

/gazebo/delete_model ros service is unresponsive

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>