admin管理员组

文章数量:1658610

navigation导航学习

    • 写在前面:对Navigation导航进行学习,重点了解其组成结构
      • 1、启动
      • 2、使用
      • 3、动态参数调节
      • 4、navigation
        • 4.1、简介
        • 4.2、设置TF
      • 5、move_base
        • 5.1、框架介绍
        • 5.2、move_base通讯机制
          • 1)、Action
          • 2)、topic
          • 3)、service
          • 4)、参数配置
      • 6、Recovery Behavior
        • 1)、简介
        • 2)、相关功能包
      • 7、costmap_params
          • 7.1、costmap_common
          • 7.2、loca_costmap
          • 7.3、global_costmap
          • 7.4、costmap_2D
      • 8、planner_params
          • 8.1、global_planner
          • 8.2、local_planner
      • 9、AMCL
          • 9.1、简介
          • 9.2、话题与服务
          • 9.3、参数配置

写在前面:对Navigation导航进行学习,重点了解其组成结构

1、启动

roslaunch yahboomcar_nav laser_bringup.launch
roslaunch yahboomcar_nav yahboomcar_navigation open_rviz:=true map:=house
  • open_rviz参数:是否打开rviz
  • map:地图名,要加载的地图

2、使用

  • 将机器人放在原点处,如果雷达扫描边线和地图没有重合,需要使用【rviz】工具的【2D PoseEstimate】设置初始位姿,如果机器人找不到在地图中的位姿时,也需要设置初始位姿。

  • 点击【rviz】工具的【2D Nav Goal】,然后再地图上在没有障碍物的地方选择目标点,松开鼠标即开始导航,只能选择一个目标点,到达即停止。

  • 多点导航:点击【rviz】工具的【Publish Point】,然后再地图上在没有障碍物的地方选择目标点,松开鼠标即开始导航,可再次点击【Publish Point】,然后选点,机器人就会点与点之间巡航。

3、动态参数调节

终端输入:

rosrun rqt_reconfigure rqt_reconfigure

查看节点关系与TF树,

rqt_graph
rosrun rqt_tf_tree rqt_tf_tree

4、navigation

4.1、简介

navigation是ROS的二维导航避障功能包,简单来说,就是根据输入的里程计等传感器的信息流和机器人的全局位置,通过导航算法,计算得出安全可靠的机器人速度控制指令。

navigation主要节点及配置:

  • move_base:导航避障控制的最终执行机构,move_base订阅导航目标move_base_simple/goal,并实时发布运动控制信号cmd_vel,move_base中的各种导航算法模块都是以插件的形式进行调用的。

  • global_planner:用于全局路径规划。

  • local_planner:用于局部路径规划。

  • global_costmap:全局代价地图用于描述全局环境信息。

  • local_costmap:局部代价地图用于描述局部环境信息。

  • recovery_behaviors:恢复策略用于机器人碰到障碍后自动进行逃离恢复。

  • amcl:利用粒子滤波算法实现机器人的全局定位,为机器人导航提供全局位置信息。

  • map_server:通过调用SLAM建图得到的地图为导航提供环境地图信息。

  • costmap_2d:可以生产代价地图,以及提供各种相关的函数。

  • robot_pose_ekf:扩展卡尔曼滤波器,输入是里程计、IMU、VO中的任意两个或者三个,输出是一个融合之后的pose。

  • nav_core:这里面只有三个文件,对应的是全局路径规划、局部路径规划、recovery_action的通用接口定义,具体功能实现则是在各个对应的规划器功能包里。

  • 机器人模型相关的tf信息、里程计odom信息、激光雷达信息scan。

4.2、设置TF

导航功能要求机器人使用tf发布有关坐标系之间关系的信息。例如:激光雷达,
假设我们知道激光雷达安装在移动底座中心点上方 10 厘米和 20 厘米处。这为我们提供了将“base_link”框架与“base_laser”框架相关联的平移偏移量。具体来说,我们知道要从“base_link”坐标系获取数据到“base_laser”坐标系,我们必须应用 (x: 0.1m, y: 0.0m, z: 0.2m) 的平移,并从“ base_laser”框架到“base_link”框架,我们必须应用相反的平移(x:-0.1m,y:0.0m,z:-0.20m)。

5、move_base

5.1、框架介绍

move_base提供了ROS导航的配置、运行、交互接口。

实现机器人导航功能必须以特定方式配置,如上图:

  • 白色组件是已经实现的必需组件,
  • 灰色组件是已经实现的可选组件,
  • 蓝色组件必须为每个机器人平台创建。
5.2、move_base通讯机制
1)、Action

