STM32 car autopilot

1.Experiment preparation

  1. knowledge reserve
  1. Material preparation
  1. k210 viewing angle module preparation 3.1 Take the TF card out of the k210 vision module and insert it into the card reader.

01

3.2 Insert the card reader into the computer and wait for the computer to recognize the U disk

02

3.3 After the computer recognizes it, enter it into the TF card.

03

3.4 Find the k210 folder in the source code of the data program, find the 20_tinybit_AI_sport.py and tinybit_AI.kmodel files from the folder, and copy them to the root directory.

04

05

3.5 Delete the main file and rename the 20_tinybit_AI_sport.py file to the main file.

06

07

3.6 After renaming, pull out the card reader, take out the TF card, and insert it back into the k210 vision module.

2.Car wiring

After the car is assembled, as shown in the figure below

08

09

2.1 Stm32 and dual driver board wiring part

  1. Wiring of stm32F103RCT6 and dual motor board (top board)
STM32RCT6The top 2-channel motor board
PA11BN1
PA8BN2
PC6AN1
PC7AN2
3.33V3
GNDGND
PA0E2A
PA1E2B
PA15E1A
PB3E1B
  1. Wiring of stm32F103RCT6 and dual motor board (lowest board)
STM32RCT6The bottom 2-channel motor board
PB0BN1
PB1BN2
PC8AN1
PC9AN2
3.33V3
GNDGND
PA7E2A
PA6E2B
PB7E1A
PB6E1B
  1. The motor drive board on the top layer is the motor of the two wheels (that is, the front motor) that is connected to the electromagnetic sensor,

    motorA--->right motor、motorB--->left motor

  2. The motor drive board at the bottom is connected to the two-wheeled motors away from the electromagnetic sensor (that is, the motor at the back),

motorA--->right motor、motorB--->left motor

10

2.2 Wiring of STM32F103RCT6 and infrared sensor

STM32RCT64-way line inspection sensor
PA5S1
PA4S2
PA3S3
PA2S4
3.3VVCC
GNDGND

2.3 Wiring of STM32RCT6 and k210

STM32RCT6k210
PA9RXD
PA10TXD
VCCVCC
GNDGND

 

3.Main source code analysis

The flow chart of the program is roughly as follows 17

The source code provided in this tutorial retains the RGB\LCD\IMU\external Flash driver on the STM32F103RCT6 board, which can be called directly to facilitate secondary development

4.Experimental results

After everything is normal, the car will start along the map and plan the path of the tracking movement. When the road sign is recognized, the corresponding path planning movement will appear.

  1. When the speed limit sign is recognized, the car will do a speed patrol movement 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 left/right turn is recognized, the car will make a priority left/right turn patrol movement

20

22

  1. The horn is recognized, because this car does not have a buzzer, so it is normal to patrol the line.

21

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

23

  1. Identify No. 1 and No. 2 garages, the car will enter No. 1 garage if it recognizes No. 1 garage; recognize No. 2 garage, and the car will reverse into No. 2 garage; 2 seconds after entering the garage, the car will come out and continue to patrol the line.

24

27

5.Notes about this routine

  1. The signposts placed on this tutorial map are shown in the figure below:

26

  1. The battery must be fully charged, otherwise it cannot work normally

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

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

  4. Under normal circumstances, the motor is very smooth. If there is a motor jam or a large resistance, these conditions indicate that there is a problem with the motor.

    1. The patrol map must be kept clean without too many stains, otherwise it will affect the normal use
  5. When patrolling the line, the environment should not be too bright or too dark, normal lighting is fine