Gazebo bumper sensor states msg shows no output

asked 2019-09-27 14:57:23 -0500

jatinm gravatar image

updated 2019-09-27 15:01:48 -0500

I have a simple robot with two wheels and I am trying to add bumper sensors on each side. The goal is to create a blind robot which has a bumper/contact sensor to sense the walls in its world and then make it navigate through the world.

I can see the topic /state_bumper in rostopic list and echo it, but I cannot see any values in states msg as shown below:

$ rostopic echo /state_bumper 
header: 
  seq: 75
  stamp: 
    secs: 480
    nsecs: 588000000
  frame_id: "world"
states: []
---
header: 
  seq: 76
  stamp: 
    secs: 480
    nsecs: 588000000
  frame_id: "world"
states: []
---

Please help me understand where am I going wrong.

I have only shown below the bumper sensor-related code and cut out the robot links codes. I have two separate amp_robot.xacro and amp_robot.gazebo files which I then convert to urdf and sdf files to see the collision tag names and make sure they are the same. This was indicated as a solution in similar questions but does not work for me. I use these commands to convert the files:

$ rosrun xacro xacro -o amp_robot.urdf amp_robot.xacro

$ gz sdf -p amp_robot.urdf > amp_robot.sdf

Robot URDF:

<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- |    This document was autogenerated by xacro from amp_robot.xacro                | -->
<!-- |    EDITING THIS FILE BY HAND IS NOT RECOMMENDED                                 | -->
<!-- =================================================================================== -->
<!-- x-green y-red z-blue - for all values - depending on where robot is facing - generally x-->
<robot name="amp_robot" xmlns:xacro="http://www.ros.org/wiki/xacro">
  <gazebo>
    <gazebo reference="bumper_link">
    <selfCollide>false</selfCollide>
    <sensor name="bump_sensor" type="contact">
      <update_rate>15.0</update_rate>
      <visualize>true</visualize>
      <contact>
        <collision>robot_footprint_fixed_joint_lump__bumper_collision_collision_3</collision>
        <!--<topic>__default_topic__</topic>-->
        <topic>state_bumper</topic>
      </contact>
      <plugin filename="libgazebo_ros_bumper.so" name="state_gazebo_ros_bumper_controller">
        <alwaysOn>true</alwaysOn>
        <updateRate>15.0</updateRate>
        <bumperTopicName>state_bumper</bumperTopicName>
        <frameName>world</frameName>
      </plugin>
    </sensor>
  </gazebo>

  <link name="bumper_link">
    <inertial>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <mass value="1e-5"/>
      <inertia ixx="1e-6" ixy="0" ixz="0" iyy="1e-6" iyz="0" izz="1e-6"/>
    </inertial>
    <visual>
      <origin rpy="0 0 0" xyz="0.2 0 0"/>
      <geometry>
        <box size="0.1 0.05 0.05"/>
      </geometry>
      <material name="DarkGrey"/>
    </visual>
    <collision>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <box size="0.1 0.05 0.05"/>
      </geometry>
      <material name="DarkGrey"/>
    </collision>
  </link>
  <joint name="bumper_joint" type="fixed">
    <origin rpy="0 0 0" xyz="0.08 0 0.04"/>
    <axis xyz="0 1 0"/>
    <!--<insert_block name="origin"/>-->
    <parent link="chassis"/>
    <child link="bumper_link"/>
  </joint>

Robot SDF

 <collision name='robot_footprint_fixed_joint_lump__bumper_link_collision_3'>
        <pose frame=''>0.08 0 0.04 0 -0 0</pose>
        <geometry>
          <box>
            <size>0.1 0.05 0.05</size>
          </box>
        </geometry>
        <surface>
          <contact>
            <ode/>
          </contact>
          <friction>
            <ode/>
          </friction>
        </surface>
      </collision>

<visual name='robot_footprint_fixed_joint_lump__bumper_link_visual_3'>
        <pose frame=''>0.28 0 0.04 0 -0 0</pose> ...
(more)
edit retag flag offensive close merge delete