UGV Beast Jetson Orin ROS2 3. Use Joystick or Keyboard Control

From Waveshare Wiki
Jump to: navigation, search
UGV Beast Jetson Orin ROS2
360px-UGV Beast PT Jetson ROS2 Kit.jpg

I2C, UART
TTL Serial Bus Servo Control Interface
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

3. Use Joystick or Keyboard Control

This section describes how to control movement using a joystick or keyboard keys. The product comes with an Xbox Bluetooth controller when shipped from the factory. By default, you have completed the main program and remotely connected to the Docker container according to the content in Chapter 1 UGV Beast Jetson Orin ROS2 1. Preparation.


3.1 Chassis drive

Before you can run the joystick control and keyboard control demos, you must first run the chassis drive node. In the previous section, we introduced the operation of one ROS2 robot drive node, and here we introduce the operation of another chassis drive node.

In the container, go to the workspace of the ROS 2 project for that product:

cd /home/ws/ugv_ws

Start the robot driver node:

ros2 launch ugv_bringup bringup_lidar.launch.py use_rviz:=true

At this moment, the robot pan-tilt will be turned to the center position, and the camera will face forward, and you can view the RVIZ2 model interface of the product. When the robot rotates in place, you can see that the model will also rotate with the robot.

Beast rviz3.png

Note: If the UGV Beast tracked chassis is not displayed in the model interface, you need to press Ctrl+C to turn off the running robot drive node first. Next, switch the UGV model in the ROS 2 project to the UGV Beast, enter the following command to switch the model, and then start the robot drive node.

export UGV_MODEL=ugv_beast
source ~/.bashrc

3.2 Joystick control

Start the robot driver node and connect the joystick receiver to the Jetson Orin Nano.

Once plugged in, you'll need to run the joystick control node on a new Docker container terminal first. Open a new Docker container terminal, click the ⭐ symbol in the left sidebar, double-click to open Docker's remote terminal, enter username: root, password: jetson.

ROS2 newDocker.png

In the container, first run the following command to check whether the joystick is recognized, as shown in the figure:

ls /dev/input

ROS2 xboxls.png

js0 represents the joystick here.

In the container, go to the workspace of the ROS 2 project for that product:

cd /home/ws/ugv_ws

Run the joystick control node:

ros2 launch ugv_tools teleop_twist_joy.launch.py

Then turn on the switch on the back of the joystick, and you can control the movement of the robot when you see the red light on the joystick. Note: There are three function keys on the joystick: the key below R is used to lock or unlock, the left joystick -- forward or backward, the right joystick -- turn left or right.

You can close the joystick control node by pressing Ctrl+C.


3.3 Keyboard control

Close the joystick control node, and then run the joystick control node in the terminal window to run keyboard control node:

ros2 run ugv_tools keyboard_ctrl

Keep this window active (that is, make sure you are in the terminal window interface when operating the keys), and control the movement of the robot through the following keys:

keyboard key Operation description keyboard key Operation description keyboard key Operation description
Letter U Left forward Letter I Straight ahead Letter O Right forward
Letter J Turn left Letter K Stop Letter L Turn right
Letter M Left backward Symbol , Straight backward Symbol . Right backward

You can close the keyboard control node by pressing Ctrl+C.