12. Navigation and avoiding

12. Navigation and avoiding12.1 Operation and use 12.1.1 Start 12.1.2 Use 12.1.3 Dynamic parameter adjustment 12.1.4 Node graph 12.1.5 tf coordinate system 12.2 navigation 12.2.1 Introduction 12.2.2 set tf 12.3 move_base 12.3.1 Introduction 12.3.2 move_base communication mechanism 1) Action 2) topic 3) tableware 4) Parameter configuration 12.3.3 Recovery Behavior 1 Introduction 2) Related function packages 12.4 costmap_params 12.4.1 costmap_common 12.4.2 global_costmap 12.4.3 local_costmap 12.4.4 costmap_2D 1 Introduction 2)topic 3) Parameter configuration 4) Layer Specifications 5)obstacle layer 6) Inflation layer 12.5 planner_params 12.5.1 global_planner 12.5.2 local_planner 1)dwa_local_planner 2)teb_local_planner

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] of 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(ordinary four-wheel drive) X3(Mike wheel) X3plus(Mike wheel mechanical arm) R2(Ackerman differential) and so on, to X3 as an example

Open the [.bashrc] file

Find the [ROBOT_TYPE] parameter and modify the corresponding model

12.1.1 Start

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

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

<Open another terminal and enter the same docker container

image-20240408144126098

Open the visual interface(virtual machine side)

6720

12.1.2 Use

1) Single point navigation

2) Multi-point navigation

3) Parameter configuration

According to different models, you only need to set the purchased model in [.bashrc], X1(ordinary four-wheel drive) X3(Mike wheel) X3plus(Mike wheel mechanical arm) R2(Ackerman differential) and so on, to X3 as an example

Open the [.bashrc] file

Find the [ROBOT_TYPE] parameter and modify the corresponding model

Looking at the yahboomcar_navigation.launch file, you 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, open the sample file as follows, you can modify and replace it according to your needs; at this time, the [DWA planner] is selected, and the [DWA] file is loaded.

Note: When using the DWA planner, the difference between the omnidirectional car and the differential car is 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 annotations and courseware, and modified according to their own needs.

12.1.3 Dynamic parameter adjustment

After starting the navigation function, open the dynamic parameter adjustment tool, adjust it according to your own needs, and observe the motion state of the robot 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 [mono + laser + yahboomcar] started in section [1.1] as an example to observe the communication between nodes.

nav_rosgraph

12.1.5 tf coordinate system

The transformation relationship between coordinates.

nav_tf

12.2 navigation

12.2.1 Introduction

Navigation is a two-dimensional navigation obstacle avoidance function package of ROS. In simple terms, it is based on the information flow of the input odometer and other sensors and the global position of the robot, through the navigation algorithm, calculates the safe and reliable robot speed control command.

20190317224634772

navigation main nodes and configuration

12.2.2 set tf

The navigation function requires the robot to publish information about the relationship between the coordinate systems using tf. 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 to associate the "base_link" frame with 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 the configuration, operation and interaction interface of 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 state of the target, it is recommended to use SimpleActionClient to send the target to the move_base.(See actionlib documentation )

nametypeillustrate
move_base/goalmove_base_msgs/MoveBaseActionGoalmove_base subscribes to the target point to be reached.
move_base/cancelactionlib_msgs/GoalIDmove_base subscribes to cancel requests for a specific target.
move_base/feedbackmove_base_msgs/MoveBaseActionFeedbackThe post contains the current position of the chassis.
move_base/statusactionlib_msgs/GoalStatusArrayPublishes status information for the move to the target point process.
move_base/resultmove_base_msgs/MoveBaseActionResultPost the final result of the move.
2) topic
nametypeillustrate
move_base_simple/goalgeometry_msgs/PoseStampedProvides a non-action interface that does not care about the execution state of the tracking target. move_base subscribes to the target point to be reached.
cmd_velgeometry_msgs/TwistPublishes the speed of the car's movement.
3) tableware
nametypeillustrate
make_plannav_msgs/GetPlanAllows external users 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 spaces in the area around the robot. This is useful when move_base's costmaps 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 costmap 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 the recovery behavior. These recovery behaviors can be configured with the recovery_behaviour parameter and disabled with 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 in place to clear the space. If this also fails, the robot will more aggressively clear the map, clearing all obstacles outside the rectangular area where the robot can rotate in place. Another in-place spin will follow. If all of these fail, the bot considers its goal unfeasible and informs the user that it has aborted.

image-20210918094233360

2) Related function packages

In the set of navigation function packs, there are 3 packs 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 specification in nav_core.

image-20210918110204025

