Home | Tutorials | Wiki | Issues
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I tried your example and made a complete robot with the information you provided:

<robot name="bumper_test" xmlns:xacro="http://ros.org/wiki/xacro">
  <xacro:macro name="box_inertial" params="x y z mass *origin">
    <inertial>
      <mass value="${mass}" />
      <xacro:insert_block name="origin" />
      <inertia ixx="${0.0833333 * mass * (y*y + z*z)}" ixy="0.0" ixz="0.0"
        iyy="${0.0833333 * mass * (x*x + z*z)}" iyz="0.0"
        izz="${0.0833333 * mass * (x*x + y*y)}" />
    </inertial>
  </xacro:macro>
  <link name="chassis">
    <xacro:box_inertial x="2" y="1" z="1" mass="100">
      <origin xyz="0  0 0" rpy="0 0 0" />
    </xacro:box_inertial>
    <visual>
      <geometry>
        <box size="2 1 1" />
      </geometry>
    </visual>
    <collision name="chassis_collision">
      <geometry>
        <box size="2 1 1" />
      </geometry>
    </collision>
  </link>
  <link name="bumper0">
    <visual>
      <geometry>
        <box size="0.1 0.1 0.1" />
      </geometry>
    </visual>
    <collision name="bumper0_collision">
      <geometry>
        <box size="0.1 0.1 0.1" />
      </geometry>
    </collision>
  </link>
  <joint name="chassis_bumper_joint" type="fixed">
    <parent link="chassis" />
    <child link="bumper0" />
    <origin xyz="1  0.5 0" rpy="0 0 0" />
    <axis xyz="0 1 0" />
  </joint>

  <gazebo reference="bumper0">
    <sensor name="bumper0_sensor" type="contact">
      <always_on>true</always_on>
      <update_rate>30</update_rate>
      <contact>
        <collision>bumper0_collision</collision>
      </contact>
      <plugin name="bumper0_plugin" filename="libgazebo_ros_bumper.so">
        <bumperTopicName>bumper0_sensor_state</bumperTopicName>
        <frameName>bumper0</frameName>
      </plugin>
    </sensor>
  </gazebo>
</robot>

which does work perfectly for me. Make sure you have the inertial properties set of your parent link.

Let me know if this example does work for you too. Cheers