Robot handle 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.

1、Program function description

The car is connected to the agent, the receiver of the handle is connected to the virtual machine port/Raspberry Pi 2 port, and the program is run, and the car movement, buzzer and gimbal servo can be controlled remotely.

2、Start and connect to the agent

Taking the supporting virtual machine as an example, enter the following command to start the agent:

image-20240102115334500

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.

image-20231220112211061

3、starting program

To connect the virtual machine to the controller receiver, you need to ensure that the virtual machine can recognize the controller receiver. As shown in the figure below, the connection is successful.

image-20231220112453720

If it is not connected, check [Virtual Machine]->[Removable Devices] in the menu bar above the virtual machine toolbar and check whether [DragonRise Controller] is checked.

Enter the following command in the terminal to start the program.

image-20231220113745011

The remote control button description is as follows:

4、Node communication diagram

Terminal input,

image-20231220115844075

If it is not displayed at first, select [Nodes/Topics(all)], and then click the refresh button in the upper left corner.

5、Code analysis

Source code reference path (already equipped with a virtual machine as an example),

yahboom_joy.py

6、Variables corresponding to remote control key values

Based on the default mode [Controller], the key values corresponding to the remote control are as follows:

remote control eventCorresponding variable
Left joystick upaxes[1]=1
Left joystick downaxes[1]=-1
Right joystick to leftaxes[2]=1
Right joystick to the rightaxes[2]=-1
Button X pressedbutton[3]=1
Button B pressedbutton[1]=1
Button Y pressedbutton[4]=1
Button R1 pressedbutton[7]=1
start button pressedbutton[11]=1
Left joystick pressedbutton[13]=1
Right joystick pressedbutton[14]=1

Combined with the above source code for easy understanding, when these values change, it means that the remote control is pressed and the corresponding program can be executed. View other button presses, subscribe to/joy topics, terminal input,

image-20231220141805260