Gamepad Control

From Waveshare Wiki
Jump to: navigation, search

JetBot User Guide

Step 1: Open Teleoperation Program

  • Use Google or Firefox browser to log in to the website http://<jetbot_ip_address>:8888 to connect to the car [jetbot_ip_address is the ip displayed by the car, be careful to remove "<>"], open the folder on the left to "jetbot/notebooks/teleoperation/teleoperation" .ipynb” file
  • Plug the gamepad receiver into the USB port of the computer. [Note] The receiver needs to be connected to the computer instead of the jetson nano. The gamepad needs to be connected to the device that opens the JupyterLab webpage.
  • Open the https://html5gamepad.com/ webpage, check whether the controller is connected properly, and write down the INDEX value of the corresponding device; at this time, press the remote control and the corresponding value on the webpage will change accordingly.

Gamepad Control01.png

  • Note: INDEX=0 is a normal value, if the connection fails, it will display: No gamepad detected.
  • Back in the demo, please odify the index to the actual value of the gamepad. Then determine the actual corresponding value of each button by pressing the button, and then you can set the function of the handle button by yourself.

Gamepad Control02.png

  • Tip: axes represent sliders, buttons represent squares.
  • After clarifying the actual values corresponding to different keys, we can write a program to set the key functions by ourselves. For example, the X key represents buttons[3], the B key represents buttons[1], the Y key represents buttons[0], and the A key represents buttons[2], and the corresponding key value is assigned to the motor to control the car to move forward, back, left and right.

Gamepad Control03.png

Step 2: Open the Camera

  • Create an image window in the program with the format of jpeg, a resolution of 300 X 300, and display it on the current page.

Gamepad Control04.png

  • If there is an error, please check whether you have enabled the RPI camera interface.
  • Quote the camera functions to call the camera. The image is outputted after running the program.

Gamepad Control 05.jpg

  • When the "heartbeat" checks, the car will stop as soon as the network is failed.

Gamepad Control 06.png

  • Control the car to take photos with buttons. You can choose the different buttons by changing it. Here we use buttons[0].

Gamepad Control 07.jpg

  • After running the program, you can control the car by the gamepad. Asex[0] is for the wheels on the left, Asex[1] is for the wheel on the right, and button[0] is the control for taking pictures. The image on the left shows the real-time image of the camera, the image on the right is the captured image, and the image is saved in the snapshots file.