move_base节点提供了SimpleActionServer的一个实现,它接收包含geometry_msgs/PoseStamped消息的目标。您可以通过ROS直接与move_base节点通信,但是如果您关心跟踪目标的状态,建议使用SimpleActionClient将目标发送到move_base。

2)、topic

3)、service

4)、参数配置

move_base_params.yaml

# 建议差速车开启DWA导航算法,非差速车开启TEB导航算法。
# 设置move_base的全局路径规划器的插件名称
# The name of the plugin for the global planner to use with move_base, see pluginlib documentation for more details on plugins.
#base_global_planner: "navfn/NavfnROS"
#base_global_planner: "global_planner/GlobalPlanner"
#base_global_planner: "carrot_planner/CarrotPlanner"


# 设置move_base的局部路径规划器的插件名称
# The name of the plugin for the local planner to use with move_base see pluginlib documentation for more details on plugins.
#base_local_planner: "teb_local_planner/TebLocalPlannerROS"
#base_local_planner: "dwa_local_planner/DWAPlannerROS"

# 恢复行为。
recovery_behaviors:
  - name: 'conservative_reset'
    type: 'clear_costmap_recovery/ClearCostmapRecovery'
  #- name: 'aggressive_reset'
  #  type: 'clear_costmap_recovery/ClearCostmapRecovery'
  #- name: 'super_reset'
  #  type: 'clear_costmap_recovery/ClearCostmapRecovery'
  - name: 'clearing_rotation'
    type: 'rotate_recovery/RotateRecovery'
    #- name: 'move_slow_and_clear'
    #type: 'move_slow_and_clear/MoveSlowAndClear'


# 向机器人底盘cmd_vel发送命令的频率
# The rate in Hz at which to run the control loop and send velocity commands to the base.
controller_frequency: 10.0
# 空间清理操作执行前,路径规划器等待有效控制命令的时间
# How long the planner will wait in seconds in an attempt to find a valid plan before space-clearing operations are performed.
planner_patience: 5.0
# 空间清理操作执行前,控制器等待有效控制命令的时间
# How long the controller will wait in seconds without receiving a valid control before space-clearing operations are performed.
controller_patience: 5.0
# 仅当默认恢复行为用于 move_base 时才使用此参数。
# The distance away from the robot in meters beyond which obstacles will be cleared from the costmap when attempting to clear space in the map.
conservative_reset_dist: 5.0
# 是否启用move_base恢复行为以尝试清除空间。
# Whether or not to enable the move_base recovery behaviors to attempt to clear out space.
recovery_behavior_enabled: true
# 机器人是否采用原地旋转的运动方式清理空间,此参数仅在使用默认恢复行为时使用。
# Determines whether or not the robot will attempt an in-place rotation when attempting to clear out space.
clearing_rotation_allowed: true
# 当move_base进入inactive状态时,是否停用节点的costmap
# Determines whether or not to shutdown the costmaps of the node when move_base is in an inactive state
shutdown_costmaps: false
# 执行恢复操作之前允许震荡的时间,0代表永不超时
# How long in seconds to allow for oscillation before executing recovery behaviors.
oscillation_timeout: 10.0
# 机器人需要移动该距离才可当做没有震荡。移动完毕后重置定时器参数
# How far in meters the robot must move to be considered not to be oscillating.
oscillation_distance: 0.3
# 全局路径规划器循环速率。
# The rate in Hz at which to run the global planning loop.
planner_frequency: 10.0 #0.0
# 在执行恢复行为之前允许计划重试的次数。值-1.0对应于无限次重试。
# How many times to allow for planning retries before executing recovery behaviors.
max_planning_retries: -1.0

conservative_reset:
  reset_distance: 1.0
  #layer_names: [static_layer, obstacle_layer, inflation_layer]
  layer_names: [obstacle_layer]

aggressive_reset:
  reset_distance: 3.0
  #layer_names: [static_layer, obstacle_layer, inflation_layer]
  layer_names: [obstacle_layer]

super_reset:
  reset_distance: 5.0
  #layer_names: [static_layer, obstacle_layer, inflation_layer]
  layer_names: [obstacle_layer]

move_slow_and_clear:
  clearing_distance: 0.1
  limited_trans_speed: 0.1
  limited_rot_speed: 0.4
  limited_distance: 0.3

6、Recovery Behavior

1)、简介

当①全局规划失败、②机器人震荡、③局部规划失败时会进入到恢复行为。可以使用recovery_behaviour参数配置这些恢复行为,并使用recovery_behavior_enabled参数禁用这些恢复行为。

