ros-simulation / gazebo_ros_pkgs

Wrappers, tools and additional API's for using ROS with Gazebo
http://wiki.ros.org/gazebo_ros_pkgs
772 stars 773 forks source link

gazebo_plugins gazebo_ros_bumper no contact seen #155

Open ugocupcic opened 10 years ago

ugocupcic commented 10 years ago

When adding a gazebo_ros_bumper sensor to my urdf, I'm not able to get a contact from the published ROS topic (states stays empty, contact_size() = 0 on line 206), even though the contact seems to be detected by Gazebo, as shown in the attached screenshot.

error_bumper

I'm running ROS hydro on ubuntu 12.04. I tried both the default package installation, and a version installed from sources (both gazebo and gazebo plugins). You can find the urdf used here: https://gist.github.com/ugocupcic/7989409

Any help is greatly appreciated!

ugocupcic commented 10 years ago

After more digging, it appears that the issue comes from a different naming convention between gazebo and the ros plugin (?): the collision element we try to access in Gazebo is named __default__, but when imported from urdf, the name is linkname_collision by default.

I'm reporting this on Gazebo's bug tracker: https://bitbucket.org/osrf/gazebo/pull-request/882/fixing-the-contactsensor-in-gazebo/diff

scpeters commented 10 years ago

I saw your gazebo pull request; sorry I didn't look at your issue sooner.

I your issue can be resolved by adding some additional tags inside your <gazebo><sensor>. Here's an example from atlas_description in drcsim:

  <gazebo reference="r_foot">
    <!-- contact sensor -->
    <sensor type="contact" name="r_foot_contact_sensor">
      <update_rate>1000.0</update_rate>
      <always_on>1</always_on>
      <contact>
        <collision>r_foot_collision</collision>
        <topic>/r_foot_contact</topic>
      </contact>
    </sensor>
  </gazebo>

You'll want the <always_on> tag, and you'll also want to include the names of each collision element under <contact><collision>.

ugocupcic commented 10 years ago

Thanks for that clean solution! I spent ages trying to figure out what went wrong with those bumpers again....

I'd really suggest updating at least that link: http://gazebosim.org/wiki/Tutorials/1.9/ROS_Motor_and_Sensor_Plugins#Bumper

I found it very hard to find proper up to date information on that front (so much so that I opened those pull requests!). Thanks for the help.

nomadik commented 9 years ago

Dear Ugo, how can I get forces and postions of contacts with respect to the link frame that is in contact. In the curent version ROS Indigo got the Shadow hand, we are receiving contacts wrt world frame.

ugocupcic commented 9 years ago

@nomadik did this get sorted out? I saw your emails and the answer seemed to be to use tf?

hsu commented 9 years ago

there is a python code that does some frame manipulation

But I think you are looking for this functionality yet to be implemented correctly and enabled in the current bumper plugin?

scpeters commented 9 years ago

Gazebo's internal contact sensor reports forces and torques in a body-fixed reference frame as of gazebo pull request 355, which was around gazebo 1.6 I think. There is some discussion in gazebo issue 545.

I think this is more an issue with the gazebo ROS plugins though.

hsu commented 9 years ago

@scpeters thanks for the links. So it sounds like gazebo_plugins's bumper plugin is reporting in the link local frame.

nomadik commented 9 years ago

@ugocupcic in the shadow robot hand ros stack I increased the robot state publish rate up to 1 kHz and used tf to transform the contacts state to local frame.

ugocupcic commented 9 years ago

@nomadik OK thanks for letting me know.

Let's see how this evolves since it doesn't seem to be the cleanest solution (from the end user point of view).

An intermediate solution might be to implement a controller that takes the bumper and republish it with the proper transform using tf (similar to what's done for the joint states?)