ROS导航包中的costmap的一些参数理解

costmap是一个package,用在move_base的global_map和local_map当中。用于将laser扫面数据或者点云数据转化成一个2d的网格地图

1.总览

简单来说,地图中分成几部分

灰色部分:安全区域,robot运动在该区域不会发生碰撞

红色部分:危险区域,robot的footprint覆盖到该色网格就肯定会发生碰撞

蓝色部分:风险区域,robot在该区域有可能发生碰撞

红色几何型:robot在地图中所占的区域

ROS导航包中的costmap的一些参数理解

2.两个操作

costmap订阅传感器发布的主题数据并更新自身地图,其中有两个操作

marking:标识该区域为障碍信息

clearing:清除该区域的障碍信息

3.网格的三种状态

每个网格会被赋予一个0~254之间的值,代表三种不同的状态

occupied:占有,unknow:未知,free:空闲。

4.地图更新和tf

costmap根据update frequency参数定期来更新地图。每个周期内,根据传感器信息mark/clear地图中的网格。

costmap更新构造地图,默认情况是,global_frame(/map)和 robot_base_frame(/base_link)和他们之间的frame都是连接的,并且定期更新的。如果tf没有按照定期的频率来更新,那navigation stack将会停止robot的运动。

5.网格的赋值

赋值范围为0~254

ROS导航包中的costmap的一些参数理解

lethal:值为254,传感器扫描到的实际障碍转化成map中的lethal网格。

inscribed :内部半径,如果网格和lethal网格距离小于等于该半径,则为inscribed网格,值为253。取robot几何型所能容纳最大的圆的半径。

被标记为253~254的网格是障碍网格,也就是lethal和inscribed网格是障碍网格。当robot的边界覆盖到这两种网格时,一定会发生碰撞。

possibly circumscribed:膨胀半径,以robot的中心为园点旋转一周所能覆盖的最大圆半径,如果所在网格距离lethal小于等于膨胀半径,大于内部半径,则为possibly circumscribed网格。值为128~252,取决与robot的运动方向和轨迹,还有算法。当robot的边界覆盖到这种网格时,可能会发生碰撞。

free:值为0,说明没有任何信息可以阻碍机器人运行到这里。

unkonw:没有任何信息,传感器还没有扫描到该区域,都是障碍网格

1~127:不会发生碰撞的区域,这里的值赋值取决于与lethal的距离,还有用户自定义的算法

6.地图类型

第一种:指定地图,地图里面有长,宽和障碍信息,通常也会有一个定位系统,例如amcl

第二种 : 没有指定地图,保持robot始终在地图的中心位置,随着robot的运动不断构建地图

7.API

订阅的主题:

~<name>/footprint (geometry_msgs/Polygon):Specification for the footprint of the robot. This replaces the previous parameter specification of the footprint.
发布的主题
~<name>/grid (nav_msgs/OccupancyGrid):The values in the costmap
~<name>/grid_updates (map_msgs/OccupancyGridUpdate):The value of the updated area of the costmap
~<name>/voxel_grid (costmap_2d/VoxelGrid):Optionally advertised when the underlying occupancy grid uses voxels and the user requests the voxel grid be published.
参数
Plugins
~<name>/plugins (sequence, default: pre-Hydro behavior):Sequence of plugin specifications, one per layer. Each specification is a dictionary with name and type fields. The name is used to define the parameter namespace for the plugin. See the tutorials for examples.
Coordinate frame and tf parameters
~<name>/global_frame (string, default: "/map"):The global frame for the costmap to operate in.
~<name>/robot_base_frame (string, default: "base_link"):The name of the frame for the base link of the robot.
~<name>/transform_tolerance (double, default: 0.2):Specifies the delay in transform (tf) data that is tolerable in seconds. This parameter serves as a safeguard to losing a link in the tf tree while still allowing an amount of latency the user is comfortable with to exist in the system. For example, a transform being 0.2 seconds out-of-date may be tolerable, but a transform being 8 seconds out of date is not. If the tf transform between the coordinate frames specified by the global_frame and robot_base_frame parameters is transform_tolerance seconds older than ros::Time::now(), then the navigation stack will stop the robot.
Rate parameters
~<name>/update_frequency (double, default: 5.0):The frequency in Hz for the map to be updated.
~<name>/publish_frequency (double, default: 0.0):The frequency in Hz for the map to be publish display information.
Map management parameters
~<name>/rolling_window (bool, default: 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.
~<name>/always_send_full_costmap (bool, default: false):If true the full costmap is published to "~<name>/grid" every update. If false only the part of the costmap that has changed is published on the "~<name>/grid_updates" topic.
The following parameters can be overwritten by some layers, namely the static map layer.
~<name>/width (int, default: 10):The width of the map in meters.
~<name>/height (int, default: 10):The height of the map in meters.
~<name>/resolution (double, default: 0.05):The resolution of the map in meters/cell.
~<name>/origin_x (double, default: 0.0):The x origin of the map in the global frame in meters.
~<name>/origin_y (double, default: 0.0):The y origin of the map in the global frame in meters.

8.需要tf 转换
(value of global_frame parameter) → (value of robot_base_frame parameter)
Usually provided by a node responsible for odometry or localization such as amcl.


9.地图上的层规范

9.1 static map layer

静态地图层,通过slam算法生成的地图,不可改变,不包括动态或静态障碍

9.2 Obstacle Map Layer

障碍地图层,通过传感器数据识别出非固定地图的障碍,包括动态,静态障碍

9.3 Inflation Layer

膨胀层,根据inflation半径计算出的robot所占的可能最大面积,可选的,

9.4 other layer

通过插件可以增加其他的层结构

参考链接:http://wiki.ros.org/costmap_2d