6.QR code instructions

1. Introduction

This course mainly uses the robot's camera to obtain the camera's picture, identify the QR code information, and control the robot's movement based on the QR code information.

 

2. Core content analysis

Initialize the hexapod robot and set the camera pan/tilt angle. The default is S1=90 and S2=30. The initial angle can be modified according to actual needs.

Import the QR code parsing library pybar

If pybar is not installed on your system, please open a terminal and run the following command to install it.

Analyze the grayscale image and extract the information and image position of the QR code in the image. If there is no QR code in the image, the information is None.

Control the robot movement according to the string command of info. Among them, g_time_pass is the time of command movement, which can be adjusted according to actual needs, and the unit is 100 milliseconds. By default, the robot will automatically stop after executing the command for 2 seconds.

Define a task_time task to stop the robot automatically and not execute other QR code instructions during the movement of the robot. g_time_pass is in units of 100 milliseconds. When g_time_pass is greater than 0, it automatically decreases by 1 every 100 milliseconds and stops automatically when timeout occurs.

 

3.Operation

Open the jupyterLab client and find the code path:

Click to run all cells, and then scroll to the bottom to see the generated controls.

image-20220810163917767

Click the Start button below to start identifying QR codes and execute instructions. The QR code that can be recognized in the current routine is QRCode. The information is "forward" for forward, "back" for backward, "left" for left translation, "right" for right translation, "turnleft" for left rotation, and "turnright" for Rotate right, "stop" means stop.

image-20230814194757789

Finally click the Close_Camera button to close the camera.

 

Appendix (QR code picture):

back

Crouching

forward

Greeting

left

Retreat

right

Say_no

stop

Stretch

Stride

Turn_around

turnleft

turnright

Warm_up