Welcome to MicroROS Self-balancing Robot Car repository
2.Handle remote control
Handle remote control
Note: The virtual machine needs to be in the same LAN as the car, and the ROS_DOMAIN_ID needs to be consistent. You can check [Must-read before use] to set the IP and ROS_DOMAIN_ID on the board.
Here, we take the [PS2-2.4G wireless controller] sold by Yabo Intelligent Technology Co., Ltd. as an example to explain how to quickly start the program and control the car. The code here is only applicable to the above-mentioned controllers, not other controllers.
1. Start and connect the agent
Take the matching virtual machine as an example, enter the following command to start the agent,
xxxxxxxxxxsudo docker run -it --rm -v /dev:/dev -v /dev/shm:/dev/shm --privileged --net=host microros/micro-ros-agent:humble udp4 --port 8899 -v4 
Then, turn on the car switch and wait for the car to connect to the agent. The connection is successful as shown in the figure below,

Then, connect the receiver of the handle to the host of the virtual machine and choose to connect to the virtual machine.
2. Start the handle control program
2.1 Code path
Virtual machine code path:
xxxxxxxxxx/home/yahboom/yahboomcar_ws/src/yahboomcar_ctrl/yahboomcar_ctrl
2.2 Run command
Take the matching virtual machine as an example, input in the terminal,
Start the chassis driver,
xxxxxxxxxxros2 launch yahboomcar_bringup yahboomcar_bringup_launch.pyOpen another terminal and input,
xxxxxxxxxxros2 launch yahboomcar_ctrl yahboomcar_joy_launch.py
Observe the handle indicator light, if it is always on, it means the connection is successful. After the program starts, press [START] and the buzzer of the car will sound. Press the R1 key, and the terminal prints the following information, turning on the handle control. You can use the left joystick to control the car forward and backward; you can use the right joystick to control the car to turn left and right;
[yahboom_joy-2] [INFO] [1735197789.731509428] [joy_ctrl]: Play:true