首先,用户指定区域之外的障碍物将从机器人的地图上清除。接下来,如果可能的话,机器人将执行原地旋转以清理空间。如果这也失败了,机器人将更积极地清除地图,清除矩形区域之外的所有障碍物,在该区域内机器人可以原地旋转。随后将进行另一次就地旋转。如果所有这些都失败,机器人会认为它的目标是不可行的,并通知用户它已经中止。

  • conservative reset:保守恢复。
  • clearing rotation:旋转清除。
  • aggressive reset:积极恢复。
  • aborted:中止。
2)、相关功能包

在导航功能包集合中,有3个包与恢复机制有关。分别为:clear_costmap_recovery、move_slow_and_clear、rotate_recovery。这3个包中分别定义了3个类,都继承了nav_core中的接口规范。

move_slow_and_clear:是一种简单的恢复行为,它清除代价图中的信息,然后限制机器人的速度。注意,这种恢复行为并不是真正安全的,机器人可能会击中物体,它只会以用户指定的速度发生。

参数配置,

rotate_recovery:旋转恢复,通过机器人360度旋转来清除空间。

参数配置,

注意:TrajectoryPlannerROS参数在使用base_local_planner::TrajectoryPlannerROS规划器时才被设置;一般无需设置。

clear_costmap_recovery:一种恢复行为,将move_base使用的代价地图还原为用户指定范围之外的静态地图。

参数配置,

7、costmap_params

导航功能使用两个代价地图来存储障碍物的信息。一个代价地图用于全局规划,这意味着在整个环境中创建全局规划路线,另一个用于局部规划和避障。这个两个代价地图有一些共同的配置,也有一些单独的配置。因此,代价地图配置有以下三个部分:通用配置、全局配置和局部配置。

7.1、costmap_common

代价地图公有参数配置costmap_common_params.yaml,

obstacle_range: 3.0
raytrace_range: 3.5

footprint: [[-0.117, -0.1], [-0.117, 0.1], [0.117, 0.1], [0.117, -0.1]]
#robot_radius: 0.105

# 膨胀半径
inflation_radius: 0.3
cost_scaling_factor: 3.0

map_type: costmap

obstacle_layer:
  # 使能障碍层
  enabled:              true
  # 最大障碍物高度
  max_obstacle_height:  2.0
  min_obstacle_height:  0.0
  combination_method:   1
  # true needed for disabling global path planning through unknown space
  track_unknown_space:  true
  # 机器人更新代价地图中的障碍物距离基坐标系的阈值。2.0
  # The robot updates the threshold of the obstacle distance from the base coordinate system in the cost map.
  obstacle_range: 3.0
  # 机器人清除代价地图中的障碍物距离基坐标系的阈值。3.0
  # The robot clears obstacles in the cost map from the threshold of the base coordinate system.
  raytrace_range: 3.5
  publish_voxel_map: false
  observation_sources:  scan
  scan:
    sensor_frame: laser
    data_type: LaserScan
    topic: "scan"
    marking: true
    clearing: true
    expected_update_rate: 0

#cost_scaling_factor and inflation_radius were now moved to the inflation_layer ns
inflation_layer:
  enabled:              true
  # exponential rate at which the obstacle cost drops off
  cost_scaling_factor:  1.0

static_layer:
  enabled:              true
  map_topic:            "/map"

7.2、loca_costmap

局部代价地图参数配置local_costmap_params.yaml,

local_costmap:
  # Coordinate frame and tf parameters
  # The "global_frame" parameter defines what coordinate frame the costmap should run in, in this case, we'll choose the /map frame.
  global_frame: odom
  # 机器人的基坐标系
  # The "robot_base_frame" parameter defines the coordinate frame the costmap should reference for the base of the robot.
  robot_base_frame: base_footprint
  # 指定可容忍的转换(tf)数据延迟(以秒为单位)。
  # Specifies the delay in transform (tf) data that is tolerable in seconds.
  transform_tolerance: 0.5
  # 代价地图更新的频率(以Hz为单位)。
  # The "update_frequency" parameter determines the frequency, in Hz, at which the costmap will run its update loop.
  update_frequency: 10.0
  # 代价地图发布可视化信息的速率(以Hz为单位)。
  # The rate at which the cost map publishes visual information
  publish_frequency: 10.0
  # 如果为true,则由map_server提供的地图服务来进行代价地图的初始化,否则为false。
  # If true, the map service provided by the map server will initialize the cost map, otherwise it will be false.
  static_map: false
  # 是否使用滚动窗口版本的costmap。如果static_map参数设置为true,则该参数必须设置为false。
  # Whether or not to use a rolling window version of the costmap.
  # If the static_map parameter is set to true, this parameter must be set to false.
  rolling_window: true
  # 代价地图宽度、高度、分辨率(米/单元格)
  # The "width," "height," and "resolution" parameters set the width (meters), height (meters), and resolution (meters/cell) of the costmap.
  width: 2.5
  height: 2.5
  resolution: 0.05
