Wheel odometry calibration
Wheel odometry calibration is a method for calibrating the rotation and movement of a robot's wheels to provide accurate position and orientation information during robot motion. Through calibration, errors caused by factors such as wheel size and wheelbase can be corrected, resulting in a more accurate motion trajectory. This section will use the MyCar navigation robot as an example to demonstrate the calibration process, with the following calibration steps:
- Prepare the measurement site.
- Linear displacement calibration;
- Angular displacement calibration;
- Verification and adjustment.
Additionally, this process also requires using a ruler as a measuring tool.
1. Prepare the measurement site
Choose an open and flat area, making sure there are no obstacles or other distractions.
2. Linear Displacement Calibration
Linear displacement calibration is used to calibrate the distance a robot travels when moving in a straight line. This calibration is closely related to the wheel diameter parameter. When the wheel diameter is measured inaccurately or the tires are worn, it can cause errors in the linear displacement of the wheel odometry. The following are the main steps for linear displacement calibration:
(1) Actual Data Collection
Start the robot chassis and keyboard control node, then use the keyboard to drive the robot forward in a straight line for a certain distance while measuring linear displacement data.
(2) Odometry Message Collection
After the robot stops, output the odometry message and retrieve the robot's displacement data from the odometry message.
(3) Parameter Calculation and Modification
Collect the actual displacement data (w1) and the displacement data from the odometry message (w2), then combine them with the original tire diameter value (d1) from the driver package configuration file to calculate the corrected tire diameter value (d). The calculation formula is as follows:
d = w1 / w2 * d1;
Write the calculated results into the corresponding parameters of the MyCar robot's configuration file, and rebuild.
For best results, you can repeat the above process multiple times. After each execution, measure and record the new actual displacement data (w1) and the displacement data from the odometry message (w2), then recalculate the corrected tire diameter value (d) based on the new data. By continuously iterating this process, you can gradually optimize the estimated tire diameter and reduce the linear displacement error of the odometry.
Tip:
If you are using the MyCar two-wheel differential robot with an Arduino as the main controller, you will need to modify the
params/arduino.yamlfile under theros2_arduino_bridgepackage. In this file, there is a parameter namedwheel_diameter, which represents the wheel diameter.If you are using a MyCar two-wheel differential robot with an STM32 as the main controller, you need to modify the
params/stm32_2w.yamlfile under theros2_stm32_bridgepackage. In this file, there is a parameter namedwheel_diameter, which is the wheel diameter.If you are using the MyCar four-wheel differential robot with an STM32 as the main controller, you need to modify the
params/stm32_4w.yamlfile under theros2_stm32_bridgepackage. In this file, there is a parameter namedwheel_diameter, which is the wheel diameter.
3. Angular Displacement Calibration
Angular displacement calibration is used to calibrate the robot's angle change during turns. This calibration is closely related to the chassis's rotation radius parameter; when the rotation radius is set incorrectly, it can lead to measurement errors in angular displacement. Additionally, it is important to note that for a two-wheel differential drive robot, the rotation radius is essentially the same as the wheel track. This is because a two-wheel differential drive robot does not experience lateral sliding of the chassis during rotation, so the wheel track can be used to calculate the rotation angle, and the rotation radius can be approximated as equal to the wheel track. However, for a four-wheel differential drive robot, lateral sliding occurs during rotation, and the wheel track cannot be directly used to calculate the rotation angle. The rotation radius of a four-wheel differential drive robot must be determined experimentally, as it is affected by lateral sliding. Furthermore, due to factors such as differences between the left and right tires or shifts in the vehicle's center of gravity, the rotation radius used to calculate the rotation angle may differ between left and right turns. Therefore, separate experiments are required to obtain the rotation radius for left and right turns.
Here are the main steps for angular displacement calibration:
(1) Actual Data Collection
Start the robot chassis and keyboard control node, use the keyboard to make the robot rotate in place, and measure the angular displacement data, for example, by rotating a full circle in place.
(2) Odometry Message Collection
After the robot stops, open rviz2 and add the TF plugin to display the relative relationship between the robot's base coordinate system (typically base_link or base_footprint) and the odometry coordinate system (typically odom).
(3) Parameter Calculation and Modification
When the robot rotates in place for one full turn, if the robot's base coordinate system aligns with the odometry coordinate system, the rotation radius parameter does not need adjustment. If the robot's base coordinate system does not align with the odometry coordinate system and the robot's rotation angle in rviz2 is larger than the actual rotation angle, then increase the rotation radius. If the robot's base coordinate system does not align with the odometry coordinate system and the robot's rotation angle in rviz2 is smaller than the actual rotation angle, then decrease the rotation radius. Write the calculated result into the corresponding parameter in the MyCar robot's configuration file, and rebuild.
For best results, the above process can be repeated multiple times. After each execution, measure and record the new actual angular displacement data and the coordinate frame relationships in rviz2, then correct the rotation radius again based on the new data. By continuously iterating this process, the estimated value of the rotation radius can be gradually optimized, reducing the measurement error of the angular displacement.
Tip:
If you are using an Arduino-based MyCar two-wheel differential robot, you need to modify the
params/arduino.yamlfile under theros2_arduino_bridgepackage. In this file, there is a parameter calledwheel_track, which represents the wheel diameter. Inros2_arduino_bridge, no distinction is made between left and right rotation.If you are using a MyCar two-wheel differential robot with an STM32 as the main controller, you need to modify the
params/stm32_2w.yamlfile under theros2_stm32_bridgepackage. When the robot rotates left, the parameter to calibrate ismodel_param_acw; when the robot rotates right, the parameter to calibrate ismodel_param_cw.If you are using the MyCar four-wheel differential robot with an STM32 as the main controller, you will need to modify the
params/stm32_4w.yamlfile under theros2_stm32_bridgepackage. Similar to the two-wheel differential case, when the robot rotates left, the parameter to calibrate is namedmodel_param_acw, and when the robot rotates right, the parameter to calibrate is namedmodel_param_cw.
4. Verification and Adjustment
Apply the calibrated wheel odometry to real-world scenarios, and perform verification and adjustments. Observe the differences between the vehicle's actual position and motion and the estimated values, and make necessary adjustments and calibrations. Additionally, when the vehicle's operating environment changes or after prolonged use, it is recommended to recalibrate the odometry.