3、Keyboard control

Function package path:~/transbot_ws/src/transbot_ctrl

Input following command to start up:

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 feature pack can be installed directly into the system.

KeyCar[linear,angular]KeyCar[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】
KeySpeed changeKeySpeed change
【q】Linear velocity and angular velocity are both increased by 10%【z】linear velocity and angular velocity are both reduced by 10%
【w】Only the linear velocity increased by 10%【x】Only the linear velocity reduced by 10%
【e】Only the angular velocity increased by 10%【c】Only the angular velocity reduced by 10%

Except for the above keys, any key stops the movement. 【Ctrl】+【c】Exit.

image-20210904164510919

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: The key control method is the same as above

Input following command to start up

Code analysis

Mainly use select module, termios module and tty module

-The select module is mainly used for socket communication. -The termios module provides an IO-controlled POSIX call interface for tty -The tty module is mainly used to change the mode of the file descriptor fd

Get current key information

Get speed limit

Control flow