this is a ros2 teleop package similar to the normal teleop packge but using arrow keys to drive your robot in a fun way. it uses the pynput python library. it publishes Twist or TwistStamped Messages on /cmd_vel_teleop topic
ensure the following are installed on your PC before you start cloning and using the package
-
pynput python library for keyboard interfacing
sudo apt install python3-pynput
-
clone (recommended) or Download the repo or in the src folder of your preferred ROS2 workspace.
git clone https://github.com/samuko-things/arrow_key_teleop_drive.git
-
To build the arrow_key_teleop_drive package, go to the root folder of your ros2 workspace and run the following command below. (DON'T FORGET TO SOURCE YOUR WORKSPACE)
colcon build --packages-select arrow_key_teleop_drive --symlink-install
NOTE that the package publishes to the /cmd_vel topic. It requires you to set the linear velocity (v) and angular velocity (w), you want your robot to move at, as argument to run the package. Below is an example of how to run the package to drive your robot.
ros2 run arrow_key_teleop_drive arrow_key_teleop_drive <v in m/s> <w in rad/sec> <use_stamped_vel - true|false>-
sample publish stamped velocity (geomatry_msg/msg/TwistStamped)
ros2 run arrow_key_teleop_drive arrow_key_teleop_drive 0.2 0.5 trueOR (with remapping)
ros2 run arrow_key_teleop_drive arrow_key_teleop_drive 0.2 0.5 true --ros-args -r /cmd_vel_teleop:=/cmd_vel -
sample publish unstamped velocity (geomatry_msg/msg/Twist)
ros2 run arrow_key_teleop_drive arrow_key_teleop_drive 0.2 0.5 falseOR (with remapping)
ros2 run arrow_key_teleop_drive arrow_key_teleop_drive 0.2 0.5 false --ros-args -r /cmd_vel_teleop:=/cmd_vel
drive the robot easily using the arrow keys
This node takes arrow keypresses from the keyboard
and publishes TwistSTamped or Twist (velocicty comands)
messages to control your robot. It makes use of the
pynput keyboard python library
NOTE!: it runs when terminal is not in focus
-------------------------------------------------------
drive around with arrow keys:
[forward-left] [forward] [forward-right]
|
[rotate left] -------------- [rotate right]
|
[reverse-left] [reverse] [reverse-right]
stops when no arrow key is pressed
H - toggle Holonomic (Straffing) Mode
Q - quit (ctrl C)
--------------------------------------------------------
- using ros2 params
- adding speed control (increment and decrement)
- adding speed ramping
- etc.