ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you want to get the position of the robot, the easiest way to do that is with the position_3d controller. Add the following to your urdf file:

<gazebo>
  <controller:gazebo_ros_p3d name="p3d_base_controller" plugin="libgazebo_ros_p3d.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>100.0</updateRate>
    <bodyName>base_link</bodyName>
    <topicName>base_pose_ground_truth</topicName>
    <gaussianNoise>0</gaussianNoise>
    <frameName>map</frameName>
    <xyzOffsets>0 0 0</xyzOffsets> 
    <rpyOffsets>0 0 0</rpyOffsets>
    <interface:position name="p3d_base_position"/>
  </controller:gazebo_ros_p3d>
</gazebo>

Change "base_link" to the link you'd like to know the position of, and change "base_pose_ground_truth" to the topic that you wish to publish to. Then, if you subscribe to that topic in your teleop node, you can see the link's absolute position relative to the Gazebo world (0,0,0) coordinate.

If you want to get the position of the robot, the easiest way to do that is with the position_3d controller. Add the following to your urdf file:

<gazebo>
  <controller:gazebo_ros_p3d name="p3d_base_controller" plugin="libgazebo_ros_p3d.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>100.0</updateRate>
    <bodyName>base_link</bodyName>
    <topicName>base_pose_ground_truth</topicName>
    <gaussianNoise>0</gaussianNoise>
    <frameName>map</frameName>
    <xyzOffsets>0 0 0</xyzOffsets> 
    <rpyOffsets>0 0 0</rpyOffsets>
    <interface:position name="p3d_base_position"/>
  </controller:gazebo_ros_p3d>
</gazebo>

Change "base_link" to the link you'd like to know the position of, and change "base_pose_ground_truth" to the topic that you wish to publish to. Then, if you subscribe to that topic in your teleop node, you can see the link's absolute position relative to the Gazebo world (0,0,0) coordinate. This message is nav_msgs/Odometry.

If you want to get the position of the robot, the easiest way to do that is with the position_3d controller. Add the following to your urdf file:

<gazebo>
  <controller:gazebo_ros_p3d name="p3d_base_controller" plugin="libgazebo_ros_p3d.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>100.0</updateRate>
    <bodyName>base_link</bodyName>
    <topicName>base_pose_ground_truth</topicName>
    <gaussianNoise>0</gaussianNoise>
    <frameName>map</frameName>
    <xyzOffsets>0 0 0</xyzOffsets> 
    <rpyOffsets>0 0 0</rpyOffsets>
    <interface:position name="p3d_base_position"/>
  </controller:gazebo_ros_p3d>
</gazebo>

Change "base_link" to the link you'd like to know the position of, and change "base_pose_ground_truth" to the topic that you wish to publish to. Then, if you subscribe to that topic in your teleop node, you can see the link's absolute position relative to the Gazebo world (0,0,0) coordinate. This message is nav_msgs/Odometry.nav_msgs/Odometry. It will give you position, velocity, and acceleration.

If you want to get the position of the robot, the easiest way to do that is with the position_3d controller. Add the following to your urdf file:

<gazebo>
  <controller:gazebo_ros_p3d name="p3d_base_controller" plugin="libgazebo_ros_p3d.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>100.0</updateRate>
    <bodyName>base_link</bodyName>
    <topicName>base_pose_ground_truth</topicName>
    <gaussianNoise>0</gaussianNoise>
    <frameName>map</frameName>
    <xyzOffsets>0 0 0</xyzOffsets> 
    <rpyOffsets>0 0 0</rpyOffsets>
    <interface:position name="p3d_base_position"/>
  </controller:gazebo_ros_p3d>
</gazebo>

Change "base_link" to the link you'd like to know the position of, and change "base_pose_ground_truth" to the topic that you wish to publish to. Then, if you subscribe to that topic in your teleop node, you can see the link's absolute position relative to the Gazebo world (0,0,0) coordinate. This message is nav_msgs/Odometry. It will give you position, velocity, position and acceleration.

velocity.

To subscribe to this topic, you can use something like the following in teleop.cpp:

ros::Subscriber base_pose_sub_ = node_.subscribe<nav_msgs::Odometry> ("base_pose_ground_truth", 100, &Teleop::GroundTruthCallback, this);

You can find more on subscribers [here](http://www.ros.org/wiki/ROS/Tutorials/WritingPublisherSubscriber(c%2B%2B). You can find a description of the nav_msgs::Odometry message here.