ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org
Ask Your Question
1

Adding sensors to gazebo - from scratch

asked 2013-01-08 23:05:11 -0500

gordon gravatar image

updated 2014-04-20 14:06:46 -0500

ngrennan gravatar image

Hi,

I am new to ROS and gazebo. I have created a world in gazebo and now I wish to add few contact sensors to it. Can someone please tell me how to add a sensor to the world and give a sample xml code if possible ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-01-09 04:17:46 -0500

davinci gravatar image
edit flag offensive delete link more
0

answered 2013-01-09 18:51:58 -0500

gordon gravatar image

This is the code I used

<?xml version="1.0"?>
<robot xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"
       xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"
       xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"
       xmlns:xacro="http://ros.org/wiki/xacro"
       name="sensorc">

<link name="sensor">
     <inertial>
      <origin xyz="-1 -1 0.5" rpy="0 0 0" /> 
      <mass value="10.0" />
      <inertia  ixx="1.0" ixy="0.0"  ixz="0.0"  iyy="100.0"  iyz="0.0"  izz="1.0" />
    </inertial>
    <visual>
      <origin xyz="-1 -1 0.5" rpy="0 0 0" /> 
      <geometry>
        <box size="1 1 1" />
      </geometry>
    </visual>
    <collision>
     <origin xyz="-1 -1 0.5" rpy="0 0 0" /> 
      <geometry>
       <box size="1 1 1" />
      </geometry>
    </collision>
  </link>
  <gazebo reference="sensor">
    <material>Gazebo/White</material>    
  </gazebo>

<gazebo reference="sensor">
      <selfCollide>true</selfCollide>
      <sensor:contact name="contact_sensor">
        <parent link="sensor"/>
        <updateRate>100.0</updateRate>
        <controller:gazebo_ros_bumper name="gazebo_ros_bumper_controller" plugin="libgazebo_ros_bumper.so">
          <alwaysOn>true</alwaysOn>
          <updateRate>100.0</updateRate>
          <bumperTopicName>contact_bumper</bumperTopicName>
          <interface:bumper name="contact_bumper_iface" />
        </controller:gazebo_ros_bumper>
      </sensor:contact>
    </gazebo>
</robot>

And I run the turtlebot simulator and dash the turtlebot against the "sensor". Now I run rostopic echo /contact_bumper/state I get this

header: 
  seq: 31066
  stamp: 
    secs: 458
    nsecs: 186000000
  frame_id: world
states: []

I don't get why I am not getting the contact information i.e force and body name. Is there a mistake I am doing ?

edit flag offensive delete link more

Comments

Please open a new question instead of asking in the answer form.

Boris gravatar imageBoris ( 2013-01-09 19:36:16 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-01-08 23:05:11 -0500

Seen: 1,087 times

Last updated: Jan 09 '13