4.Handle control(Optional)

1. Operating environment

Operating system: Ubuntu 18.04 LTS

ROS version: melodic

Equipment: jetson nano, Raspberry Pi, PC, wireless controller (USB receiver)

Controller control function package path: ~/transbot_ws/src/transbot_ctrl

2. Install the driver

ROS driver for universal Linux controllers. The Joy package contains Joy_node, a node that connects a generic Linux controller to ROS. This node publishes a "/Joy" message containing the current state of each button and axis of the controller. Note: The factory image of the car has already been installed, no need to reinstall it

3. Usage steps

First, connect the USB end of the wireless controller to the device (jetson nano, Raspberry Pi, PC). This lesson takes connecting the USB end of the wireless controller to the jetson nano as an example. Connect the mouse, keyboard, and monitor; or you can also connect remotely through VNC.

Open the terminal and enter the following command. [js0] is displayed. This is the wireless controller. In special cases, you can also view the changes in the device list through the two states of connecting and not connecting to the USB side of the wireless handle. If there is a change, the changed device will be the one; otherwise, the connection will be unsuccessful or cannot be recognized.

001

Open the terminal and enter the following command. As shown in the picture, the wireless handle has 8 axial inputs and 15 key inputs. You can press the keys individually to test the numbers corresponding to the keys.

002

If jstest is not installed, run the following command:

Open three terminals and enter the following commands in order to view detailed information, which is the same as [Test Controller]. Depending on the device (Raspberry Pi, Jetson Nano, PC) and the system, the controller status will be different.

jetson motherboard/Raspberry Pi 4B

Raspberry Pi 5

Before running, please confirm that the large program has been permanently closed

Enter docker

Note: If there is a terminal that automatically starts docker, or there is a docker terminal that has been opened, you can directly enter the docker terminal to run the command, and there is no need to manually start docker

Start docker manually

Enter the same docker from multiple terminals

Keep the program of the previous docker terminal running and open a new terminal

Enter the following command

Enter the same docker and use the following 18870bc3dc00 to modify the ID displayed on the actual terminal.

Enter the same docker from multiple terminals

Keep the program of the previous docker terminal running and open a new terminal

Enter the following command

Enter the same docker and use the following 18870bc3dc00 to modify the ID displayed on the actual terminal.

003

 

4. Control the little turtle with the handle

4.1. Start the little turtle

jetson motherboard/Raspberry Pi 4B

Raspberry Pi 5

Before running, please confirm that the large program has been permanently closed

Enter docker

Note: If there is a terminal that automatically starts docker, or there is a docker terminal that has been opened, you can directly enter the docker terminal to run the command, and there is no need to manually start docker

Start docker manually

Enter the same docker from multiple terminals

Keep the program of the previous docker terminal running and open a new terminal

Enter the following command

Enter the same docker and use the following 18870bc3dc00 to modify the ID displayed on the actual terminal.

If you want to drive the little turtle, you only need to give the little turtle a certain speed. Next, check out the ROS speed control node.

004

4.2. Node View

jetson motherboard/Raspberry Pi 4B

Raspberry Pi 5

Enter the same docker from multiple terminals

Keep the program of the previous docker terminal running and open a new terminal

Enter the following command

Enter the same docker and use the following 18870bc3dc00 to modify the ID displayed on the actual terminal.

4.3. View the node information

jetson motherboard/Raspberry Pi 4B

Raspberry Pi 5

Enter the same docker from multiple terminals

Keep the program of the previous docker terminal running and open a new terminal

Enter the following command

Enter the same docker and use the following 18870bc3dc00 to modify the ID displayed on the actual terminal.

If you want to control the movement of the little turtle, you only need to post a message to the topic [/turtle1/cmd_vel] with the type [geometry_msgs/Twist].

4.4. Control the little turtle with the handle

Receive the current status information of the handle, and send instructions to the little turtle by pressing the buttons or shaking the joystick to receive different information fed back by the wireless handle.

Start command

jetson motherboard/Raspberry Pi 4B

Raspberry Pi 5

Before running, please confirm that the large program has been permanently closed

Enter docker

Note: If there is a terminal that automatically starts docker, or there is a docker terminal that has been opened, you can directly enter the docker terminal to run the command, and there is no need to manually start docker

Start docker manually

 

006

At this time, you can use the handle to control the operation of the little turtle.

handlelittle turtle
On the left joystickForward
Left joystick downBackward
Right joystick leftTurn left
Right joystick rightTurn right

【/joy_node】:Node of controller information

【/turtlesim_joy】:Nodes controlled by the handle

【/turtlesim_node】:The node of the little turtle

