2. Lidar obstacle avoidance fun gameplay

 

2.1 Description of program function

After the program starts, the car will move forward, when there is an obstacle in the detection range, it will adjust its attitude, avoid the obstacle, and then continue to move forward.

Enable/pause this function by starting the Dynamic Parameter Adjuster on the virtual machine and clicking [Switch].

In addition, the [L1] button on the handle locks/turns on the car's motion controls. When motion control is enabled, the function is locked; This function can be turned on when the motion control is locked.

2.2. Program Code reference path

After SSH connection car, the location of the function source code is located at,

2.3. Program Startup

2.3.1. Car start command

After SSH connects to the car, terminal input,

2.3.2. Modifying parameters on the VM side

On the virtual machine, open the dynamic parameter adjuster, open the terminal input,

1684746125126

The meaning of each parameter is as follows.

parameter nameparameter meaning
SwitchPlay switch
ResponseDistObstacle detection distance
linearThe linear velocity
angularAngular velocity
LaserAngleRadar detection Angle

The above parameters can be adjusted. By checking or unchecking [Switch], the radar obstacle avoidance function can be enabled or suspended.

The other four need to be set when the decimal, modify, press the enter key or click the blank space can be written.

2.3.3. View the topic communication node graph

Virtual machine terminal input,

1684746599055

2.4. Core Source Code Analysis

Mainly look at the radar callback function, which explains how to obtain the obstacle distance information at each Angle.