7.3、global_costmap

全局代价地图参数配置global_costmap_params.yaml,

global_costmap:
  # Coordinate frame and tf parameters
  # The "global_frame" parameter defines what coordinate frame the costmap should run in, in this case, we'll choose the /map frame.
  global_frame: map
  # 机器人的基坐标系
  # The "robot_base_frame" parameter defines the coordinate frame the costmap should reference for the base of the robot.
  robot_base_frame: base_footprint
  # 指定可容忍的转换(tf)数据延迟(以秒为单位)。
  # Specifies the delay in transform (tf) data that is tolerable in seconds.
  transform_tolerance: 0.5
  # 代价地图更新的频率(以Hz为单位),数值越大CPU负担越重,通常设定在1.0到5.0之间。
  # The "update_frequency" parameter determines the frequency, in Hz, at which the costmap will run its update loop.
  update_frequency: 10.0
  # 代价地图发布可视化信息的速率(以Hz为单位)。
  # The rate at which the cost map publishes visual information
  publish_frequency: 10.0
  # 如果为true,则由map_server提供的地图服务来进行代价地图的初始化,否则为false。
  # If true, the map service provided by the map server will initialize the cost map, otherwise it will be false.
  static_map: true
  # 代价地图分辨率(米/单元格)
  # Cost map resolution (m/cell)
  resolution: 0.05
  # 比例因子
  cost_scaling_factor: 10.0
  # 膨胀半径
  inflation_radius: 0.02
7.4、costmap_2D

1)、简介

costmap_2d这个包提供了一种2D代价地图的实现方案,该方案利用输入的传感器数据,构建数据2D或 者3D代价地图(取决于是否使用基于voxel的实现),并根据占用网格和用户定义的膨胀半径计算2D代价地图的代价。

  • 红色代表代价地图中的障碍物。

  • 蓝色表示机器人内接半径膨胀的障碍物

  • 红色多边形表示机器人的足迹。

  • 为了使机器人避免碰撞,机器人的外壳绝对不允许与红色单元格相交,机器人的中心点绝对不允许

    与蓝色单元格相交。

2)、topic

3)、参数配置

如果您不提供plugins参数,那么初始化代码将假定您的配置是pre-Hydro,默认名称空间是静态层(static_layer)、障碍层(obstacle_layer)和膨胀层(inflation_layer)。

插件:

  • plugins:一般使用默认即可。

坐标系与tf参数:

  • global_frame:代价地图运行的全局坐标系。
  • robot_base_frame:机器人base_link的坐标系名称。
  • transform_tolerance:指定可容忍的转换(tf)数据延迟(单位:s)。

速率参数:

  • update_frequency:更新地图的频率(单位:Hz)。
  • publish_frequency:发布显示信息的地图的频率(单位:Hz)。

地图管理参数:

  • rolling_window:是否使用代价地图的滚动窗口版本。如果static_map参数设置为true,则此参数必须设置为false。
  • always_send_full_costmap:如果为true,则每次更新都会将完整的costmap发布到"/costmap"。如果为false,则仅在“/costmap_updates”主题上发布已更改的costmap部分。

静态图层:

  • width:地图的宽度(单位:m)。
  • height:地图的高度(单位:m)。
  • resolution:地图分辨率(单位:m/cell)。
  • origin_x:全局框架中地图的x原点(单位:m)。
  • origin_y:全局框架中地图的y原点(单位:m)。

TF变换:

global_fram——>robot_base_frame

4)、图层规格

  • 静态层 static map layer:静态图层在代价地图中基本不变

    订阅的主题:

    • map:代价地图将向map_server发出服务调用以获取此映射。

    参数:

    • unknown_cost_value:从map server提供地图中读到这个值,其代价将被按unknown看待。值为零也会导致此参数未使用。

    • lethal_cost_threshold:从地图服务器读取地图时考虑致命的阈值。

    • map_topic:指定代价地图用来订阅静态地图的主题。

    • first_map_only:仅订阅地图话题上的第一条消息,忽略所有后续消息。

    • subscribe_to_updates:除map_topic外,还订阅map_topic + “_updates”。

    • track_unknown_space:如果为true,则地图消息中的未知值将直接转换到图层。否则,地图消息中的未知值将转换为层中的空闲空间。

    • use_maximum:只有当静态层不是底层时才重要。如果为true,则仅将最大值写入主成本图。

    • trinary_costmap:如果为true,则将所有地图消息值转换为NO_INFORMATION/FREE_SPACE/LETHAL_OBSTACLE(三个值)。如果为false,则可能出现完整的中间值范围

  • 障碍物层obstacle layer:障碍层跟踪传感器数据读取的障碍物。碰撞代价地图插件在二维中标记和光线跟踪障碍物,而VoxelCostmapPlugin 在三维中标记和光线跟踪障碍物。

  • 膨胀层inflation layer:在致命障碍物周围添加新值(即膨胀障碍物),以使代价地图表示机器人的配置空间。

  • 其他层:其他层可以通过pluginlib在代价地图中实现和使用。

