12. Navigation and obstacle avoidance

navigation: http://wiki.ros.org/navigation/

navigation/Tutorials: http://wiki.ros.org/navigation/Tutorials/RobotSetup

costmap_2d: http://wiki.ros.org/costmap_2d

nav_core: http://wiki.ros.org/nav_core

global_planner: http://wiki.ros.org/global_planner

dwa_local_planner: http://wiki.ros.org/dwa_local_planner

teb_local_planner: http://wiki.ros.org/teb_local_planner

move_base: http://wiki.ros.org/move_base

12.1. Operation and use

Note: [R2] on the remote control handle has the function of canceling the target point.

According to different models, you only need to set the purchased model in [.bashrc], X1 (normal four-wheel drive) X3 (Mailun) X3 as an example

Open the [.bashrc] file

Find the [ROBOT_TYPE] parameters and modify the corresponding car model

12.1.1. Start

Start the driver (robot side). For ease of operation, this section takes [mono + laser + yahboomcar] as an example.

Start the navigation obstacle avoidance function (robot side), set parameters and modify the launch file according to needs.

<PI5 needs to open another terminal to enter the same docker container

image-20240408144126098

Turn on the visual interface (virtual machine side)

6720

12.1.2. Use

  1. Single point navigation

  1. Multi-point navigation

  1. Parameter configuration

According to different models, you only need to set the purchased model in [.bashrc], X1 (normal four-wheel drive) X3 (Mailun) X3 as an example

Open the [.bashrc] file

Find the [ROBOT_TYPE] parameters and modify the corresponding car model

Looking at the yahboomcar_navigation.launch file, we can see that the navigation parameters are modified in the move_base.launch file under the yahboomcar_nav function package.

Find the move_base.launch file and open the example file as follows. It can be modified and replaced according to your needs. At this time, [DWA Planner] is selected and the [DWA] file is loaded.

Note: When using the DWA planner, the difference between an omnidirectional car and a differential car lies in whether the speed in the Y direction is 0. There are clear comments in it, which can be modified according to the actual situation.

Enter the dwa_local_planner_params.yaml file under the yahboomcar_nav function package. Some parameters are as follows:

Other parameter files can be opened, combined with comments and courseware, and modified according to your own needs.

12.1.3. Dynamic parameter adjustment

After starting the navigation function, open the dynamic parameter adjustment tool, adjust according to your own needs, and observe the robot's motion status until the effect is optimal. Record the current parameters and modify them to the dwa_local_planner_params.yaml file under the yahboomcar_nav function package.

image-20220224175356466

12.1.4. Node graph

Take starting [mono + laser + yahboomcar] in section [1.1] as an example to observe the communication between nodes.

nav_rosgraph

12.1.5, tf coordinate system

The conversion relationship between coordinates.

nav_tf

 

12.2, navigation

12.2.1. Introduction

Navigation is the two-dimensional navigation and obstacle avoidance function package of ROS. Simply put, it calculates safe and reliable robot speed control instructions through the navigation algorithm based on the information flow from the input odometer and other sensors and the global position of the robot.

20190317224634772

navigation main nodes and configuration

12.2.2. Setting tf

Navigation functionality requires the robot to use tf to publish information about the relationships between coordinate systems. For example: lidar

image-20210917144744778

Suppose we know that the lidar is mounted 10 cm and 20 cm above the center point of the mobile base. This gives us the translation offset that relates the "base_link" frame to the "base_laser" frame. Specifically, we know that to get data from the "base_link" coordinate system to the "base_laser" coordinate system, we have to apply a translation of (x: 0.1m, y: 0.0m, z: 0.2m) and get the data from the "base_laser" frame To the "base_link" frame we have to apply the opposite translation (x: -0.1m, y: 0.0m, z: -0.20m).

image-20210917144913572

12.3, move_base

12.3.1. Introduction

move_base provides configuration, operation, and interactive interfaces for ROS navigation.

image-20210917111812154

Implementing the robot navigation function must be configured in a specific way, as shown above:

12.3.2, move_base communication mechanism

1) Action

The move_base node provides an implementation of SimpleActionServer that receives targets containing geometry_msgs/PoseStamped messages. You can communicate directly with the move_base node via ROS, but if you care about tracking the status of the target, it is recommended to use SimpleActionClient to send the target to move_base. (See actionlib documentation for more information)

