ROS Move Base恢复机制

本文解析了movebase在规划路径、控制运动和障碍清除状态下的恢复机制,重点介绍三种终止方式及如何通过参数调整。了解了当机器人遇到震荡、规划超时和控制失败时的应对策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、什么情况下启动恢复机制

movebase的三种状态:

enum MoveBaseState {
  PLANNING,//在规划路径中
  CONTROLLING,//在控制机器人运动中
  CLEARING//规划或者控制失败在恢复或者清除中。
};


一般默认状态或者接收到一个有效goal时是PLANNING,在规划出全局路径后state_会由PLANNING->CONTROLLING,如果规划失败则由PLANNING->CLEARING。在MoveBase::executeCycle中,会分别对这三种状态做处理:

还在PLANNING中则唤醒规划线程让它干活
如果已经在CONTROLLING中,判断是否已经到达目的地,否则判断是否出现震动?否则调用局部路径规划,如果成功得到速度则直接发布到cmd_vel,失败则判断是否控制超时,不超时的话让全局再规划一个路径。
如果出现了问题需要CLEARING(仅有全局规划失败、局部规划失败、长时间困在一片小区域三种原因),则每次尝试一种recovery方法,直到所有尝试完
movebase为recovery行为定义了如下三种原因

enum RecoveryTrigger
{
  PLANNING_R,//全局规划失败
  CONTROLLING_R,//局部规划失败
  OSCILLATION_R//长时间困在一片小区域
};

以下三种情况,开始clearing

(1)

        //check for an oscillation condition

        if(oscillation_timeout_ > 0.0 &&

            last_oscillation_reset_ + ros::Duration(oscillation_timeout_) < ros::Time::now())

        {

          publishZeroVelocity();

          state_ = CLEARING;

          recovery_trigger_ = OSCILLATION_R;

        }

(2)

//check if we've tried to make a plan for over our time limit or our maximum number of retries

 //issue #496: we stop planning when one of the conditions is true, but if max_planning_retries_

        //is negative (the default), it is just ignored and we have the same behavior as ever

        lock.lock();

        planning_retries_++;

        if(runPlanner_ &&

           (ros::Time::now() > attempt_end || planning_retries_ > uint32_t(max_planning_retries_))){

          //we'll move into our obstacle clearing mode

          state_ = CLEARING;

          runPlanner_ = false;  // proper solution for issue #523

          publishZeroVelocity();

          recovery_trigger_ = PLANNING_R;

        }

(3)

          //check if we've tried to find a valid control for longer than our time limit

          if(ros::Time::now() > attempt_end){

            //we'll move into our obstacle clearing mode

            publishZeroVelocity();

            state_ = CLEARING;

            recovery_trigger_ = CONTROLLING_R;

          }

2、恢复机制有哪些?

三种终止方式

if(recovery_trigger_ == CONTROLLING_R){

            ROS_ERROR("Aborting because a valid control could not be found. Even after executing all recovery behaviors");

            as_->setAborted(move_base_msgs::MoveBaseResult(), "Failed to find a valid control. Even after executing recovery behaviors.");

          }

          else if(recovery_trigger_ == PLANNING_R){

            ROS_ERROR("Aborting because a valid plan could not be found. Even after executing all recovery behaviors");

            as_->setAborted(move_base_msgs::MoveBaseResult(), "Failed to find a valid plan. Even after executing recovery behaviors.");

          }

          else if(recovery_trigger_ == OSCILLATION_R){

            ROS_ERROR("Aborting because the robot appears to be oscillating over and over. Even after executing all recovery behaviors");

            as_->setAborted(move_base_msgs::MoveBaseResult(), "Robot is oscillating. Even after executing recovery behaviors.");

          }

3、如果通过调整参数调整恢复机制

震荡时间与距离

    private_nh.param("oscillation_timeout", oscillation_timeout_, 0.0);

    private_nh.param("oscillation_distance", oscillation_distance_, 0.5);

路径规划等待时间

private_nh.param("planner_patience", planner_patience_, 5.0);

### ROS MoveBase 插件或扩展 对于导航堆栈自定义,`MoveBase` 提供了多种插件接口来增强其功能。这些插件允许开发者针对特定应用需求调整路径规划、局部避障以及全局地图管理等功能。 #### 路径规划器 (Global Planner) 为了实现更复杂的路径规划逻辑,可以开发新的全局路径规划器插件。这类插件通常继承 `nav_core::BaseGlobalPlanner` 接口并重写相应方法[^1]: ```cpp class CustomGlobalPlanner : public nav_core::BaseGlobalPlanner { public: bool makePlan(const geometry_msgs::PoseStamped& start, const geometry_msgs::PoseStamped& goal, std::vector<geometry_msgs::PoseStamped>& plan); }; ``` #### 局部避障控制器 (Local Planner) 通过创建自定义局部避障算法,能够提高机器人在动态环境中的适应能力。此类插件需遵循 `nav_core::BaseLocalPlanner` 定义的行为模式: ```cpp class CustomLocalPlanner : public nav_core::BaseLocalPlanner { public: bool computeVelocityCommands(geometry_msgs::Twist& cmd_vel); }; ``` #### 成本映射层 (Costmap Layer) 成本映射是移动基座决策过程的重要组成部分之一。新增的成本映射层可以帮助处理特殊传感器输入或是引入额外的空间约束条件。这涉及到实现 `costmap_2d::Layer` 类及其子类的方法: ```cpp class CustomCostmapLayer : public costmap_2d::Layer { protected: void onInitialize(); void updateBounds(double robot_x, double robot_y, double robot_yaw, double* min_x, double* min_y, double* max_x, double* max_y); void updateCosts(costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j); }; ``` 上述组件构成了完整的 `move_base` 自定义化框架,使得研究人员和工程师可以根据实际应用场景灵活配置机器人的行为特性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值