5)、obstacle layer

障碍物层和体素层以点云或激光扫描的形式包含来自传感器的信息。障碍层在二维中跟踪,而体素层在三维中跟踪。

代价地图会自动订阅传感器主题并相应地更新。每个传感器用于标记(将障碍物信息插入代价地图)、清除(从代价地图中删除障碍物信息)。每次观察数据,清除操作从传感器原点向外通过网格执行光线跟踪。在体素层中,将每列中的障碍物信息向下投影到二维地图中。

订阅的话题,

传感器管理参数:

  • observation_sources:观测源名称列表,观测源中的每个源名称定义了一个命名空间,可以在其中设置参数

    • <source_name>/topic:传感器数据所涉及的话题。

    • <source_name>/sensor_frame:传感器。可以是sensor_msgs/LaserScan、sensor_msgs/PointCloud和sensor_msgs/PointCloud2。

    • <source_name>/observation_persistence:保持每个传感器读数的时间(单位:s)。值为0.0将仅保留最近的读数。

    • <source_name>/expected_update_rate:传感器读数的频率(单位:s)。值为0.0将允许读数之间有无限的时间间隔。

    • <source_name>/data_type:与话题关联的数据类型,目前仅支持“PointCloud”、PointCloud2”和“LaserScan”。

    • <source_name>/clearing:该观察值是否应该用来清除自由空间。

    • <source_name>/marking:该观察值是否应用于标记障碍物。

    • <source_name>/max_obstacle_height:被认为有效的传感器读数的最大高度(单位:m)。这通常设置为略高于机器人的高度。

    • <source_name>/min_obstacle_height:被认为有效的传感器读数的最小高度(单位:m)。这通常设置为地面高度,但可以根据传感器的噪声模型设置得更高或更低。

    • <source_name>/obstacle_range:使用传感器数据将障碍物插入成本图的最大范围(单位:m)。

    • <source_name>/raytrace_range:使用传感器数据从地图中光线追踪障碍物的最大范围(单位:m)。

    • <source_name>/inf_is_valid:允许在“激光扫描”观测信息中输入Inf值。Inf值转换为激光最大范围

全局滤波参数:这些参数适用于所有传感器:

  • max_obstacle_height:要插入代价地图的任何障碍物的最大高度(单位:m)。此参数应设置为略高于机器人的高度。
  • obstacle_range:将障碍物插入代价地图时与机器人的默认最大距离(单位:m)。这可能会在每个传感器的基础上过度使用。
  • raytrace_range:使用传感器数据从地图中光线追踪障碍物的默认范围(单位:m)。这可能会在每个传感器的基础上过度使用。

ObstacleCostmapPlugin:

  • track_unknown_space:如果为false,则每个像素具有两种状态之一:致命障碍或自由。如果为true,则每个像素具有三种状态之一:致命障碍、自由或未知。
  • footprint_clearing_enabled:如果为true,则机器人足迹将清除(标记为自由)其移动的空间。
  • combination_method:更改障碍层处理来自其以外层的传入数据的方式。可能的值有“覆盖” (0)、“最大值”(1)和“无”(99)。

VoxelCostmapPlugin:

  • origin_z:地图的z原点(单位:m)。
  • z_resolution:地图的z分辨率(单位:m/cell)。
  • z_voxels:每个垂直列中的体素数量,栅格高度为z_resolution * z_voxels
  • unknown_threshold:列中被认为“已知”的未知单元格数
  • mark_threshold:被视为“空闲”的列中允许的最大标记单元格数。
  • publish_voxel_map:是否为可视化目的发布基础体素栅格。
  • footprint_clearing_enabled:如果为true,则机器人足迹将清除(标记为自由)其移动的空间。

6)、Inflation Layer

膨胀代价值随着机器人离障碍物距离增加而减少。为代价地图的代价值定义5个与机器人有关的特定符号。

  • 致命的(“Lethal” cost):说明该单元格中有真实的障碍。若机器人的中心在该单元格中,机器人必然会跟障碍物相撞。
  • 内切(“Inscribed” cost):说明该单元格离障碍物的距离小于机器人内切圆半径。若机器人的中心位于等于或高于"Inscribed" cost的单元格,机器人必然会跟障碍物相撞。
  • 可能外切(“Possibly circumscribed” cost ):说明一个单元格离障碍物的距离小于机器人外切圆半径,但是大于内切圆半径。若机器人的中心位于等于或高于"Possibly circumscribed" cost 的单元格,机器不一定会跟障碍物相撞,其取决于机器人的方位。
  • 自由空间(“Freespace” ):没有任何东西可以阻止机器人去那里。
  • 未知(“Unknown”) : 未知空间。

