局部规划器-TebLocalPlannerROS

本文链接地址: 局部规划器-TebLocalPlannerROS

Content:

  1. 局部规划器初始化
  2. 计算速度命令
  3. 规划逻辑
  4. 构建图并优化
  5. 计算速度


由于Teb算法能很好的支持阿克曼小车,这儿使用TebLocalPlannerROS进行局部规划
在Move Base初始化中通过参数指定base_local_planner为teb_local_planner/TebLocalPlannerROS

    private_nh.param("base_local_planner", local_planner, std::string("base_local_planner/TrajectoryPlannerROS"));
 
    //create a local planner
    try {
      tc_ = blp_loader_.createInstance(local_planner);
      ROS_INFO("Created local_planner %s", local_planner.c_str());
      tc_->initialize(blp_loader_.getName(local_planner), &tf_, controller_costmap_ros_);
    } catch (const pluginlib::PluginlibException& ex) {
      ROS_FATAL("Failed to create the %s planner, are you sure it is properly registered and that the containing library is built? Exception: %s", local_planner.c_str(), ex.what());
      exit(1);
    }

Move Base中通过调用tc_->computeVelocityCommands(cmd_vel)完成速度命令计算。

局部规划器初始化

void TebLocalPlannerROS::initialize(std::string name, tf2_ros::Buffer* tf, costmap_2d::Costmap2DROS* costmap_ros)
{
  // check if the plugin is already initialized
  if(!initialized_)
  {	
    // create Node Handle with name of plugin (as used in move_base for loading)
    ros::NodeHandle nh("~/" + name);
 
    // get parameters of TebConfig via the nodehandle and override the default config
    cfg_.loadRosParamFromNodeHandle(nh);       
 
    // reserve some memory for obstacles
    obstacles_.reserve(500);
 
    // create visualization instance	
    visualization_ = TebVisualizationPtr(new TebVisualization(nh, cfg_)); 
//获取小车的参数,这些参数将用于模型优化,路径计算,比如阿克曼小车的最小转弯半径        
    // create robot footprint/contour model for optimization
    RobotFootprintModelPtr robot_model = getRobotFootprintFromParamServer(nh);
//这儿我们解读TebOptimalPlanner分支    
    // create the planner instance
    if (cfg_.hcp.enable_homotopy_class_planning)
    {
      planner_ = PlannerInterfacePtr(new HomotopyClassPlanner(cfg_, &obstacles_, robot_model, visualization_, &via_points_));
      ROS_INFO("Parallel planning in distinctive topologies enabled.");
    }
    else
    {
      planner_ = PlannerInterfacePtr(new TebOptimalPlanner(cfg_, &obstacles_, robot_model, visualization_, &via_points_));
      ROS_INFO("Parallel planning in distinctive topologies disabled.");
    }
 
    // init other variables
    tf_ = tf;
    costmap_ros_ = costmap_ros;
    costmap_ = costmap_ros_->getCostmap(); // locking should be done in MoveBase.
 
    costmap_model_ = boost::make_shared(*costmap_);
 
    global_frame_ = costmap_ros_->getGlobalFrameID();
    cfg_.map_frame = global_frame_; // TODO
    robot_base_frame_ = costmap_ros_->getBaseFrameID();
 
    //Initialize a costmap to polygon converter
    if (!cfg_.obstacles.costmap_converter_plugin.empty())
    {
      try
      {
        costmap_converter_ = costmap_converter_loader_.createInstance(cfg_.obstacles.costmap_converter_plugin);
        std::string converter_name = costmap_converter_loader_.getName(cfg_.obstacles.costmap_converter_plugin);
        // replace '::' by '/' to convert the c++ namespace to a NodeHandle namespace
        boost::replace_all(converter_name, "::", "/");
        costmap_converter_->setOdomTopic(cfg_.odom_topic);
        costmap_converter_->initialize(ros::NodeHandle(nh, "costmap_converter/" + converter_name));
        costmap_converter_->setCostmap2D(costmap_);
 
        costmap_converter_->startWorker(ros::Rate(cfg_.obstacles.costmap_converter_rate), costmap_, cfg_.obstacles.costmap_converter_spin_thread);
        ROS_INFO_STREAM("Costmap conversion plugin " << cfg_.obstacles.costmap_converter_plugin << " loaded.");        
      }
      catch(pluginlib::PluginlibException& ex)
      {
        ROS_WARN("The specified costmap converter plugin cannot be loaded. All occupied costmap cells are treaten as point obstacles.
ROS(机人操作系统)是一套用于开发机人软件的开源框架,其中包括了丰富的功能包。局部路径规划Local Path Planner)是ROS中的一个重要功能包。 局部路径规划用于在机人周围的局部环境中计算机人的运动轨迹,以避开障碍物并达到目标位置。它基于机人的传感数据和地图信息,对机人周围的环境进行感知和分析,然后根据规划算法生成合适的路径。 ROS的局部路径规划功能包提供了多种路径规划算法的实现,包括经典的Dijkstra算法、A*算法等。这些算法根据不同的需求和环境特点,可以选择合适的算法来进行路径规划局部路径规划的核心思想是通过将机人当前位置作为起点,在环境中搜索一个合适的路径,并考虑到障碍物的避开以及路径的平滑性。具体的规划过程可以分为以下几个步骤: 1. 获取机人当前位置和地图信息。 2. 根据当前位置和地图,使用路径规划算法计算出一条可行的路径。 3. 对计算出的路径进行平滑处理,以便更顺利地跟随路径。 4. 将规划的路径发送给机人的控制系统,实现路径跟踪和控制。 局部路径规划的目标是使机人能够安全、高效地在复杂环境中移动,避开障碍物并尽快到达目标位置。它在机人导航任务中起到关键作用,能够帮助机人实现自主移动和避障等功能。 总而言之,ROS的局部路径规划是一种功能强大的工具,通过利用机人感知和规划算法,能够为机人提供合适的路径,使其在环境中安全地移动。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值