yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
RDK X3 Robot📖
01. About RDK-X3-Robot
1. Instructions
  • 1. Introduction
  • 2. FAQ
  • 3. Battery and charger use precautions
  • 4.TF card expand capacity
2. Common problem analysis
02. Assembly video
  • Part1-Install Motor
  • Part2-Install Battert Fixing Column
  • Part3-Install Motor Coupling
  • Part4-Install Mecanum wheel
  • Part5-Install Expansion Board
  • Part6-Wiring Show
  • Part7-Install Main Control Board
  • Part8-Install Car Top Plate and Antenna
  • Part9-Install OLED Screen
  • Part10-Install Depth Camera(Optional)
  • Part11-Install OLED Screen
  • Part12-Install HD Camera
  • Part13-Install Top Plate
  • Part14-Install Right Side Plate
  • Part15-Motor Wiring Show
  • Part16-lnstall Car Body
  • Part17-Install Battery
  • Part18-Install Lidar
03. Remote control tutorial
  • 1. The phone APP remote tutorial
  • 2. USB wireless controller remote tutorial
04. ROS functional tutorial
  • 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 tutorial
  • 1. Update the firmware of the expansion module
  • 2. Install the Python driver library
  • 3. Set the type of bottom car
  • 4. Open and close the APP program control
  • 5. Turn hotspot mode on and off
  • 6. The buzzer blows
  • 7. Control the motor forward and reverse
  • 8. Control robot movement
  • 9. OLED display
  • 10. Control fan and lamp effect
06. Development environment setup
  • 1. Virtual Machine
  • 2. Linux Basics
  • 3. Remote connection
  • 4. Multi-computer communication configuration
  • 5. Bind the 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
  • 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 courses
  • 1. Introduction and use of lidar
  • 2. Lidar obstacle avoidance
  • 3. Lidar following
  • 4. Lidar guard
  • 5. Patrol
  • 6. gmapping algorithm
  • 7. cartographer algorithm
  • 8. Navigation and obstacle avoidance
  • 9. App mapping and navigation
10. OpenCV courses
  • 1. Introduction to OpenCV
  • 2. OpenCV geometric transformation
  • 3. OpenCV image processing
  • 4. OpenCV image beautification
  • 5. Qr code creation and identification
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 command
  • 7. Face detection
  • 8. Object detection
  • 9. Visual Inspection -OpenCV
  • 10. Visual inspection - Deep learning
  • 11. Human tracking
  • 12. Gesture control
12. Depth Camera courses
  • 1. Use depth camera
  • 2. Calibration of camera internal reference
  • 3. ROS+OpenCV Foundation
  • 4. AR vision
  • 5. Color tracking
  • 6. Object tracking
13. Multi vehicle control
  • 1. Multi-vehicle synchronous control
  • 2. Multi-vehicle navigation
Remote login control
  • 1. VNC and SSH remote login
  • 2. Jupyter lab login and case code running
Download
  • RemoteCtrl_APP(iOS/Android))
  • Mapping_APP(iOS_Android)
  • Code
  • System File
  • VM_File
  • Manual
  • Software_File
  • Hardware_File
  • ROS2_Basic_VM
Download ZIP

Welcome to RDK X3 Robot repository

3. Robot control

3. Robot information release

3. Robot information release3.1 Description of program function3.2 Application Code reference path3.3. Program start3.3.1. Handles3.3.2. Keyboard controls3.3.3 Node Communication3.4. Core Source Code Parsing3.4.1. Handles control code3.4.2. Keyboard control code

 

3.1 Description of program function

Open the chassis, run the handle/keyboard control program, you can control the car movement through the handle or keyboard, the handle also control the buzzer, control the light belt and other functions.

3.2 Application Code reference path

After SSH is connected to the car, the position of the handle control function source code is located at,

xxxxxxxxxx
/userdata/yahboomcar_ws/src/yahboomcar_ctrl/yahboomcar_ctrl/yahboom_joy.py

After SSH is connected to the car, the location of the keyboard control function source code is located at,

xxxxxxxxxx
/userdata/yahboomcar_ws/src/yahboomcar_ctrl/yahboomcar_ctrl/yahboom_keyboard.py

3.3. Program start

xxxxxxxxxx
#启动底盘# Start chassis
ros2 run yahboomcar_bringup Mcnamu_driver
​
#手柄控制
#启动launch文件
# Handle control
# launch file
ros2 launch yahboomcar_ctrl yahboomcar_joy_launch.py
#或单独启动两个节点# or start two nodes separately
ros2 run yahboomcar_ctrl yahboom_joy
ros2 run joy joy_node
​
#键盘控制# Keyboard control
ros2 run yahboomcar_ctrl yahboom_keyboard

It should be noted here that the gamepad and the keyboard cannot run at the same time, because after the keyboard control is started, when the keyboard is not pressed, the default is to send a message of 0 data speed.

3.3.1. Handles

After opening, press the [START] button, hear the buzzer sound, you can start the remote control.The remote control will enter hibernation mode after being turned on for a period of time. You need to press [START] button to end hibernation 。If you want to control the car running , you also need to press the [L1] key , lift the motion control lock ,you can use the rocker to control the car moving.

Remote control effect description,