参数:

  • inflation_radius:地图将障碍物代价值膨胀到的半径(单位:m)。
  • cost_scaling_factor:膨胀期间应用于代价值的比例因子。

8、planner_params

8.1、global_planner

nav_core::BaseGlobalPlanner为导航中使用的全局规划器提供接口。所有作为move_base节点插件编写的全局规划器都必须遵守此接口。关于NavaCys::BaseGoLBalPrimeNe:C++文档的文档可以在这里找到:BaseGlobalPlanner documentation。

全局路径规划插件:

  • navfn:基于栅格地图的全局规划器,使用导航功能时计算机器人的路径。实现了dijkstra和A*全局规划算法。(插件名:“navfn/NavfnROS”)
  • global_planner:重新实现了Dijkstra和A*全局路径规划算法,可以看作navfn的改进版。(插件名:“global_planner/GlobalPlanner”)
  • carrot_planner:一个简单的全局路径规划器,它获取用户指定的目标点,并尝试将机器人移动到尽可能靠近它的位置,即使目标点位于障碍物中。(插件名:“carrot_planner/CarrotPlanner”)

全局路径规划global_planner_params.y,

GlobalPlanner: 
	allow_unknown: false 
	default_tolerance: 0.2 
	visualize_potential: false 
	use_dijkstra: true 
	use_quadratic: true 
	use_grid_path: false 
	old_navfn_behavior: false 
	lethal_cost: 253 
	neutral_cost: 50 
	cost_factor: 3.0 
	publish_potential: true 
	orientation_mode: 0 
	orientation_window_size: 1

参数解析:

  • allow_unknown:是否选择探索未知区域。只设计该参数为true还不行,还要在costmap_commons_params.yaml中设置 track_unknown_space 必须同样设置为 true 。

  • default_tolerance:当设置的目的地被障碍物占据时,需要以该参数为半径寻找到最近的点作为新目的地点。

  • visualize_potential:是否显示从PointCloud2计算得到的可能的区域。

  • use_dijkstra:如果为true,则使用dijkstra算法。否则,A*。

  • use_quadratic:设置为true,将使用二次函数近似函数,否则使用更加简单的计算方式,这样节省硬件计算资源。

  • use_grid_path:如果为true,则创建沿栅格边界的路径。否则,使用梯度下降法,路径更为光滑

    点。

  • old_navfn_behavior:如果你想要让global_planner跟之前的navfn版本效果一样,就设true,所

    以不建议设置为true。

  • lethal_cost:障碍物致命区域的代价数值(可动态配置)。

  • neutral_cost:障碍物中等代价值(可动态配置)。

  • cost_factor:代价地图与每个代价值相乘的系数(可动态配置)。

  • publish_potential:是否发布可能的代价地图(可动态配置)。

  • orientation_mode:设置每个点的朝向。 (None=0, Forward=1, Interpolate=2,

    ForwardThenInterpolate=3, Backward=4, Leftward=5, Rightward=6)(可动态配置)。

  • orientation_window_size:根据定向方式指定的位置积分来得到使用窗口的方向;默认值1(可动

    态配置)。

  • outline_map:用致命的障碍勾勒出全局代价地图。对于非静态(滚动窗口)全局代价地图的使

    用,需要将其设置为false。

8.2、local_planner

nav_core::BaseLocalPlanner 为导航中使用的局部路径规划人员提供接口。所有作为move_base节点插件编写的局部路径规划器都必须遵守此接口。关于NavaCys::BaseLoCalPrnor的C++ API的文档可以在这里找到:BaseLocalPlanner documentation.

局部路径规划插件:

  • base_local_planner:实现了Trajectory Rollout和DWA两种局部规划算法。

  • dwa_local_planner :与base_local_planner的DWA相比,模块化DWA实现具有更清晰、更易于理

    解的界面和更灵活的y轴变量的优点。

  • teb_local_planner:实现用于在线轨迹优化的Timed-Elastic-Band方法。

  • eband_local_planner:Implements the Elastic Band method on the SE2 manifold仅适用于圆形、差速驱动、向前驱动(而不是向后)、全向的机器人。

  • mpc_local_planner:Provides several model predictive control approaches embedded in the

    SE2 manifold.

TEB与与DWA对比:

teb在运动过程中会调整自己的位姿朝向,当到达目标点时,通常机器人的朝向也是目标朝向而不需要旋转。dwa则是先到达目标坐标点,然后原地旋转到目标朝向。对于两轮差速底盘,teb在运动中调节朝向会使运动路径不流畅,在启动和将到达目标点时出现不必要的后退。这在某些应用场景里是不允许的。因为后退可能会碰到障碍物。而原地旋转到合适的朝向再径直走开是更为合适的运动策略。这也是teb需要根据场景要优化的地方。一般的,全向轮结构使用dwa,阿克曼结构的使用TEB。

本节针对DWA算法做出说明,

dwa_local_planner软件包支持任何机器人,其底盘可以表示为凸多边形或圆形。该软件包提供了一个控制器,在平面驱动机器人移动。该控制器将路径规划器连接到机器人。规划器使用地图为机器人创建从起点到目标位置的运动轨迹,发送给机器人的dx、dy、dtheta速度。

DWA算法的基本思想:

  • 机器人控制空间中的离散采样(dx、dy、dtheta)
  • 对于每个采样速度,从机器人的当前状态执行正向模拟,以预测如果采样速度应用一段(短)时间会发生什么。
  • 评估(评分)前方模拟产生的每条轨迹,使用包含以下特征的指标:接近障碍物、接近目标、接近全局路径和速度。丢弃非法轨迹(与障碍物碰撞的轨迹)。
  • 选择得分最高的轨迹,并将相关速度发送到移动机器人。
  • 清洗数据并重复。

可以设置大量ROS参数来自定义dwa_local_planner::DWAPlannerROS的行为。这些参数分为几个类别:机器人配置、目标容差、正向模拟、轨迹评分、振荡预防和全局规划。可以使用dynamic_reconfigure工具调试这些参数,以便于在运行的系统中调整局部路径规划器。

