Lidar wall tracking-multiple walls

The tutorial mainly demonstrates the wall patrol function of the balance car combined with the Tmini-Plus radar (maintaining a certain distance from the nearest wall).

Hardware connection

Since we have configured a special connection line, you only need to install it to the corresponding interface.

PeripheralsDevelopment Board
Tmini-Plus radar: VCC5V
Tmini-Plus radar: TXDPC10
Tmini-Plus radar: RXDPC11
Tmini-Plus radar: GNDGND

Control principle

The program analyzes the radar data, and sets the distance from the wall and the distance to be maintained for patrolling the wall according to the distance collected by the program initialization (radar 72° distance). The 0° distance determines whether there is an obstacle in front.

image-20240820102356793

Product nameTmini-Plus radar
Scanning frequency6-12Hz
Sampling frequency4000 times/s
Measuring radiusBlack object: 12m
Minimum measuring distance0.05m
Distance measurement principleTOF distance measurement
Scanning angle360°
Communication interfaceStandard asynchronous serial port (UART)
1. Baud rate: 230400
2. Data bits: 8
3. Check bit: None
4. Stop bit: 1
ROS supportROS1/ROS2
Windows supportHost computer

Radar angle distribution

The arrow in the center of the radar points to 0°/360°, and the angle increases clockwise.

image-20240820204047537

Communication protocol

Main code

The tutorial mainly explains the code for the radar wall following function. For detailed code, please refer to the corresponding project file.

LiDar_Straight

The radar wall following function adds a turning action to the radar wall following function. When there is no obstacle in front of the radar, the radar maintains the wall following function. When an obstacle is detected in front of the radar, the radar turns left.

Distance_Adjust_PID

PID processing is performed based on the distance between the radar and the wall. If the balancing car does not patrol the wall in a straight line effectively, modify the PID parameters of the app_lidar_car.c file. It is not recommended to modify the PID parameters of the pid_control.c file (the PID parameters of the pid_control.c file are subject to the parameters finally confirmed in the balancing car parameter adjustment tutorial).

Program flow chart

Briefly introduce the process of function implementation:

image-20240904175810993

Experimental phenomenon

Software code

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

Experimental phenomenon

After the program is started, press KEY1 according to the OLED prompt to start the radar wall-following function of the balance car:

OLED displays wait get dis!: The balance car will take 1 second to obtain the distance that the radar needs to patrol the wall (the right side of the radar needs to be close to the wall, and the source of the patrol distance is the 72° position of the radar); OLED displays start track!: Start the radar wall-following mode.

If an obstacle is encountered during the patrol process, it will turn left; after turning left, it will resume the wall-following mode.