ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Error spawning many urdf's in Gazebo

asked 2016-04-16 12:34:23 -0500

sefi_roee gravatar image

Hi, I observe strange behavior in Gazebo when I'm trying to spawn many objects.

I created this xacro file for the object:

<?xml version="1.0"?>

<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="box_obstacle">
   <xacro:arg name="row" default="0"/>
   <xacro:arg name="col" default="0"/>
   <xacro:arg name="width" default="1"/>
   <xacro:arg name="height" default="1"/>

  <link name="obstacle" type="fixed">
    <inertial>
      <origin xyz="$(arg row) $(arg col) 0.5" />
      <mass value="1.0" />
      <inertia  ixx="0.0" ixy="0.0"  ixz="0.0"  iyy="0.0"  iyz="0.0"  izz="0.0" />
    </inertial>
    <visual>
      <origin xyz="$(arg row) $(arg col) 0.5"/>
      <geometry>
        <box size="$(arg width) $(arg height) 1" />
      </geometry>
    </visual>
    <collision>
      <origin xyz="$(arg row) $(arg col) 0.5"/>
      <geometry>
        <box size="$(arg width) $(arg height) 1" />
      </geometry>
    </collision>
  </link>
  <gazebo reference="obstacle">
    <static>true</static>
    <material>Gazebo/Black</material>
  </gazebo>

</robot>

and my launch file looks like this:

 <launch>
     <arg name="world" default="$(find my_package)/worlds/empty.world"/>

      <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
      <include file="$(find gazebo_ros)/launch/empty_world.launch">
          <arg name="world_name" value="$(arg world)"/>
      </include>

     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro row:=6.5 col:=4.0 width:=3 height:=6" name="obstacle_0" />
     <node args="-urdf -param obstacle_0 -model obstacle_0" name="spawn_obstacle_0" output="screen" pkg="gazebo_ros" respawn="false" type="spawn_model" />
     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro row:=4.5 col:=4.0 width:=1 height:=2" name="obstacle_1" />
     <node args="-urdf -param obstacle_1 -model obstacle_1" name="spawn_obstacle_1" output="screen" pkg="gazebo_ros" respawn="false" type="spawn_model" />
     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro row:=-4.5 col:=-9.0 width:=9 height:=2" name="obstacle_2" />
     <node args="-urdf -param obstacle_2 -model obstacle_2" name="spawn_obstacle_2" output="screen" pkg="gazebo_ros" respawn="false" type="spawn_model" />
</launch>

This works fine with few "obstacles", but when I try about 10 (instead of 3 here) the simulator doing unexpected things (I'm trying to attach images but >5 points are needed :(, the linkes below will be valid only for 1 week).

 <launch>
     <arg name="world" default="$(find my_package)/worlds/empty.world"/>

      <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
      <include file="$(find gazebo_ros)/launch/empty_world.launch">
          <arg name="world_name" value="$(arg world)"/>
      </include>

     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro row:=6.5 col:=4.0 width:=3 height:=6" name="obstacle_0" />
     <node args="-urdf -param obstacle_0 -model obstacle_0" name="spawn_obstacle_0" output="screen" pkg="gazebo_ros" respawn="false" type="spawn_model" />
     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro row:=4.5 col:=4.0 width:=1 height:=2" name="obstacle_1" />
     <node args="-urdf -param obstacle_1 -model obstacle_1" name="spawn_obstacle_1" output="screen" pkg="gazebo_ros" respawn="false" type="spawn_model" />
     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-04-18 02:08:30 -0500

F.Brosseau gravatar image

updated 2016-04-22 03:44:24 -0500

There is a static tag for models : http://sdformat.org/spec?ver=1.6&elem=model

You can try to add the following lines to your urdf file (inside the robot tags) :

Update :

<gazebo>
    <static>true</static>
</gazebo>

<gazebo reference="obstacle">
    <material>Gazebo/Black</material>
</gazebo>
edit flag offensive delete link more

Comments

Thanks. As you can see, I already have similar line in my .xacro file

<gazebo reference="obstacle"><static>true</static><material>Gazebo/Black</material></gazebo>

Do you think there is a difference between "1" and "true"?

sefi_roee gravatar image sefi_roee  ( 2016-04-18 02:26:40 -0500 )edit

Sorry I didn't saw these lines. Can you check in Gazebo GUI that your models are really static ?

F.Brosseau gravatar image F.Brosseau  ( 2016-04-18 02:51:08 -0500 )edit

NP. In the Gazebo GUI i can see that the "static" attribute of the model is checked, but the models are still being affected by the physics. (For example, when i put two model on top of each other, I can see the gravity and other forces moving both the models).

sefi_roee gravatar image sefi_roee  ( 2016-04-18 03:10:44 -0500 )edit

I use also gazebo with static = true and I have no problem. I also had <gravity>0</gravity>

F.Brosseau gravatar image F.Brosseau  ( 2016-04-18 04:47:46 -0500 )edit

Hi, Tnx. I tried gravity=0, objects now flying around :( Did you see the pics i attached? Is this happening to you too?

sefi_roee gravatar image sefi_roee  ( 2016-04-19 22:05:27 -0500 )edit

I saw the pics but I didn't had this problem. Maybe you can try to add a fixed joint between your flying objects and the world. Maybe you can have more help on this forum : http://answers.gazebosim.org/questions/

F.Brosseau gravatar image F.Brosseau  ( 2016-04-20 01:51:37 -0500 )edit

Could you please give me pic of the objects in your environment? Tnx a lot

sefi_roee gravatar image sefi_roee  ( 2016-04-20 02:15:55 -0500 )edit

I used your code and I saw obstacle 4,6 and 9 "shaking". In your obstacle.urdf.xacro file, I changed <gazebo reference="obstacle"> to <gazebo> and there is no problem anymore

Answer updated

F.Brosseau gravatar image F.Brosseau  ( 2016-04-22 03:34:39 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-04-16 12:34:23 -0500

Seen: 690 times

Last updated: Apr 22 '16