In laser SLAM and ROS, the understanding of several coordinate systems and coordinate transformations of map, odom, laser_link, and base_link

Since the SLAM process needs to use different sensors to perceive and observe the environment, and each sensor should have a coordinate system, so many coordinate transformations are involved in the entire SLAM process. I want to understand the SLAM process. , need to have a full understanding of these coordinate transformations, this article mainly records my understanding of coordinate transformations in laser SLAM (under ROS)

In ROS, common coordinate systems include map, odom, base_link, laser_link, and the transformations between these coordinate systems are explained below.

base_link\rightarrowlaser_link

Understanding of two coordinate systems:

base_link generally refers to the coordinate system with the robot as the origin, which can be directly understood as the robot itself, and laser_link refers to the coordinate system centered on the lidar (other sensor coordinate systems similar to imu, which are installed on the robot, are similar to laser_link). The transformation between the two coordinate systems is relatively simple and generally static, because once the sensor is installed on the robot, it will not move again, so you only need to issue a static TF transformation to complete the transformation between base_link and laser_link.

 As shown in the figure, the radar scans an obstacle 3m ahead, but for the robot, the obstacle is 6m ahead. The reason for this gap is that the two observe the same obstacle in different coordinate systems. The purpose of coordinate transformation is to unify this observation, either in the radar coordinate system, it is considered that there is an obstacle at 3m, or in the robot coordinate system, it is considered that there is an obstacle at 6m.

When is coordinate transformation used?

When the sensors on the robot collect data, the data are located in each sensor coordinate system, such as the mileage obtained by the radar through the icp algorithm. If you want to draw the robot's trajectory in world coordinates, you need to use laser_link The coordinate transformation to base_link converts the mileage data from the radar coordinate system to the robot coordinate system, and then converts to odom and map layer by layer.

Who will post it?

Generally, we directly write the static coordinate transformation to publish

odom\rightarrowbase_link

Understanding of two coordinate systems:

odom is the odometer coordinate system, in which the movement of the robot can already be described. After the information released by the robot odometer is converted to the odom coordinate system, it can intuitively reflect the movement mileage of the robot. The coordinate transformation between odom and base_link is issued by the odometer. When the robot is moving, it is moving relative to the odom system. The robot moves forward 10m, which means that it moves 10m on the odom system. But note that the two coordinate systems of odom and map are not coincident. How much movement on the map requires an odom-to-map conversion. The reason why the odom and the map do not coincide is that there is an error. The 10m advance on the odom is measured by the sensor, but the real moving distance is not necessarily 10m.

When is coordinate transformation used?

The odometer of the robot, such as radar, etc., obtains the motion (x, y, theta) of the robot between two frames of data through algorithms such as icp, and accumulates (x, y, theta) for a period of time to obtain The trajectory and mileage of the robot during this period, but (x, y, theta) is obtained by the sensor and is under laser_link, so it needs to be converted to base_link and then converted to odom to obtain the corresponding trajectory and mileage.

Who will post it?

Usually issued by the odometer

map\rightarrowodom

Understanding of two coordinate systems:

The map is the world coordinates. Generally, we observe the movement of the robot from the perspective of the map. The map created by the robot in the SLAM process is also in the map coordinate system. The movement of the robot in ROS can be understood as publishing the coordinate transformation from the base_link map \rightarrow. Let the base_link move in the map, and the coordinate transformation from the map to the base_link is calculated by the positioning module. But the positioning module does not publish the conversion from map to base_link. Instead, it first accepts the conversion from odom to base_link, and then calculates and broadcasts the position conversion relationship from map to odom. It is an indirect process.

When is coordinate transformation used?

Map is mainly used in map construction. The process of map construction is actually the process of scanning the surrounding information at the correct position in the map and building a grid map. The correct position is obtained by transforming the position in the odom into the map. of.

Who will post it?

Generally released by the positioning module

How to reflect the coordinate transformation in the code?

In the code, the coordinate transformation is generally processed through the tf library, and the coordinate transformation between the two coordinate systems is stored by establishing a transformation matrix T. When performing coordinate transformation, follow the steps below:

  1. Convert the data to the format required by TF, and create a container V from TF to store the data
  2. Coordinate transformation is performed by multiplying the transformation matrix T, V(base_link) = V(laser_link) * T(laser_link to base_link)
  3. After getting V(base_link), convert the data from TF format to original format for further processing

Example:

  tf2::Transform corr_ch;
 
    if (output_.valid)
    {
        // 将雷达数据转换为TF格式数据corr_ch_1
        tf2::Transform corr_ch_l;
        CreateTfFromXYTheta(output_.x[0], output_.x[1], output_.x[2], corr_ch_l);
 
        // 将雷达坐标系下的数据 转换成 base_link坐标系下
        corr_ch = base_to_laser_ * corr_ch_l * laser_to_base_;
 
        // 将base_link坐标系下的数据,转换到odom坐标系下
        base_in_odom_ = base_in_odom_keyframe_ * corr_ch;
   
    }

Guess you like

Origin blog.csdn.net/weixin_43890835/article/details/131546455