NameTypeDescription
move_base/goalmove_base_msgs/MoveBaseActionGoalmove_base subscribes to the target point to be reached.
move_base/cancelactionlib_msgs/GoalIDmove_base subscribes to requests to cancel a specific goal.
move_base/feedbackmove_base_msgs/MoveBaseActionFeedbackPublish the current position containing the chassis.
move_base/statusactionlib_msgs/GoalStatusArrayPublish status information of the process of moving to the target point.
move_base/resultmove_base_msgs/MoveBaseActionResultPublish the final result of the move.
2) topic
NameTypeDescription
move_base_simple/goalgeometry_msgs/PoseStampedProvides a non-action interface for not paying attention to the execution status of the tracking goal. move_base subscribes to the target point that will be reached.
cmd_velgeometry_msgs/TwistPublish the moving speed of the car.
3) servies
NameTypeDescription
make_plannav_msgs/GetPlanAllows an external user to request a plan for a given pose from move_base without causing move_base to execute the plan.
clear_unknown_spacestd_srvs/EmptyAllows external users to notify move_base to clear unknown space in the area around the robot. This is useful when the costmaps of move_base are stopped for a long period of time and then restarted at a new location in the environment.
clear_costmapsstd_srvs/EmptyAllows external users to tell move_base to clear barriers in the costmaps used by move_base. This may cause the robot to bump into things and should be used with caution
4) Parameter configuration

move_base_params.yaml

12.3.3. Recovery Behavior

1 Introduction

When ① the global planning fails, ② the robot oscillates, and ③ the local planning fails, it will enter recovery behavior. These recovery behaviors can be configured using the recovery_behaviour parameter and disabled using the recovery_behavior_enabled parameter.

Desired robot behavior

First, obstacles outside the user-specified area are cleared from the robot's map. Next, if possible, the robot will perform a spin to clear space. If this also fails, the robot will clear the map more aggressively, clearing all obstacles outside of a rectangular area within which the robot can rotate in place. This will be followed by another spin in place. If all else fails, the bot considers its goal to be infeasible and notifies the user that it has aborted.

image-20210918094233360

In the navigation function package collection, there are 3 packages related to the recovery mechanism. They are: clear_costmap_recovery, move_slow_and_clear, rotate_recovery. Three classes are defined in these three packages, all of which inherit the interface specifications in nav_core.

image-20210918110204025

ParametersTypeDefault valueParse
clearing_distancedouble0.5Obstacles within the robot's clearing distance will be cleared (unit: m).
limited_trans_speeddouble0.25When performing this recovery behavior, the robot's translation speed will be limited (unit: m/s).
limited_rot_speeddouble0.25When performing this recovery behavior, the robot's rotational speed will be limited (unit: rad/s).
limited_distancedouble0.3The distance (unit: m) that the robot must move before the speed limit is released.
planner_namespacestring"DWAPlannerROS"The name of the planner whose parameters are to be reconfigured.
ParametersTypeDefault valueParse
sim_granularitydouble0.017When checking whether it is safe to rotate in place, the distance between obstacles is checked to be 1 degree (unit: rad) by default.
frequencydouble20.0The frequency of sending speed commands to the mobile robot (unit: HZ).
TrajectoryPlannerROS/yaw_goal_tolerancedouble0.05The controller's arc tolerance in yaw/rotation when achieving its goal.
TrajectoryPlannerROS/acc_lim_thdouble3.2The rotational acceleration limit of the robot (unit: rad/s^2).
TrajectoryPlannerROS/max_rotational_veldouble1.0The maximum rotation speed allowed by the base (unit: rad/s).
TrajectoryPlannerROS/min_in_place_rotational_veldouble0.4The minimum rotation speed allowed by the base when performing in-place rotation (unit: rad/s).

Note: The TrajectoryPlannerROS parameter is only set when using the base_local_planner::TrajectoryPlannerROS planner; generally no setting is required.

ParametersTypeDefault valueParse
clearing_distancedouble0.5The length, centered on the robot, that the obstacle will be removed from the cost map when it reverts to a static map.

12.4, costmap_params

The navigation function uses two cost maps to store obstacle information. One cost map is used for global planning, which means creating globally planned routes throughout the environment, and the other is used for local planning and obstacle avoidance. The two costmaps have some common configurations and some separate configurations. Therefore, the cost map configuration has the following three parts: general configuration, global configuration and local configuration.

12.4.1, costmap_common

Cost map public parameter configuration costmap_common_params.yaml

Parameter analysis

12.4.2, global_costmap

Global cost map parameter configuration global_costmap_params.yaml

12.4.3, local_costmap

Local cost map parameter configuration local_costmap_params.yaml

Parameter analysis

12.4.4, costmap_2D

1 Introduction

The costmap_2d package provides a 2D cost map implementation that uses input sensor data to construct a data 2D or 3D cost map (depending on whether a voxel-based implementation is used) and generates data based on the occupancy grid and user-defined dilation. The radius calculates the cost of the 2D cost map.

6714

2) topic
NameTypeDescription
footprintgeometry_msgs/PolygonRobot shell specification. This replaces the previous parameter specification for the package outline.
costmapnav_msgs/OccupancyGridcostmap
costmap_updatesmap_msgs/OccupancyGridUpdateThe update area of the cost map
voxel_gridcostmap_2d/VoxelGridvoxel grid
3) Parameter configuration

