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

# ROS Transform between robot and map

I have an odometry message which is the current position of my robot. (For example odometry.pose.pose.position (x=1, y=1, z=0)

Then I have a sensor mounted on the robot (x + 1.2, y +0, z+0)

Lets assume there is a point P1 in the sensor at (x = 2, y=0, t=0) Therefore it would be (x=3.2,y=0,z=0) in the robot frame (x=4.2, y=1, z=0) in world frame without orientation.

But how do I correctly calculate the position with respect to odometry orientation? Using geometry_msgs::Quaternion (odometry message) and geometry_msgs::Pose (Point P1)

Also, Could someone explain or link me to resources on how to do this in TF instead of manually calculating?

edit retag close merge delete

Sort by ยป oldest newest most voted

I assume you have a ROS node that is correctly publishing an Odometry transform. If you don't look at this tutorial:

Next, you should also have a ROS driver for your ranging sensor. If so, your distance measurements (published as a ROS message) are expressed in the sensor reference frame.

Then you need to set up a static transform in order to express where the sensor is located with respect to your robot frame. There are several ways how to to this, for instance:

• Starting a static_transform_publisher via launch file
• As a ROS node
• Using an URDF model of your robot and robot_state_publisher to broadcast TF values
• Running a static_transform_publisher via command line tools

Here is an example on how to set up static transforms from the launch file:

<launch>
<node name="camera_pose" pkg="tf2_ros" type="static_transform_publisher"
</launch>


TO-DO: set these actual transform values based on the real robot. Under args you define an x/y/z offset in meters and yaw/pitch/roll in radians. (yaw is rotation about Z, pitch is rotation about Y, and roll is rotation about X).

To publish a transform from odometry to map you need a node that can solve the global localization problem.
For instance you could use AMCL. AMCL is a bit broad subject to discuss in details.

Here are some other resources to get you started:

TF tutorials in general

How to write your own ROS node that sets a static transform broadcaster:

If you choose to follow the URDF + robot_state_publisher path:
- URDF tutorials
- Using the robot state publisher on your own robot

To fire up a static_transform_publisher from the terminal run the following command:

rosrun tf2_ros static_transform_publisher 1.2 0 0 0 0 0 1 base_link camera_link


Finally to look at the TF tree you can generate a TF tree PDF file with this command:

rosrun tf view_frames

more