K210-Self learning

The tutorial mainly demonstrates the balance car combined with the K210 vision module for autonomous classification learning and controlling the balance car to specify actions according to classification.

Hardware connection

PeripheralsDevelopment board
K210 vision module: VCC5V
K210 vision module: TXDPA2
K210 vision module: RXDPA3
K210 vision module: GNDGND

Control principle

Object classification learning is carried out through the K210 vision recognition module, and the learned data is used for object recognition. The classification serial number after object recognition is sent to the development board, and the development board controls the balance car to specify actions according to the serial number.

image-20240819151049932

Download program and model

Connect the SD card of the K210 vision module to the computer through a card reader, rename the program file to main.py and copy it to the SD card, and then reinstall the SD card into the SD card slot of the K210 vision module.

The model file used by the program needs to be placed in the specified location of the SD card (the sd folder refers to the root directory): /sd/KPU/self_learn_classifier/mb-0.25.kmodel

image-20240904140416242

Self-learning

After downloading the program and model to the K210 vision module, the K210 vision module will display Self Learing Demo:

image-20240904162654231

Press the K1 button to enter the next state:

image-20240904162746800

Press the K1 button again to start collecting the image material of the first object. Each object can collect 5 pictures. After collecting, proceed to the next object collection:

image-20240904163123590

After pressing the K1 button to collect five pictures, enter the next category collection: a total of three categories can be collected, and the collection steps are the same (press the K1 button to confirm the collected category and picture)

image-20240904163147581

After the collection is completed, the screen displays Classificatiion to indicate that it has entered the classification state. Press the BOOT button again to automatically disappear the prompt.

image-20240904163309107

image-20240904163456424

If the recognition effect is not good, or the image acquisition is wrong, you can press reset or press and hold the BOOT button to restart.

Communication protocol

The program of the K210 vision module will automatically recognize the object and send the category to the development board for processing.

Data headerData (X represents object category)Data tailExample
$X#$1#: represents object classification number 1
$X#$2#: represents object classification number 2
$X#$3#: represents object classification number 3

Main code

The tutorial mainly explains the code for the K210 self-learning control of the balance car function. For detailed code, please refer to the corresponding project file.

Deal_K210

Receive valid data sent by K210.

Change_state

根据k210发来的不同指令执行不同的动作。

Program flow chart

Briefly introduce the process of function implementation:

image-20240904164116298

Experimental phenomenon

Software code

The K210_BalancedCar_SelfLearn.hex file generated by the project compilation is located in the OBJ folder of the K210_BalancedCar_SelfLearn project. Find the K210_BalancedCar_SelfLearn.hex file corresponding to the project and use the FlyMcu software to download the program to the development board.

Experimental phenomenon

Before starting the program, you need to perform self-learning first. After completion, press the KEY1 button according to the OLED prompt to start the self-learning control function of the balance car: OLED displays Start control!; the K210 visual recognition module will perform the corresponding action when it recognizes the object; if no object is recognized, the balance car will remain balanced.