3. Keyboard control

Function package path: ~/transbot_ws/src/transbot_ctrl

Start low-level control

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

 

3.1, teleop_twist_keyboard.py

Wiki: http://wiki.ros.org/teleop_twist_keyboard

Source code: https://github.com/ros-teleop/teleop_twist_keyboard

This function package can be installed directly into the system. The factory image of the car has been installed, no need to reinstall it

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.

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.

ButtonCar [linear, angular]ButtonCar [linear, angular]
[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]
ButtonSpeed changeButtonSpeed change
[q]Linear speed and angular speed are both increased by 10%[z]Linear speed and angular speed are both reduced by 10%
[w]Only the linear speed increases by 10%[x]Only the linear speed decreases by 10%
[e]Only the angular velocity increases by 10%[c]Only the angular velocity decreases by 10%

In addition to the above keys, any key stops movement. [Ctrl]+[c] to exit.

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.

The node [teleop_twist_keyboard] publishes a message to the topic [/cmd_vel] and is subscribed by the node [/transbot_node].

3.2, transbot_keyboard.py

Note: Button control method is the same as above

Start mode

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.

Code analysis

Mainly used select module, termios module and tty module

Get current key information

Get speed limit

control flow