If you do not provide the plugins parameter, the initialization code will assume that your configuration is pre-Hydro and the default namespaces are static_layer, obstacle_layer, and inflation_layer.

plug-in

Coordinate system and tf parameters

Rate parameters

Map management parameters

static layer

tf transform

global_frame——>robot_base_frame

4) Layer specifications
5)obstacle layer

The obstacle and voxel layers contain information from sensors in the form of point clouds or laser scans. Barrier layers are tracked in two dimensions, while voxel layers are tracked in three dimensions.

The cost map automatically subscribes to the sensor topic and updates accordingly. Each sensor is used for marking (inserting obstacle information into the cost map) and clearing (removing obstacle information from the cost map). Each time the data is observed, the clear operation performs a ray trace from the sensor origin outward through the mesh. In the voxel layer, the obstacle information in each column is projected down into a 2D map.

Subscribe to topics

Topic nameTypeAnalysis
point_cloud_topicsensor_msgs/PointCloudUpdate PointCloud information to the cost map.
point_cloud2_topicsensor_msgs/PointCloud2Update PointCloud2 information to cost map
laser_scan_topicsensor_msgs/LaserScanUpdate LaserScan information to cost map
mapnav_msgs/OccupancyGridCost map with option to initialize from user generated static map

Sensor management parameters

Global filtering parameters: These parameters apply to all sensors.

ObstacleCostmapPlugin

VoxelCostmapPlugin

6) Inflation layer

6715

The inflation cost decreases as the robot's distance from the obstacle increases. Define 5 robot-specific symbols for the cost map's cost value.

parameter

12.5, planner_params

12.5.1, global_planner

nav_core::BaseGlobalPlanner provides an interface to the global planner used in navigation. All global planners written as move_base node plugins must comply with this interface. Documentation about NavaCys::BaseGoLBalPrimeNe: C++ documentation can be found here: BaseGlobalPlanner documentation.

Global path planning plug-in

Global path planning global_planner_params.yaml

Parameter analysis

Global path planning algorithm renderings

-A*

If it appears at the very beginning:

This situation is related to the direction set by the robot. It is recommended to try the default [navfn] plug-in for global path planning.

12.5.2, local_planner

nav_core::BaseLocalPlanner Provides an interface for local path planners used in navigation. All local path planners written as move_base node plugins must comply with this interface. Documentation on the C++ API of NavaCys::BaseLoCalPrnor can be found here: BaseLocalPlanner documentation.

Local path planning plug-in

Comparison between TEB and DWA:

Teb will adjust its posture and orientation during the movement. When it reaches the target point, the robot's orientation is usually the target orientation without rotation.

dwa first reaches the target coordinate point, and then rotates in place to the target orientation.

For a two-wheel differential chassis, TEB's adjustment of the direction during movement will make the movement path unsmooth, causing unnecessary retreat when starting and reaching the target point, which is not allowed in some application scenarios. Because retreating may encounter obstacles. It is a more appropriate movement strategy to rotate on the spot to the appropriate direction and then walk away. This is also where teb needs to be optimized according to the scenario.

1) dwa_local_planner

The dwa_local_planner package supports any robot whose chassis can be represented as a convex polygon or a circle. This software package provides a controller to drive robot movement in a flat surface. This controller connects the path planner to the robot. The planner uses the map to create a motion trajectory for the robot from the starting point to the target location, sending the dx, dy, and dtheta velocities to the robot.

The basic idea of DWA algorithm

A number of ROS parameters can be set to customize the behavior of dwa_local_planner::DWAPlannerROS. These parameters are divided into several categories: robot configuration, target tolerance, forward simulation, trajectory scoring, oscillation prevention, and global planning. These parameters can be debugged using the dynamic_reconfigure tool to facilitate tuning of the local path planner in a running system.

Robot configuration parameters

target tolerance parameters

Forward simulation parameters

Trajectory scoring parameters

Anti-vibration parameters

Global planning parameters

2) teb_local_planner

teb_local_planner is an optimization-based local trajectory planner. Supports differential models and car-like models. This software package implements an online optimal local trajectory planner for mobile robot navigation and control, effectively obtaining optimal trajectories by solving sparse scalarized multi-objective optimization problems. Users can provide weights to the optimization problem to specify behavior in case of conflicting goals.

The teb_local_planner package allows users to set parameters to customize the behavior. These parameters are divided into several categories: robot configuration, target tolerance, trajectory configuration, obstacles, optimization, planning in unique topologies and other parameters. Some of these were chosen to meet basic local planner requirements. Many (but not all) parameters can be modified at runtime using rqt_reconfigure.

Local path planner teb_local_planner_params.yaml

Robot configuration

target tolerance

Track configuration

obstacle

The following parameters are only relevant when the costmap_converter plug-in is required:

optimization

planning