andle(), "move_base", boost::bind(&MoveBase::executeCb, this, _1), false);
planner_thread_ = new boost::thread(boost::bind(&MoveBase::planThread, this));
每次有goal发布的时候,都会去调用executeCb
,executeCb
会去调用executeCycle
进行local plan,发布cmd_vel的topic,根据小车处于的状态,进行相应的实现(会进行plan,control,clear obstacle)
API
- 提供两种方式
send goal
目标位置的信息
- SimpleActionServer(可以追踪移动到目标过程的状态信息,到了没有,是不是没有plan,取消了etc)
- Subscribe topic(move_base_simple/goal),直接发布这个topic的信息,不会有目标执行过程中的反馈信息
- 提供的
service
- ~make_plan(只会提供plan该怎么走的位置信息,不会使机器人移动)
- ~clear_unknown_space(告诉move_base清楚机器人周围的unknown space)
- ~clear_costmaps(告诉move_base清楚costmap中的障碍物信息,可能导致撞到障碍物)
nav_core
ROS wiki
代码文档
提供三类接口(这些接口都是以plugin的形式存在,很容易更换):
- BaseGlobalPlanner
- BaseLocalPlanner
- RecoveryBehavior
BaseGlobalPlanner
所有的global planner
都必须实现nav_core::BaseGlobalPlanner
定义的接口(纯续函数)
主要实现的函数定义如下:
virtual void initialize (std::string name, costmap_2d::Costmap2DROS *costmap_ros)=0
virtual bool makePlan (const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, std::vector< geometry_msgs::PoseStamped > &plan)=0
BaseLocalPlanner
所有的local planner
都必须实现nav_core::BaseLocalPlanner
定义的接口(纯续函数)
主要实现的函数定义如下:
#Given the current position, orientation, and velocity of the robot, compute velocity commands to send to the base
virtual bool computeVelocityCommands (geometry_msgs::Twist &cmd_vel)=0
virtual void initialize (std::string name, tf::TransformListener *tf, costmap_2d::Costmap2DROS *costmap_ros)=0
virtual bool isGoalReached ()=0
virtual bool setPlan (const std::vector< geometry_msgs::PoseStamped > &plan)=0
RecoveryBehavior
所有的recovery behaviors
都必须实现nav_core::RecoveryBehavior
定义的接口(纯续函数)
主要实现的函数定义如下:
virtual void initialize (std::string name, tf::TransformListener *tf, costmap_2d::Costmap2DROS *global_costmap, costmap_2d::Costmap2DROS *local_costmap)=0
virtual void runBehavior ()=0
Recovery behavior
首先, obstacles outside of a user-specified region will be cleared from the robot's map.(conservative_reset_dist
半径之外的非NO_INFORMATION
都会被设置成NO_INFORMATION
)。然后, if possible, the robot will perform an in-place rotation to clear out space. If this too fails, 再然后,
the robot will more aggressively clear its map, removing all obstacles outside of the rectangular region in
which it can rotate in place.(默认是4倍的最小外接圆半径) This will be followed by another in-place rotation. If all this fails,
the robot will consider its goal infeasible and notify the user that it has aborted
插件的配置
~recovery_behaviors
(list, default: [{name: conservative_reset, type: clear_costmap_recovery/ClearCostmapRecovery},
{name: rotate_recovery, type: rotate_recovery/RotateRecovery},
{name: aggressive_reset, type: clear_costmap_recovery/ClearCostmapRecovery}]
参数
#The distance away from the robot in meters at which obstacles will be cleared from the costmap when attempting to clear space in the map.
~conservative_reset_dist (double, default: 3.0)
#Whether or not to enable the move_base recovery behaviors to attempt to clear out space.
~recovery_behavior_enabled (bool, default: true)
#Determines whether or