ROS导航系列(一):move_base的心脏——nav_core

1. nav_core

nav_core功能包中包括navigation_stack的关键接口。所有的路径规划算法和恢复行为都使用插件形式继承这些接口来实现的。
在这里插入图片描述

后续几章会重点详解GlobalPlanner和LocalPlanner.

2. BaseGlobalPlanner API

nav_core::BaseGlobalPlanner 微导航提供全局路径规划接口。所有的路径规划算法都会写成move_base节点的插件,这些插件都要继承于这个接口。接下来详细说下接口。

 #ifndef NAV_CORE_BASE_GLOBAL_PLANNER_H
 #define NAV_CORE_BASE_GLOBAL_PLANNER_H
  
 #include <geometry_msgs/PoseStamped.h>
 #include <costmap_2d/costmap_2d_ros.h>
  
 namespace nav_core {
   class BaseGlobalPlanner{
     public:
       virtual bool makePlan(const geometry_msgs::PoseStamped& start, 
           const geometry_msgs::PoseStamped& goal, std::vector<geometry_msgs::PoseStamped>& plan) = 0;
  
       virtual bool makePlan(const geometry_msgs::PoseStamped& start, 
                             const geometry_msgs::PoseStamped& goal, std::vector<geometry_msgs::PoseStamped>& plan,
                             double& cost)
       {
         cost = 0;
         return makePlan(start, goal, plan);
       }
  
       virtual void initialize(std::string name, costmap_2d::Costmap2DROS* costmap_ros) = 0;
  
       virtual ~BaseGlobalPlanner(){}
  
     protected:
       BaseGlobalPlanner(){}
   };
 };  // namespace nav_core
  
 #endif  // NAV_CORE_BASE_GLOBAL_PLANNER_H

3. BaseLocalPlanner API

 #ifndef NAV_CORE_BASE_LOCAL_PLANNER_H
 #define NAV_CORE_BASE_LOCAL_PLANNER_H
  
 #include <geometry_msgs/PoseStamped.h>
 #include <geometry_msgs/Twist.h>
 #include <costmap_2d/costmap_2d_ros.h>
 #include <tf2_ros/buffer.h>
  
 namespace nav_core {
   class BaseLocalPlanner{
     public:
     // 给定机器人位置朝向和速度,求传到底盘的速度指令
       virtual bool computeVelocityCommands(geometry_msgs::Twist& cmd_vel) = 0;
  
       virtual bool isGoalReached() = 0;
       
  	// 设置局部planner要跟随的轨迹(与全局路径规划的联系)
       virtual bool setPlan(const std::vector<geometry_msgs::PoseStamped>& plan) = 0;
  
  // tf: tf_listener的指针
       virtual void initialize(std::string name, tf2_ros::Buffer* tf, costmap_2d::Costmap2DROS* costmap_ros) = 0;
  
       virtual ~BaseLocalPlanner(){}
  
     protected:
       BaseLocalPlanner(){}
   };
 };  // namespace nav_core
  
 #endif  // NAV_CORE_BASE_LOCAL_PLANNER_H

4. 分析

  • 全局路径规划不需要tf,直接给定start和goal,输出plan即可
  • 局部路径规划需要依赖全局路径规划输出的plan,同时依赖tf,最终输出速度指令交给底盘进行控制
  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值