5、Patrol function gameplay

1、Program function description

After the program starts, open the patrol route set by the dynamic parameter setter, click the "switch" of the GUI interface, the trolley moves according to the set patrol route, during operation, the radar works at the same time, and if an obstacle is detected within the detection range, it will stop. After the controller program is turned on, you can also pause/resume the trolley movement through the R2 button.

2、Program code reference path

After entering the docker container, the location of the source code of this function is located at,

3、The program starts

3.1、start the command

After entering the docker container, according to the actual model and radar model, the terminal input,

3.2、View the topic communication node diagram

docker terminal input,

image-20230421161538192

Set the size of parameters via dynamic parameter adjuster, terminal input,

The parameters of the dynamic parameter regulator are described as follows:

image-20230421161626269

Parameter nameParameter meaning
odom_frameOdometer coordinate system
base_frameCoordinate system
circle_adjustRotational angular velocity adjustment factor
SwitchGameplay switch
CommandPatrol routes
Set_loopSet up a loop
ResponseDistRadar obstacle avoidance response range
LaserAngleRadar scan angle
LinearLine speed
Angularangular velocity
LengthStraight-line test distance
RotationToleranceSteering error tolerance
RotationScalingCorner scale factor

After the program starts, enter any of the following routes in the Comand field in the GUI interface of the Dynamic Parameter Adjuster interface:

After selecting the route, click the blank parameter to write, and then click the Switch button to start the patrol movement. If the loop is set, you can loop through the previous route to patrol, and if the loop is false, it will stop when the patrol is completed.

4、Core source code analysis

The implementation source code of this code is to subscribe to the TF transformation of odom and base_footprintf, so that you can know "how long you have walked" at any time, and then issue speed instructions according to the set route, take Triangle as an example, here to do the analysis,