ROS study notes (5): TF (Transform) coordinate conversion and principle analysis

table of Contents

6 TF

6.1 TF / TF tree format specification

6.2 TF related tool commands

6.3 TF principle

6.3.1 ROS coordinate system

6.3.2 Classification of coordinate system

6.3.3  setup Robot TF


6 TF

TF is a basic and important concept in ROS. TF (TransForm) is coordinate transformation.

Tf is essentially a tree-like data structure, so we usually call it "tf tree", tf can also be regarded as a topic: / tf, the message stored in the topic is the tf tree data structure format. The coordinate conversion relationship of the entire robot and even the map is maintained.

6.1 TF / TF tree format specification

The format specification of TransformStamped.msg is as follows:

std_mags/Header header
    uint32 seq
    time stamp
    string frame_id
string child_frame_id
geometry_msgs/Transform transform
    geometry_msgs/Vector3 translation
        float64 x
        float64 y
        float64 z
    geometry_msgs/Quaternion rotation
        float64 x
        float64 y
        flaot64 z
        float64 w

First, the header defines the serial number, time and frame name. Then I also wrote child_frame. The transformation between these two frames is defined by geometry_msgs / Transform. Vector3 three-dimensional vector represents translation, and Quaternion quaternion represents rotation.

In the end, many TransformStamped.msg sent to tf, forming a TF tree.

 

TF tree is formed by TF stitching between many frames. So what type is TF tree? as follows:

  • tf/tfMessage.msg
  • tf2_msgs/TFMessage.msg

There are two data types for TF, the main reason is the iteration of the version. Since ROS Hydro, the first generation of tf has been "deprecated" in favor of tf2.

How to check which version of TF you use, just use the command rostopic info / tf.

The standard format specifications of tf / tfMessage.msg or tf2_msgs / TFMessage are as follows:

geometry_msgs/TransformStamped[] transforms
    std_mags/Header header
        uint32 seq
        time stamp
        string frame_id
    string child_frame_id
    geometry_msgs/Transform transform
        geometry_msgs/Vector3 translation
            float64 x
            float64 y
            float64 z
        geometry_msgs/Quaternion rotation
            float64 x
            float64 y
            flaot64 z
            float64 w

A TransformStamped array is a TF tree.

6.2 TF related tool commands

  • Create a pdf graph based on the current tf tree:

        $ rosrun tf view_frames

       This tool first subscribes to / tf for 5 seconds, draws a tf tree based on the tf information received during this time, and then creates a pdf map.

  • View the current tf tree:

       $ rosrun rqt_tf_tree rqt_tf_tree

       This command also queries the tf tree, but the difference from the first command is that the command dynamically queries the current tf tree. Any current changes can be seen immediately, such as when to disconnect and when to catch These are then displayed through the rqt plugin.

  • View the transformation relationship between two frames:

      $ rosrun tf tf_echo[reference_frame][target_frame]

6.3 TF principle

6.3.1 ROS coordinate system

  • The coordinate system of ROS is defined with the right hand:

Therefore, for the ROS robot, if it is used as the original center of the coordinate system, then:

  • x axis: front

  • y-axis: left

  • z-axis: above

 

  • In a rotation around the axis, the right-hand definition is also used:

 

Hold the coordinate axis with your right hand, the direction of the thumb is toward the positive direction of the coordinate axis, and the direction of the four fingers around defines the positive direction of rotation along this coordinate axis

According to the definition of the right hand, positive rotation around the z axis is counterclockwise rotation

  1. Rotate around the Z axis, called the heading angle, using yaw;
  2. Rotate around the X axis, called the roll angle, use roll to indicate;
  3. Rotate around the Y axis, called pitch angle, use pitch to express;

Examples:

    The two-dimensional plane we usually use to describe the movement of the car refers to the XY plane, which is the plane composed of the X axis and the Y axis. In this plane, the angle used to describe the turning of the car is the rotation around the Z axis, which is often Said heading angle. The Z axis is facing upwards, so according to the right-hand rule, you can know that the car turns positive to the left and negative to the right.

  • Coordinate system definition

       At the same position in space, the coordinate values ​​are different under different coordinate systems.

 

In the figure above, there are two coordinate systems, coordinate system A and coordinate system B, where the orange coordinate axis represents the X axis (frontward) and the blue coordinate axis represents the Y axis (leftward). For coordinate system A, the coordinates of pink dots are ** (3, -3), for coordinate system B, the coordinates of pink dots are (5, 1) **

  • Units of measurement:

ROS uses metric system:

          > Linear speed: m / s

         > Angular velocity: rad / s

Linear speed = 0.5m / s is a fairly fast speed for an indoor robot. Angular velocity = 1.0rad / s means 6 seconds of rotation.

Refer to:

https://www.cnblogs.com/hiram-zhang/p/10392877.html

https://blog.csdn.net/shixiaolu63/article/details/78496457

https://blog.csdn.net/autolabor/article/details/85120806

 

6.3.2 Classification of coordinate system

There are usually multiple three-dimensional reference coordinate systems in a robot system, and the relative relationship between these coordinate systems will change with time. Here is an example of an actual robot application scenario to illustrate this relationship and changes

  1. Global world coordinate system: usually the coordinate system map of the raster map constructed by laser slam.
  2. Robot chassis coordinate system: usually the robot chassis coordinate system base_footprint or base_link.
  3. The coordinate system of each component on the robot: such as the lidar, imu and other sensors' own coordinate system base_laser_link, imu_link.

Some of the relationships between these coordinate systems are static and some are dynamic. When the robot chassis moves, the relative relationship between the robot chassis and the world map-> base_footprint is dynamic;

The relative relationship between the sensors such as lidar and imu installed on the robot chassis and the robot chassis base_footprint-> base_laser_link, base_footprint-> imu_link is static.

 

6.3.3  setup Robot TF

http://wiki.ros.org/navigation/Tutorials/RobotSetup/TF

https://www.ros.org/reps/rep-0105.html

 

Published 31 original articles · Like 3 · Visits 2028

Guess you like

Origin blog.csdn.net/lclfans1983/article/details/105399161