上一讲讨论了输出输出以及相关参数含义,这一讲,先梳理这个包的头文件。

头文件夹分为两大块:ExplorationPlannerROS文件夹和 ExplorationPlanner文件夹。

先从ROS集成的文件夹:ExplorationPlannerROS文件夹开始讲起。

ExplorationPlannerROS

1.输入通过topic主题订阅:costmap 和 global map

1>输入

从move_base包订阅获得的costmap以及从SLAM建图包(比如:gmapping包)订阅获得的global map

//costmap
ros::Subscriber costmap_sub_;
ros::Subscriber costmap_update_sub_;

//global map
ros::Subscriber global_map_sub_;

2>订阅costmap和global map 的原因说明

我们从move_base包订阅到costmap,这个costmap用于检查轨迹的合理性。

// subscribe to a costmap from move_base:
// costmap is used to check validity of trajectories

ros::Subscriber costmap_sub_;
ros::Subscriber costmap_update_sub_;
boost::mutex costmap_lock_;
void costmapCb(const nav_msgs::OccupancyGrid &map);
void costmapUpdateCb(const map_msgs::OccupancyGridUpdate &map_update);
boost::shared_ptr<PlanarGridBinaryMap> trajectorycheck_map_;

我们从经典SLAM建图包,比如说:gmapping包,订阅到global map,这个地图用于去plan和模拟observations。

// subscribe to a global map, e.g. from SLAM.
// this map is used to plan and simulate observations.

ros::Subscriber global_map_sub_;
boost::mutex global_map_lock_;
void globalmapCb(const nav_msgs::OccupancyGrid &map);
PlanarGridOccupancyMap global_map_;

总结:costmap用来描述机器人被允许或者不允许在哪里可以规划路径,而global map用来描述机器人相对于当前环境的信息。我们在使用costmap时,不仅需要去订阅costmap本身,而且也要订阅它的更新。

3>costmap 和 global map 消息类型说明

#include <nav_msgs/OccupancyGrid.h>
#include <map_msgs/OccupancyGridUpdate.h>

看到这两个引用的头文件,就知道大概是跟占据栅格有关的东西。事实上,引用这两个消息类型,是为了订阅两种不同类型的map:costmap 和 global map。

3.1>示例costmap的两种消息类型:

1.nav_msgs/OccupancyGrid

//This msg of costmap describing where the robot is allowed to plan paths to
//All values less than or equal to 98 are interpreted as allow for planning.
//For controlling behaviour in unknown areas,see the parameter allow_unknow_targets.

 nav_msgs::OccupancyGrid 

这个消息类型,是costmap用于描述机器人被允许去规划路径的地方的message。当所有的值<=98就视为可以允许规划。为了控制未知区域的行为,可以参考参数:

allow_unknow_targtes,在上一讲中可以找到。

2.map_msgs/OccupancyGridUpdates

//This msg containing updates to partial areas in the global costmap.
 
 map_msgs::OccupancyGridUpdates

这个消息类型包含在costmap里局部地区的更新。

3.2>示例global map的消息类型:

nav_msgs/OccupancyGrid

//This msg containing a global map.This can be produced by a SLAM algorithm.
//This map is used at each planning stage as staring information.
//This map should be updated to reflect exploration progress.

 nav_msgs::OccupancyGrid

2.输出通过topic主题发布:Path

//publish the paths considered by the planner at each iteration
ros::Publisher path_pub_;
void publishPath(const std::vector<PlanarPose>& p);

3.过程原理

论文:P28/43如此描述:

论文链接:

4.过程具体实现:使用action消息类型和sevice服务

输入:costmap和global map,过程:planner(规划器)发布explore targets,move_base包将其作为navigation goals ,输出:planner(规划器)发布的路径。

explore节点 作为服务端,move_base节点作为客户端

1>服务端explore 节点

使用action类型:Explore.action,作为信息载体:一个空的goal,一个空的result,以及一个feedback。

该feedback将会输出由planner产生的当前的exploration target。

我们可以通过这个action来进行一个探索任务,planner将会产生exploration targets直到出现错误或者我们想要取消这个action;

//Explore.action
#goal definition
---
#result definition
---
#feedback
geometry_msgs/PoseStamped current_target

2>客户端movebase节点

使用acion类型:move_base_msgs/MoveBase.action,作为信息载体:一个target_pose,两个为空的参数,一个base_position

exploration targets已经被planner产生,它将被作为navigation goals发送到move_base包。

geometry_msgs/PoseStamped target_pose
---
---
geometry_msgs/PoseStamped base_position

ROS wiki 关于move_base_msgs的介绍,参考:

5.探索任务的state(状态):

// state of exploration task
bool moving_;//移动
bool possibly_stuck_;//机器人可能被困住
bool goal_is_frontier_;//目标在边界
ros::Time goal_time_;

6.planner(规划器):

// tools used by the planner
boost::shared_ptr<TrajectoryGenerator> trajgenerator_;//生成轨迹
boost::shared_ptr<TrajectoryEvaluator> trajevaluator_;//评价轨迹
void updateTrajectoryGenerator();//更新生成轨迹函数
void updateTrajectoryEvaluator();//更新评价轨迹函数
//SMC planner
std::unique_ptr<SMCPlanner> buildPlanner() const;//SMC planner

论文:P35/43:提到SMC planner能表现得像人遥控操作建图一样完美当使用一个a long optimization horizon。

6.参数相关:

见上一讲:

7.总结

以上就是ExplorationPlannerROS的头文件源码的相关说明了。

下一讲见:

Churlaaaaaaa:6.gmapping建图拓展篇:ase_exploration包| 源码梳理(二)