图优化 optimizeGraph
1 | // clear_after 调用时写死为false |
再回到optimizeTEB
,剩余部分是这样的:1
2
3
4
5
6
7
8
9
10
11
12
13
14success = optimizeGraph(iterations_innerloop, false);
if (!success)
{
clearGraph();
return false;
}
optimized_ = true;
// 只在最后一次外循环时 compute cost vec
if (compute_cost_afterwards && i==iterations_outerloop-1)
computeCurrentCost(obst_cost_scale, viapoint_cost_scale, alternative_time_cost);
clearGraph();
weight_multiplier *= cfg_->optim.weight_adapt_factor;
// iterations_outerloop 结束
computeCurrentCost
1 | void TebOptimalPlanner::computeCurrentCost( double obst_cost_scale, |
相应的有个TebOptimalPlanner::getCurrentCost()
返回每次图优化计算的代价,而它又用于HomotopyClassPlanner::computeCurrentCost
和 HomotopyClassPlanner::selectBestTeb()
obst_cost_scale
Specify extra scaling for obstacle costs (only used ifcompute_cost_afterwards
is true)viapoint_cost_scale
Specify extra scaling for via-point costs (only used ifcompute_cost_afterwards
is true)alternative_time_cost
Replace the cost for the time optimal objective by the actual (weighted) transition time (only used ifcompute_cost_afterwards
is true)
总结
optimizeTEB
包括两个循环:
通过调用
TimedElasticBand::autoResize()
,外循环resizes the trajectoryoptimizeGraph()
是内循环部分,调用solver(使用g2o的sparse Levenberg-Marquardt
方法) 遍历一定次数的optimization calls内外循环次数的比例defines the
contraction behavior
andconvergence rate
of the trajectory optimization.2~6
个内循环足够了
TebOptPlannerContainer tebs_;
: Container that stores multiple local teb planners (for alternative equivalence classes) and their corresponding costs
The number of outer loop
iterations should be determined by considering the maximum CPU time
required to match the control rate.
Optionally, the cost vector can be calculated by specifyingcompute_cost_afterwards
, the cost vector can be accessed afterwards using getCurrentCost()
. 目前使用TebOptimalPlanner
不会计算代价,使用HomotopyClassPlanner
会,第一次计算时,代价是一个很大很大的数,第二次减小很多,之后逐渐减小到1左右或者更小