parametertypeDefaultsParse
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 this recovery behavior is performed, the rotational speed of the robot will be limited(unit: rad/s).
limited_distancedouble0.3The distance(unit: m) that the robot must move before releasing the speed limit.
planner_namespacestring"DWAPlannerROS"The name of the planner whose parameters are to be reconfigured.
parametertypeDefaultsParse
sim_granularitydouble0.017When checking whether it is safe to rotate in place, the distance between checking obstacles is 1 degree by default(unit: rad).
frequencydouble20.0The frequency(unit: Hz) of sending speed commands to the mobile robot.
TrajectoryPlannerROS/yaw_goal_tolerancedouble0.05The tolerance in radians for the controller in yaw/rotation to achieve 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(unit: rad/s) allowed by the base when performing an in-position rotation.

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

parametertypeDefaultsParse
clearing_distancedouble0.5The length centered on the robot that the obstacle will be removed from the costmap when it reverts to a static map.

12.4 costmap_params

The navigation function uses two costmaps to store information about obstacles. One costmap is used for global planning, which means creating global planning routes across the entire environment, and the other is used for local planning and obstacle avoidance. The two costmaps have some common configuration and some individual configuration. Therefore, the costmap configuration has the following three parts: general configuration, global configuration and local configuration.

12.4.1 costmap_common

Costmap public parameter configuration costmap_common_params.yaml

parameter parsing

12.4.2 global_costmap

Global costmap parameter configuration global_costmap_params.yaml

12.4.3 local_costmap

Local costmap parameter configuration local_costmap_params.yaml

parameter parsing

12.4.4 costmap_2D

1 Introduction

The costmap_2d package provides a 2D costmap implementation that takes input sensor data, builds a 2D or 3D costmap of the data(depending on whether a voxel-based implementation is used), and uses occupancy grids and user-defined inflation Radius computes the cost of the 2D costmap.

6714

2)topic
nametypeillustrate
footprintgeometry_msgs/PolygonRobot enclosure specification. This replaces the previous parameter specification for the package outline.
costmapnav_msgs/OccupancyGridcost map
costmap_updatesmap_msgs/OccupancyGridUpdateUpdate area of the costmap
voxel_gridcostmap_2d/VoxelGridvoxel grid
3) Parameter configuration

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

plugin

Coordinate system and tf parameters

Rate parameter

Map management parameters

static layer

tf transform

global_fram——>robot_base_frame

4) Layer Specifications
5)obstacle layer

Obstacle layers and voxel layers contain information from sensors in the form of point clouds or laser scans. Barrier layers track in 2D, while voxel layers track in 3D.

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

Subscribe to topics

topic nametypeParse
point_cloud_topicsensor_msgs/PointCloudUpdate PointCloud information to costmap.
point_cloud2_topicsensor_msgs/PointCloud2Update PointCloud2 information to costmap
laser_scan_topicsensor_msgs/LaserScanUpdate LaserScan information to costmap
mapnav_msgs/OccupancyGridThe costmap has the option to initialize from a user-generated static map

Sensor Management Parameters

Global filter 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 specific symbols related to bots for the cost value of the costmap.

parameter

12.5 planner_params

12.5.1 global_planner

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

Global Path Planning Plugin

Global path planning global_planner_params.yaml

parameter parsing

Global path planning algorithm renderings

img

img

img

img

img

img

img

If it appears in the very first stage:

This situation is related to the direction set by the robot. It is recommended to try the default [navfn] plugin 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 adhere to this interface. Documentation on NavaCys::BaseLoCalPrnor's C++ API can be found here: BaseLocalPlanner documentation .

Local path planning plugin

Comparison of TEB and DWA:

teb will adjust its orientation during the movement. When it reaches the target point, usually the orientation of the robot is also the orientation of the target and does not need to rotate.

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

For a two-wheel differential chassis, adjusting the orientation of the teb during movement will make the movement path unsmooth, and unnecessary backwards will occur when starting and reaching the target point, which is not allowed in some application scenarios. Because backing up may encounter obstacles. Rotating in place to a suitable orientation and then walking away is a more appropriate exercise strategy. This is also where teb needs to be optimized according to the scene.

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 package provides a controller that drives the robot to move in a plane. 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 position, sending the dx, dy, 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 fall 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 tune the local path planner in a running system.

Robot configuration parameters

Target tolerance parameter

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. Support difference model, car-like model. This software package implements an online optimal local trajectory planner for mobile robot navigation and control, which efficiently obtains the optimal trajectory by solving a sparse scalar multi-objective optimization problem. Users can provide weights to optimization problems 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 grouped into categories: robot configuration, target tolerance, trajectory configuration, obstacles, optimization, planning in unique topologies, and other parameters. Some of them were selected to meet basic local planners. Many(but not all) parameters can be modified at runtime using rqt_reconfig.

Local path planner teb_local_planner_params.yaml

Robot configuration

target tolerance

Track configuration

obstacle

The following parameters are only costmap_converter plugin is required:

optimization

planning