JETANK AI Kit-Gamepad Control

From Waveshare Wiki
Jump to: navigation, search

Gamepad Control

This tutorial will identify the different colors by getting the HSV value of a block of pixels in the screen by the camera.

  • Type in the address bar of your browser http://<jetbot_ip_address>:8888, connect to the cart and open /Notebooks/JETANK_6_gamepadCtrl/ on the left side. Open the file JETANK_6_gamepadCtrl.ipynb. The program provides Chinese and English versions, where the CN suffix is a Chinese comment and EN is an English comment.
  • Similarly, the program first initializes the camera and creates a widget to display the camera screen.

JETANK AI Kit Manual 26.png

  • Initialize the cart chassis and servo.

JETANK AI Kit Manual 27.png

  • Some parameters for the operation of the robot arm are defined here. It is recommended not to modify them unless necessary, and the modification may lead to unpredictable movements of the robot arm.

JETANK AI Kit Manual 28.png

  • The code here defines a number of different action motion functions.

JETANK AI Kit Manual 29.png

  • Here starts the gamepad control code that detects the gamepad device and then displays it, and defines some key values.

JETANK AI Kit Manual 30.png

  • A message like this will be displayed after the program runs normally. The note has been added to the handle button description, you can try to control JETANK movement by pressing different buttons.

JETANK AI Kit Manual 33.png

  • Note: This tutorial requires the gamepad receiver to be plugged into the Jetson Nano. Instead of plugging it into the computer side as in tutorial 4 Remote Control. And you need to plug the receiver into the jetson nano before starting the system, after starting the system and then inserting the receiver may cause the Docker container can not detect the device.
  • You can run the following command in jupyterLab's Terminal to see if the gamepad is recognized.

[Note] This is a Docker container operation, you must use the terminal operation in Jupyterlab.

ls /dev/input

JETANK AI Kit Manual 31.png

  • Where js0 is the representative game joystick handle, enter the following command to test whether the device works properly:
sudo jstest /dev/input/js0

The corresponding key value will change when different keys are pressed by the remote control handle.
JETANK AI Kit Manual 32.png
It also shows the key values of the different keys. If you don't use our handle grip, you may need to modify the program to change the actual key value of the key.