ros Navigation DWA学习

参考博客
ROS 源码阅读——局部路径规划之DWAPlannerROS分析

dwa_planner_ros.cpp中的computeVelocityCommands()函数是计算最后的速度指令的。在函数中,首先得到机器人位置,然后得到全局路径映射后的局部路径,然后由dp_.updatePlanAndLocalCosts()更新打分,然后判断是否到达目标附近,是的话调用停止的函数发布速度,否则调用dwaComputeVelocityCommands计算速度。

dp_.updatePlanAndLocalCosts()函数更新打分应该是更新局部路径产生的路径点那些内容。

在dwaComouteVelocityCommands函数中,主要的是findBestPath()函数。

findBestPath()函数在dwa_planner.cpp文件中定义。
首先利用generator_.initialise()产生轨迹。该函数为base_local_planner功能包中的simpleTrajectorygenerator.cpp中的类。

generator_.initialise(pos,
        vel,
        goal,
        &limits,
        vsamples_);

    result_traj_.cost_ = -7;

然后就是findBestTrajectory()函数

std::vector<base_local_planner::Trajectory> all_explored;
scored_sampling_planner_.findBestTrajectory(result_traj_, &all_explored);

该函数在base_local_planner功能包中的simpleScoredSamplingPlanner.cpp中定义.。
首先进行打分项的prepare。打分项那部分,每个都是critics,这个在dwa_planner.cpp中构造函数中会把不同的costfunction压入。分别是

 // see constructor body for explanations
      base_local_planner::SimpleTrajectoryGenerator generator_;
      base_local_planner::OscillationCostFunction oscillation_costs_;
      base_local_planner::ObstacleCostFunction obstacle_costs_;
      base_local_planner::MapGridCostFunction path_costs_;
      base_local_planner::MapGridCostFunction goal_costs_;
      base_local_planner::MapGridCostFunction goal_front_costs_;
      base_local_planner::MapGridCostFunction alignment_costs_;
      base_local_planner::TwirlingCostFunction twirling_costs_;

打分项prepare后,就是simple_scored_sampling_planner中的scoreTrajectory函数,而在其中,cost计算如下

double cost = score_function_p->scoreTrajectory(traj);

这一部分在base_local_planner功能包中的Trajectory_cost_function.h中声明,是一个虚函数,其定义根据之前score_function_p的不同,即critics中类型的不同,分别到不同的costfunction中。

以obstacle_cost_function为例。
其cost为f_cost和cost的最大值,f_cost计算如下:


 double f_cost = footprintCost(px, py, pth,
        scale, footprint_spec_,
        costmap_, world_model_);

footprintCost在obstacle_cost_function.cpp中。
其计算如下:

 double footprint_cost = world_model->footprintCost(x, y, th, footprint_spec);

world_model.h文件中footprintCost函数也是虚函数,因为用的是costmap,所以为costmap_model.cpp的footprintCost函数。

在其中会返回足迹点之间线段上所有的点中的最大代价,或者求和。
点的代价参考博客 costmap_2D包的理解

应该是就不包含距离障碍的代价,就是碰撞或不碰撞。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值