the controller can not subscribe to the topic from gazebo

asked 2014-04-02 03:56:46 -0500

hannuaa gravatar image

updated 2014-04-02 03:58:44 -0500

demmeln gravatar image

Hi , everyone. Now, I add a contact sensor for the robot in xacro file, as follow:

<gazebo reference="${robot_name}left_lower_arm">
   <selfCollide>false</selfCollide>
   <sensor type="contact" name="left_lower_arm_contact_sensor">
      <update_rate>100.0</update_rate>
      <contact>
        <collision>${robot_name}left_lower_arm_geom</collision>
      </contact>

      <plugin name="left_lower_arm_gazebo_ros_bumper_controller" filename="libgazebo_ros_bumper.so">
        <alwaysOn>true</alwaysOn>
        <updateRate>100.0</updateRate>
        <bumperTopicName>${robot_name}left_lower_arm_contact</bumperTopicName>
      </plugin>
   </sensor>
   <material>PR2/Grey2</material>
</gazebo>

I can get the data of the contact sensor by typing "rostopic echo r2/left_lower_arm_contact". But when I program in the controller to get the sensor data, I get nothing. The program in the controller is as follow:

left_hand_contact_sub = node.subscribe("r2/left_lower_arm_contact", 10, &R2ImpedanceController::left_hand_contact, this);

My ROS is groovy.Any answer to these questions, or any suggestion is very welcome!

edit retag flag offensive close merge delete

Comments

Use rxgraph or rqt_graph to check the connectivity between gazebo and your node for the `r2/left_lower_arm_contact` topic. Include some more of your code, in particular how you create the `node` object. How do you notice that you get "nothing"? What does the callback look like?

demmeln gravatar image demmeln  ( 2014-04-02 04:07:30 -0500 )edit