GamepadEffect
left rocker up/downGo forward/backward straight
left rocker left/rightleft/right go straight
Right rocker left/rightRotate left/select right
【L1】keyUnlocks motion control
【R1】 keyto control the lighting effect
【START】 keyto control the buzzer/end sleep
left rocker pressX/Y axis adjustment speed
Right rocker pressto adjust the angular speed

3.3.2. Keyboard controls

Button description,

  • Direction control

    【i】or【I】【 linear,0】【u】 or【U】【linear,angular】
    【,】【-linear,0】【o】 or【O】【linear,- angular】
    【j】or【J】【0, angular】【m】or【M】【- linear,- angular】
    【l】or【L】【0,- angular】【.】【 - linear,angular】
  • Speed control

    buttonspeed changebuttonspeed change
    【q】both linear velocity and angular velocity are increased by 10%【z】both linear velocity and angular velocity are decreased by 10%
    【w】only linear speed increased by 10%【x】only linear speed decreased by 10%
    【e】the angular velocity is increased by 10% only【c】the angular velocity is decreased by 10% only
    【t】line speed X axis /Y axis direction change【s】stop keyboard control

3.3.3 Node Communication

Handle control car node communication diagram,

image-20230419160537647

Keyboard control car node communication diagram,

image-20230419160740283

3.4. Core Source Code Parsing

3.4.1. Handles control code

As we mentioned in the last lesson, the chassis control program, Mcnamu_driver.py, defines three subscribers: speed (/cmd_vel), light effect (/RGBLight), and Buzzer (/ buzzer), so, We control the controller code program yahboom_joy.py to control the speed, light effect and buzzer as long as the type of topic data is posted.

xxxxxxxxxx
#create pub
self.pub_cmdVel = self.create_publisher(Twist,"cmd_vel",  10)
self.pub_Buzzer = self.create_publisher(Bool,"Buzzer",  1)
self.pub_RGBLight = self.create_publisher(Int32,"RGBLight" , 1)
self.pub_JoyState = self.create_publisher(Bool,"JoyState",  10)

In addition, we need to subscribe to the "joy" topic data, which tells us which key values (joysticks and keys) have changed, that is,

xxxxxxxxxx
#create sub
self.sub_Joy = self.create_subscription(Joy,'joy', self.buttonCallback,1)

The main thing to look at is the joy topic callback function, which parses the received value, then assigns it to the publisher's variable, and finally publishes it.

xxxxxxxxxx
def buttonCallback(self,joy_data):
    if not isinstance(joy_data, Joy): return
    if self.user_name == "root": self.user_sunrise(joy_data)
    else: self.user_pc(joy_data)

Here the function jumps to self.user_sunrise, and the argument variable passed in is the received topic,

xxxxxxxxxx
def user_sunrise(self, joy_data):

Take control buzzer as an example to analyze,

xxxxxxxxxx
if joy_data.buttons[7] == 1:
    Buzzer_ctrl = Bool() 
    self.Buzzer_active = not self.Buzzer_active
    Buzzer_ctrl.data = self.Buzzer_active
    for i in range(3): self.pub_Buzzer.publish(Buzzer_ctrl)

If joy_data.buttons[7] == 1 If [START] is pressed, then the buzzer value will change and publish self.pub_Buzzer.publish(Buzzer_ctrl). Other analogies, the principle is the same, are assigned by ** detection of the change in the key value **. See yahboom_joy.py for details.

3.4.2. Keyboard control code

The keyboard control can only control the motion control of the car, not the lights and buzzers, so there is only one /cmd_vel speed publisher,

xxxxxxxxxx
self.pub = self.create_publisher(Twist,'cmd_vel',1)

The program also defines two dictionaries to detect changes in keyboard letters when pressed,

xxxxxxxxxx
moveBindings = {
    'i': (1, 0),
    'o': (1, -1),
    'j': (0, 1),
    'l': (0, -1),
    'u': (1, 1),
    ',': (-1, 0),
    '.': (-1, 1),
    'm': (-1, -1),
    'I': (1, 0),
    'O': (1, -1),
    'J': (0, 1),
    'L': (0, -1),
    'U': (1, 1),
    'M': (-1, -1),
}
​
speedBindings = {
    'Q': (1.1, 1.1),
    'Z': (.9, .9),
    'W': (1.1, 1),
    'X': (.9, 1),
    'E': (1, 1.1),
    'C': (1, .9),
    'q': (1.1, 1.1),
    'z': (.9, .9),
    'w': (1.1, 1),
    'x': (.9, 1),
    'e': (1, 1.1),
    'c': (1, .9),
}

Entering the while loop, the program reads the value of the keyboard press and makes a layer by layer judgment,

xxxxxxxxxx
key = yahboom_keyboard.getKey()
if key=="t" or key == "T": xspeed_switch = not xspeed_switch
elif key == "s" or key == "S":
...
if key in moveBindings.keys():
...
elif key in speedBindings.keys():
...

Finally, according to the judgment of the multiple layers, the values are assigned to twist.linear.x, twist.linear.y, twist.angular.z and then published.

xxxxxxxxxx
if xspeed_switch: twist.linear.x = speed * x
else: twist.linear.y = speed * x
twist.angular.z = turn * th
if not stop: yahboom_keyboard.pub.publish(twist)
if stop:yahboom_keyboard.pub.publish(Twist())

See yahboom_keykey.py for details.

Robot information release
Robot state estimation

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/中文