@danren-aa120
2021-04-23T00:39:05.000000Z
字数 3222
阅读 366
ROS
与move_base.cpp中的bool MoveBase::loadRecoveryBehaviors(ros::NodeHandle node)和void MoveBase::loadDefaultRecoveryBehaviors()有关。
一、class RotateRecovery,rotate_recovery功能包。关于rotate_recovery.h和rotate_recovery.cpp。
该包给导航功能包提供了rotate_recovery::RotateRecovery修复机制,它尝试让机器人执行360度旋转来完成清理导航功能包里的代价地图的空间。**
1.void initialize(std::string name, tf2_ros::Buffer*,
costmap_2d::Costmap2DROS*, costmap_2d::Costmap2DROS* local_costmap)
1)ros::NodeHandle private_nh("~/" + name);
ros::NodeHandle blp_nh("~/TrajectoryPlannerROS");//NodeHandle类在哪个命名空间中
ROS学习之源码——NodeHandle:https://blog.csdn.net/wanzew/article/details/80014029
https://blog.csdn.net/weixin_30802171/article/details/95162842;
ROS NodeHandle 命名空间 参数读取https://blog.csdn.net/i_robots/article/details/107508346
rotate_recovery::RotateRecovery对象假定move_base node使用的局部规划器是base_local_planner::TrajectoryPlannerROS。
以下是创建rotate_recovery::RotateRecovery对象的示例:
#include <tf/transform_listener.h>
#include <costmap_2d/costmap_2d_ros.h>
#include <rotate_recovery/rotate_recovery.h>
...
tf::TransformListener tf(ros::Duration(10));
costmap_2d::Costmap2DROS global_costmap("global_costmap", tf);
costmap_2d::Costmap2DROS local_costmap("local_costmap", tf);
rotate_recovery::RotateRecovery rr;
rr.initialize("my_rotate_recovery", &tf, &global_costmap, &local_costmap);
rr.runBehavior();
RotateRecovery Parameters
~/sim_granularity (double, default: 0.017)
The distance in radians between checks for obstacles when checking if an in-place rotation is safe. Defaults to 1 degree.
~/frequency (double, default: 20.0)
The frequency in HZ at which to send velocity commands to the mobile base.
TrajectoryPlannerROS Parameters
这些参数在base_local_planner::TrajectoryPlannerROS局部规划器已经配置过, 只有当导航功能包集中的其它局部规划器被rotate_recovery::RotateRecovery使用时才有必要设置。
~TrajectoryPlannerROS/yaw_goal_tolerance (double, default: 0.05)
The tolerance in radians for the controller in yaw/rotation when achieving its goal
~TrajectoryPlannerROS/acc_lim_th (double, default: 3.2)
The rotational acceleration limit of the robot in radians/sec^2
~TrajectoryPlannerROS/max_rotational_vel (double, default: 1.0)
The maximum rotational velocity allowed for the base in radians/sec
~TrajectoryPlannerROS/min_in_place_rotational_vel (double, default: 0.4)
The minimum rotational velocity allowed for the base while performing in-place rotations in radians/sec
2)只用局部local_costmap;
3) world_model_ = new base_local_planner::CostmapModel(*local_costmap_->getCostmap());//new其实就是告诉计算机开辟一段新的空间,但是和一般的声明不同的是,new开辟的空间在堆上,而一般声明的变量存放在栈上。
堆栈空间分配区别:
栈(操作系统):bai由操作系统自du动分配释放 ,存放函数zhi的参数值,局部变量的值等。其操作方式类似于数据结构中的栈;
堆(操作系统): 一般由程序员分配释放, 若程序员不释放,程序结束时可能由OS回收,分配方式倒是类似于链表。
堆栈缓存方式区别:
栈使用的是一级缓存, 他们通常都是被调用时处于存储空间中,调用完毕立即释放;
堆是存放在二级缓存中,生命周期由虚拟机的垃圾回收算法来决定(并不是一旦成为孤儿对象就能被回收)。所以调用这些对象的速度要相对来得低一些。
堆栈数据结构区别:
堆(数据结构):堆可以被看成是一棵树,如:堆排序;
栈(数据结构):一种先进后出的数据结构。
2. void RotateRecovery::runBehavior()
// make sure that the point is legal, if it isn't... we'll abort
//footprintCost returns:
// -1 if footprint covers at least a lethal obstacle cell, or
// -2 if footprint covers at least a no-information cell, or
// -3 if footprint is [partially] outside of the map, or
// a positive value for traversable space
double footprint_cost = world_model_->footprintCost(x, y, theta, local_costmap_->getRobotFootprint(), 0.0, 0.0);