DWAPlannerROS:
  # Robot Configuration Parameters
  # x方向最大线速度绝对值,单位:米/秒
  # The maximum y velocity for the robot in m/s
  max_vel_x: 0.6
  # x方向最小线速度绝对值,负数代表可后退,单位:米/秒
  # The minimum x velocity for the robot in m/s, negative for backwards motion.
  min_vel_x: -0.6
  # y方向最大线速度绝对值,单位:米/秒。差速机器人为0 0.6
  # The maximum y velocity for the robot in m/s
  max_vel_y: 0.3
  # y方向最小线速度绝对值,单位:米/秒。差速驱动机器人为0 0.6
  # The minimum y velocity for the robot in m/s
  min_vel_y: -0.3
  # 机器人最大旋转速度的绝对值,单位为 rad/s 2.0
  # The absolute value of the maximum rotational velocity for the robot in rad/s
  max_rot_vel: 5.0
  # 机器人最小旋转速度的绝对值,单位为 rad/s 2.0
  # The absolute value of the minimum rotational velocity for the robot in rad/s
  min_rot_vel: 5.0
  # 机器人最大平移速度的绝对值,单位为 m/s
  # The absolute value of the maximum translational velocity for the robot in m/s
  max_vel_trans: 1.0
  # 机器人最小平移速度的绝对值,单位为 m/s 不可为零
  # The absolute value of the minimum translational velocity for the robot in m/s
  min_vel_trans: 0.01
  # 机器人被认属于“停止”状态时的平移速度。单位为 m/s
  # The translation speed when the robot is considered to be in the "stop" state in m/s.
  trans_stopped_vel: 0.1
  # 机器人的最大旋转角速度的绝对值,单位为 rad/s
  # The maximum rotational velocity limit of the robot in radians/sec^2
  max_vel_theta: 2.0
  # 器人的最小旋转角速度的绝对值,单位为 rad/s
  # The minimum rotational velocity limit of the robot in radians/sec^2
  min_vel_theta: 0.1
  # 机器人被认属于“停止”状态时的旋转速度。单位为 rad/s
  # The rotation speed of the robot when it is considered to be in the "stopped" state in m/s.
  theta_stopped_vel: 0.4
  # 机器人在x方向的极限加速度,单位为 meters/sec^2
  # The x acceleration limit of the robot in meters/sec^2
  acc_lim_x: 10.0
  # 机器人在y方向的极限加速度,差速机器人来说是0 10
  # The y acceleration limit of the robot in meters/sec^2
  acc_lim_y: 10.0
  # 机器人的极限旋转加速度,单位为 rad/sec^2
  # The rotational acceleration limit of the robot in radians/sec^2
  acc_lim_theta: 20.0

  # Goal Tolerance Parameters目标距离公差参数
  # 到达目标点时偏行角/旋转时的弧度允许的误差,单位弧度
  # The tolerance in radians for the controller in yaw/rotation when achieving its goal
  yaw_goal_tolerance: 0.1
  # 到达目标点时,在xy平面内与目标点的距离误差,单位:m.
  # The tolerance in meters for the controller in the x & y distance when achieving a goal
  xy_goal_tolerance: 0.1
  # 设置为true时表示:如果到达容错距离内,机器人就会原地旋转;即使转动是会跑出容错距离外。
  # If goal tolerance is latched, if the robot ever reaches the goal xy location it will simply rotate in place, even if it ends up outside the goal tolerance while it is doing so.
  latch_xy_goal_tolerance: false
  # Forward Simulation Parameters前向模拟参数
  # 前向模拟轨迹的时间,单位为s(seconds)
  # The amount of time to forward-simulate trajectories in seconds
  sim_time: 1.0
  # x方向速度空间的采样点数
  # The number of samples to use when exploring the x velocity space
  vx_samples: 10
  # y方向速度空间采样点数.。差分驱动机器人y方向永远只有1个值(0.0)
  # The number of samples to use when exploring the y velocity space
  vy_samples: 0
  # 旋转方向的速度空间采样点数
  # The number of samples to use when exploring the theta velocity space
  vtheta_samples: 10
  # 以 Hz 为单位调用此控制器的频率。
  # The frequency at which this controller will be called in Hz.
  controller_frequency: 10.0

  # Trajectory Scoring Parameters
  # 控制器与给定路径接近程度的权重
  # The weighting for how much the controller should stay close to the path it was given
  path_distance_bias: 10.0
  # 控制器与局部目标点的接近程度的权重,也用于速度控制
  # The weighting for how much the controller should attempt to reach its local goal, also controls speed
  goal_distance_bias: 20.0
  # 控制器躲避障碍物的程度
  # The weighting for how much the controller should attempt to avoid obstacles
  occdist_scale: 0.5
  # 以机器人为中心,额外放置一个计分点的距离
  # The distance from the center point of the robot to place an additional scoring point, in meters
  forward_point_distance: 0.325
  # 机器人在碰撞发生前必须拥有的最少时间量。该时间内所采用的轨迹仍视为有效。
  # The amount of time that the robot must stop before a collision in order for a trajectory to be considered valid in seconds
  stop_time_buffer: 0.1
  # 开始缩放机器人足迹时的速度的绝对值,单位为m/s。
  # The absolute value of the velocity at which to start scaling the robot's footprint,
  scaling_speed: 0.25
  # 最大缩放因子。max_scaling_factor为上式的值的大小。
  # The maximum factor to scale the robot's footprint by
  max_scaling_factor: 0.2

  # Oscillation Prevention Parameters
  # 机器人必须运动多少米远后才能复位震荡标记(机器人运动多远距离才会重置振荡标记)
  # How far the robot must travel in meters before oscillation flags are reset
  oscillation_reset_dist: 0.05
  oscillation_reset_angle: 0.05

  # Debugging调试参数
  # 将规划的轨迹在RVIZ上进行可视化
  publish_traj_pc: true
  # 将代价值进行可视化显示
  publish_cost_grid_pc: true
  # 全局参考坐标系
  global_frame_id: /map

9、AMCL

9.1、简介

amcl的英文全称是adaptive Monte Carlo localization,是一种二维移动机器人的概率定位系统。其实就是蒙特卡洛定位方法的一种升级版,使用自适应的KLD方法来更新粒子,使用粒子过滤器根据已知地图跟踪机器人的姿势。按照目前的实施,该节点仅适用于激光扫描和激光地图。它可以扩展到处理其他传感器数据。amcl接收基于激光的地图、激光扫描和变换信息,并输出姿势估计。启动时,amcl根据提供的参数初始化其粒子过滤器。请注意,由于默认设置,如果未设置任何参数,则初始过滤器状态将是以(0,0,0)为中心的中等大小的粒子云。

amcl(蒙特卡洛定位)法使用的是粒子滤波的方法来进行定位的。举例说明粒子滤波:首先在平面地图上均匀的撒一把粒子,然后向前移动机器人移动了一米,所有的粒子也跟随机器人向前移动一米。使用每个粒子所处位置模拟一个传感器信息跟观察到的传感器信息(一般是激光)作对比,从而赋给每个粒子一个概率。之后根据生成的概率来重新生成粒子,概率越高的生成的概率越大。这样的迭代之后,所有的粒子会慢慢地收敛到一起,机器人的确切位置也就被推算出来了。

9.2、话题与服务

9.3、参数配置

有三类ROS参数可用于配置amcl节点:整体过滤器、激光模型和里程计模型。

1)、整体过滤器参数

2)、激光模型参数

3)、里程计模型参数

本文标签: navigation