9.2 Keyboard control of ROS robot

1. Install teleop_twist_keyboard

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. If you use the official image of jetbot-mini, you can skip this step.

2. start up

3. control method

*Note: The initial speed is 0, you need to press [u] or [j] to accelerate

keyCarkeySpeed change
【w】Advance【u】Left wheel speed increase10%
【a】Turn left【i】Left wheel speed reduction10%
【s】Back【j】Right wheel speed increase10%
【d】Turn right【k】Right wheel speed reduction10%

4. 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

Control flow

Code path:/home/jetson/workspace/catkin_ws/src/jetbot_ros/scripts/jetbotmini_keyboard.py