yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
RDK X5 Robot📖
01. RDK-X5-Robot Introduction
  • 1.Introduction
  • 2.Common Problem Analysis
  • 3.Battery and charger usage precautions
  • 4.TF card expand capacity
02. Assembly Tutorial
  • Assembly Tutorial
  • Assembly Video-1
  • Assembly Video-2
  • Assembly Video-3
  • Assembly Video-4
03. Remote Control Course
  • 1.Mobile APP remote control
  • 2.USB Wireless Controller Remote Control
04. ROS Driver Board Course
  • 1. Introduction of extension board
  • 2. Set up STM32 development environment
  • 3. Key control buzzer sound
  • 4. FreeRTOS application
  • 5. Serial communication
  • 6. SBUS model remote control
  • 7. CAN bus communication
  • 8. RGB color light strip
  • 9. Timer interrupt control PWM servo
  • 10. Control serial steering gear
  • 11. Nine-axis attitude sensor to obtain data
  • 12. Control motor forward and reverse
  • 13. The timer captures encoder data
  • 14. Theory of robot kinematics analysis
  • 15. PID control robot motion
05. Basic Control Course
  • 1.Update expansion board firmware
  • 2.Install Python driver library
  • 3.Set the car type
  • 4.Open and close APP program control
  • 5.Turn hotspot mode on and off
  • 6.Buzzer sound
  • 7.Control the motor to rotate forward and reverse
  • 8.Controlling robot movement
  • 9.OLED display
  • 10.Control fans and lighting effects
06. Development Environment
  • 1. Virtual machine installation and use
  • 2. Linux Basics
  • 3. Remote connection
  • 4. Multi-machine communication configuration
  • 5. Bind device ID
  • 6. Image installation and backup
07. ROS2 Basic Course
  • 1. Introduction to ROS2
  • 2. ROS2 install Humble
  • 3. ROS2 development environment
  • 4. ROS2 workspace
  • 5. ROS2 function package
  • 6. ROS2 node
  • 7. ROS2 topic communication
  • 8. ROS2 service communication
  • 9. ROS2 action communication
  • 10. ROS2 custom interface message
  • 11. ROS2 parameter service case
  • 12. ROS2 meta-function package
  • 13. ROS2 distributed communication
  • 14. ROS2 DDS
  • 15. ROS2 time related API
  • 16. ROS2 common command tools
  • 17. ROS2 rviz2 use
  • 18. ROS2 rqt toolbox
  • 19. ROS2 Launch startup file configuration
  • 20. ROS2 recording and playback tool
  • 21. ROS2 URDF model
  • 22. ROS2 Gazebo simulation platform
  • 23. ROS2 TF2 coordinate transformation
08. Robot Chassis Control Course
  • 1. PID algorithm theory
  • 2. Robot information release
  • 3. Robot control
  • 4. Robot state estimation
  • 5. Robot calibration
  • 6. Robot trajectory tracking
  • 7. URDF Model
09. LiDAR Course
  • 1. Introduction and use of lidar
  • 2. Lidar obstacle avoidance
  • 3. Lidar tracking
  • 4. Lidar guard
  • 5. Lidar patrol
  • 6. gmapping mapping algorithm
  • 7. Cartographer mapping algorithm
  • 8. Navigation and obstacle avoidance
  • 9. App Mapping and Navigation
10. OpenCV Course
  • 1. Getting started with OpenCV
  • 2. OpenCV geometric transformation
  • 3. OpenCV Image Processing
  • 4. OpenCV image beautification
  • 5. QR code creation and recognition
11. Mipi Camera Course
  • 1. Camera driver
  • 2. Adjust the color HSV value
  • 3. Color recognition
  • 4. Color Tracking
  • 5. Color Follow
  • 6. QR code instructions
  • 7. Face Detection
  • 8. Object Detection
  • 9. Visual line patrol-OpenCV
  • 10. Visual line patrol-deep learning
  • 11. Human body tracking
  • 12. Gesture control
12. Depth Camera Course
  • 1. Use of Depth Camera
  • 2. Camera intrinsic calibration
  • 3. ROS+OpenCV Basics
  • 4. AR Vision
  • 5. Color Tracking
  • 6. Object Tracking
  • 7. RTAB-Map 3D Mapping Navigation
13. Multi-robot Synchronous Control
  • Multi-vehicle synchronous control
Remote login control
  • 1. VNC and SSH remote login
  • 2. Jupyter lab login and case code running
Download
  • System_File
  • Code
  • VM_File
  • Software_Tools
  • Hardware_Info
  • Firmware
  • Instruction_Manual
  • ROS2_Basic_VM
Download ZIP

Welcome to RDK X5 Robot repository

5. Robot calibration

5. Robot calibration

5. Robot calibration5.1. Program function description5.2, Program code reference path5.3, Program startup5.4, Core source code analysis

5.1. Program function description

After the program is running, adjust the parameters here to calibrate the linear speed and angular speed of the robot through the dynamic parameter regulator. The intuitive manifestation of calibrating the linear speed is to let the robot go forward 1 meter to see how far it actually runs and whether it is within the error range; the intuitive manifestation of calibrating the angular speed is to let the robot rotate 360 degrees to see whether the angle of rotation of the robot is within the error range.

5.2, Program code reference path

After SSH connects to the car, the location of the function source code is,

