Tinybit Pro autopilot

1. Learning objectives

In this course, we mainly learn how to let Tiny:bit Pro complete the recognition of different road signs while using the line tracking sensor to track the line.

2.Preparation for class

  1. Remove the TF card from the k210 vision module and insert it into the card reader.

01

  1. Plug the card reader into the computer, and wait for the computer to recognize the USB disk.

02

  1. Then, enter the TF card. You will see following content.

03

  1. Go to the k210 folder, find the 3.12_Autopilot.py file and tinybit_AI.kmodel file from the folder and copy it to the root directory.

04

05

  1. Delete the original main.py file.

Then, re-name the 3.12_Autopilot.py file as the main file.

07

  1. After re-name, pull out the card reader, remove the TF card and insert it back into the k210 vision module.

3.Programming Methods

Online programming: first copy this URL https://makecode.microbit. and enter the online programming interface.

Click Extension, copy the package URL: https://github.com/YahboomTechnology/K210-Module.git to the input field, click Confirm to add package,

Click Extension again, copy the package URL: https://github.com/YahboomTechnology/Tiny-bitLib to the input field, click Confirm to add the package.

Finally you can use the K210 Vision Module package and Tinybit's building blocks.

4.Blocks

08

10

11

12

13

5. Some important source code analysis

5.1 Open the source code

This tutorial only shows a small part of the source code, not all the source code. If you want to see all the source code of this tutorial, first open the makecode offline software or an online programming website. Take the online programming website as an example.

 

 

5.2 Partial source code analysis

 

Function Analysis

The flow chart of this program, as shown below 17

 

6. Download code

Connect the Micro:bit board to the computer via microusb cable, the computer will pop up a USB stick.

Then, select the k210_Autopilot.hex code and right click to send it to the Micro:bit U disk.

Wait until sending is complete and unplug the Micro:bit usb cable. Plug the Micro:bit board into the car.

7.Experimental phenomena

After starting the car, the car will move forward along the black line on the map. When the camera recognizes the road sign, the corresponding path planning movement will appear.

  1. When the speed limit sign is recognized, the car will follow the line at a speed that does not exceed the speed limit sign.

25

  1. When the speed limit sign is recognized, the car will return to the normal line patrol movement.

19

  1. When a turn left/right sign is recognized, the car will make a priority turn left/right tracking movement.

20

22

  1. When the honk is recognized, the car will whistle.

21

  1. Recognize traffic lights, red lights will stop, green lights will continue to move forward.

23

  1. Recognize parking No. 1 and parking No. 2.

    When car recognizes parking No. 1, it will enter parking No. 1;

    When car recognizes parking No. 2, it will enter parking No. 2; after 2 seconds, the car will come out and continue to tracking.

24

27

8.Note

  1. The location of the road sign on the map, as shown below. 26

  2. Please make sure the battery is fully charged, otherwise it will not work normally

  3. If the road signs cannot be recognized, you can adjust the bracket of the k210 or the distance of the road signs

  4. You must use the road sign model provided by Yahboom, refer to the pictures in the road sign folder, other road signs cannot be recognized.

  5. Under normal circumstances, the motor is very smooth. If the motor freezes and the resistance is large, these conditions indicate that the motor is broken.

  6. The map must be kept clean without too many stains, otherwise it will affect the normal use

  7. When tracking, the environment should not be too bright or too dark.