The node [/joy_node] publishes the topic [/joy] so that the node [/turtlesim_joy] subscribes. After processing, it publishes the topic [/turtle1/cmd_vel] so that the node [/turtlesim_node] subscribes to drive the movement of the little turtle.

jetson motherboard/Raspberry Pi 4B

Raspberry Pi 5

Enter the same docker from multiple terminals

Keep the program of the previous docker terminal running and open a new terminal

Enter the following command

Enter the same docker and use the following 18870bc3dc00 to modify the ID displayed on the actual terminal.

007

5. Handle control Transbot SE

Controlling Transbot SE with a handle is similar to controlling a little turtle with a handle; let the handle control node establish contact with the underlying drive node of Transbot SE, change the current state of the handle, send different information to Transbot SE, and drive Transbot SE to make different reactions. What we need to control are the buzzer, pan/tilt, robotic arm, and car movement (linear speed, angular speed).

The topic requires continuous communication, but the service does not need continuous communication. The following settings are made according to the characteristics and business needs of the topic and service:

5.1. Handle control node

5.3. Operation process

008

Start command

jetson motherboard/Raspberry Pi 4B

Raspberry Pi 5

Before running, please confirm that the large program has been permanently closed

Enter docker

Note: If there is a terminal that automatically starts docker, or there is a docker terminal that has been opened, you can directly enter the docker terminal to run the command, and there is no need to manually start docker

Start docker manually

View node graph

jetson motherboard/Raspberry Pi 4B

Raspberry Pi 5

Enter the same docker from multiple terminals

Keep the program of the previous docker terminal running and open a new terminal

Enter the following command

Enter the same docker and use the following 18870bc3dc00 to modify the ID displayed on the actual terminal.

Only the connections between topics can be seen

View service list

jetson motherboard/Raspberry Pi 4B

Raspberry Pi 5

Enter the same docker from multiple terminals

Keep the program of the previous docker terminal running and open a new terminal

Enter the following command

Enter the same docker and use the following 18870bc3dc00 to modify the ID displayed on the actual terminal.

Print as follows:

5.4. Source code analysis

File path: ~/transbot_ws/src/transbot_bringup/launch/joy_bringup.launch

-py file

File path: ~/transbot_ws/src/transbot_ctrl/scripts/transbot_joy.py

Start the thread, obtain the currently connected camera device in the [self.analyse_PWM()] function, and start loop control of the gimbal servo and robotic arm.

Subscribe to the data published by the node [joy_node] and obtain the current status of the wireless controller. Different master controls are distinguished here.

5.5. Handle effect

212

5.6. Precautions when using the handle

Appendix

jetson nano

axes(8)

Code analysisHandle buttonCar control
axes[0]Left rocker 
axes[1]Left rockeradvance and back
axes[2]Right rockerleft and right
axes[3]Right rocker 
axes[4]  
axes[5]  
axes[6]Left buttonArm-1
axes[7]Left buttonArm-2

buttons(15)

Code analysisHandle buttonCar control
buttons[0]Acamera platform move down
buttons[1]Bcamera platform move right
buttons[2]  
buttons[3]Xcamera platform move left
buttons[4]Ycamera platform move up
buttons[5]  
buttons[6]L1Arm-clip close
buttons[7]R1running water light
buttons[8]L2Arm-clip open
buttons[9]R2control switch
buttons[10]SELECTsearch light on high frame rate camera
buttons[11]STARTbuzzer
buttons[12]  
buttons[13]Press left rockerLinear speed [ 0.15 , 0.3 , 0.45 ]
buttons[14]Press right rockerAngular speed [ 0.5 , 1 , 1.5 , 2 ]

Raspberry Pi

axes(8)

Code analysisHandle buttonCar control
axes[0]Left rocker 
axes[1]Left rockeradvance and back
axes[2]L2(press:-1,release:1)Arm clip
axes[3]Right rockerleft and right
axes[4]Right rocker 
axes[5]R2(press:-1,release:1)control switch
axes[6]Left buttonArm-1
axes[7]Left buttonArm-2

buttons(11)

Code analysisHandle buttonCar control
buttons[0]Acamera platform move down
buttons[1]Bcamera platform move right
buttons[2]Xcamera platform move left
buttons[3]Ycamera platform move up
buttons[4]L1Arm clip
buttons[5]R1running water light
buttons[6]SELECTsearch light on high frame rate camera
buttons[7]STARTbuzzer
buttons[8]MODE 
buttons[9]Press left rockerLinear speed [ 0.15 , 0.3 , 0.45 ]
buttons[10]Press right rockerAngular speed [ 0.5 , 1 , 1.5 , 2 ]