x
#Calibrate linear speed source code
/home/sunrise/yahboomcar_ws/src/yahboomcar_bringup/yahboomcar_bringup/calibrate_linear.py
#Calibrate angular speed source code
/home/sunrise/yahboomcar_ws/src/yahboomcar_bringup/yahboomcar_bringup/calibrate_angular.py

5.3, Program startup

After SSH connects to the car, enter in the terminal,

xxxxxxxxxx
#Start chassis
ros2 launch yahboomcar_bringup yahboomcar_bringup_launch.py
#Calibrate linear speed
ros2 run yahboomcar_bringup calibrate_linear
#Calibrate angular speed
ros2 run yahboomcar_bringup calibrate_angular

Open the virtual machine terminal and enter,

xxxxxxxxxx
#Dynamic parameter adjustment
ros2 run rqt_reconfigure rqt_reconfigure

1684481464371

Take the calibration of linear speed as an example, click [start_test] to calibrate the linear speed of the car in the x direction, and observe whether the car moves the test_distance distance. The default setting here is 1m. You can customize the test distance before calibration. It must be a decimal. After setting, click the blank space and the program will automatically write it. If the distance moved by the car exceeds the acceptable error range (the value of the tolerance variable), then set the value of odom_linear_scale_correction. The following are the meanings of each parameter.

ParameterMeaning
rateRelease frequency (can be left unchanged)
test_distanceTest distance of linear speed
speedLinear speed
toleranceAcceptable error value
odom_linear_scale_correctionScale factor
start_testStart test
directionDirection (Linear speed test X(1)Y(0) direction)
base_frameParent coordinates of TF transformation
odom_frameChild coordinates of TF transformation

The variable settings for testing angular velocity are roughly the same, except that test_distance becomes test_angle test angle and speed becomes angular velocity.

5.4, Core source code analysis

This program is mainly implemented by using TF to monitor the transformation between coordinates. By monitoring the coordinate transformation between base_footprint and odom, the robot knows "how far I have walked now/how many degrees I have turned now".

Taking calibrate_linear.py as an example, the core code is as follows,

xxxxxxxxxx
#Listen to TF transformation
def get_position(self):
try:
now = rclpy.time.Time()
trans = self.tf_buffer.lookup_transform(self.odom_frame,self.base_frame,now)
return trans
except (LookupException, ConnectivityException, ExtrapolationException):
self.get_logger().info('transform not ready')
raise
return

#Get the current xy coordinates and calculate the distance based on the previous xy coordinates
self.position.x = self.get_position().transform.translation.x
self.position.y = self.get_position().transform.translation.y
print("self.position.x: ",self.position.x)
print("self.position.y: ",self.position.y)
distance = sqrt(pow((self.position.x - self.x_start), 2) +
pow((self.position.y - self.y_start), 2))
distance *= self.odom_linear_scale_correction

The core code of calibrate_angular.py is as follows,

xxxxxxxxxx
#Here, TF transformation is also monitored to obtain the current posture information, but here a conversion is also made, the quaternion is converted to Euler angle, and then returned
def get_odom_angle(self):
try:
now = rclpy.time.Time()
rot = self.tf_buffer.lookup_transform(self.odom_frame,self.base_frame,now)
print("orig_rot: ",rot.transform.rotation)
cacl_rot = PyKDL.Rotation.Quaternion(rot.transform.rotation.x, rot.transform.rotation.y, rot.transform.rotation.z, rot.transform.rotation.w)
#print("cacl_rot: ",cacl_rot) angle_rot = cacl_rot.GetRPY()[2] #print("angle_rot: ",angle_rot) return angle_rot except (LookupException, ConnectivityException, ExtrapolationException): self.get_logger().info('transform not ready') raise return #Calculate rotation angle self.odom_angle = self.get_odom_angle() self.delta_angle = self.odom_angular_scale_correction * self.normalize_angle(self.odom_angle - self.first_angle)

The published TF transformation is published in the base_node node, and the code path is,

x
/home/sunrise/yahboomcar_ws/src/yahboomcar_base_node/src/base_node.cpp

This node will receive the data of /vel_raw, publish the odom data through mathematical calculations, and publish the TF transformation at the same time. The core code is as follows,

xxxxxxxxxx
#Calculate the values of xy coordinates and xyzw quaternion. The xy coordinates represent the position, and the xyzw quaternion represents the posture
double delta_heading = angular_velocity_z_ * vel_dt_; //radians
double delta_x = (linear_velocity_x_ * cos(heading_)-linear_velocity_y_*sin(heading_)) * vel_dt_; //m
double delta_y = (linear_velocity_x_ * sin(heading_)+linear_velocity_y_*cos(heading_)) * vel_dt_; //m x_pos_ += delta_x; y_pos_ += delta_y; heading_ += delta_heading; tf2::Quaternion myQuaternion; geometry_msgs::msg::Quaternion odom_quat; myQuaternion.setRPY(0.00,0.00,heading_ ); #Publish TF transformation geometry_msgs::msg::TransformStamped t; rclcpp::Time now = this->get_clock()->now(); t.header.stamp = now; t.header.frame_id = "odom"; t.child_frame_id = "base_footprint"; t.transform.translation.x = x_pos_; t.transform.translation.y = y_pos_; t.transform.translation.z = 0.0; t.transform.rotation.x = myQuaternion.x(); t.transform.rotation.y = myQuaternion.y(); t.transform.rotation.z = myQuaternion.z(); t.transform.rotation.w = myQuaternion.w(); tf_broadcaster_->sendTransform(t); ```
Robot state estimation
Robot trajectory tracking

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文