fix(minco_ws): 期望朝向对轨迹起始“后向钩子”免疫(贴墙起步原地打转)
现象:0.5 m 目标正常,1.5 m 目标原地打转(方向随机,先右后左)。duration 正常 (0.5 m→5 s+、1.5 m→18 s+,速度一致),排除时间参数化问题。 决定性数据:/planning/bspline 的 pos_pts 前三点 (0.002,-0.035) → (-0.031,0.017) → (-0.063,0.069) x 递减、y 递增 ⇒ 轨迹起始段朝“后左”打钩,中段 y 还鼓到 +0.111。 estimateDesiredYaw 取 traj(0.8s)-traj(0) ≈ (-0.05,+0.055) ⇒ 期望 yaw ≈ +133°,远超 heading_error_threshold 0.6 ⇒ 进原地转分支。 根因在上游:起步位置离障碍过近,A* 起点附近被判占,参考路径先“挤出来”再走, B 样条拟合出起始钩子。已实测:把车挪到 ≥1 m 净空处后 1.5 m 目标正常。 修法(控制器兜底,不改规划器):仅当 dot(短前视方向, 指向轨迹终点方向) < 0 时才逐步加大前视、跳过钩子。该判据的边界是安全的: - 正常朝前路径 点积>0 → 代码路径与改动前完全一致,零影响; - 目标真在车后(掉头)时整体方向同样朝后,点积>0 → 掉头不被误伤。 回归:贴墙起步 1.5 m 不再打转且基本走直线;掉头 180° 正常;0.5/1.5 m 停车精度不变。 遗留:空旷处仍会先转一个小角度再斜着逼近 —— 属“沿路径切向跟随”的固有特性,非缺陷。
This commit is contained in:
@@ -63,8 +63,32 @@ private:
|
|||||||
|
|
||||||
double estimateDesiredYaw(double t_cur, const Eigen::Vector3d &pos_des) const
|
double estimateDesiredYaw(double t_cur, const Eigen::Vector3d &pos_des) const
|
||||||
{
|
{
|
||||||
const double t_look = std::min(traj_duration_, t_cur + time_forward_);
|
// 固定前视 time_forward_ 取切向。若轨迹起始段因"+起点拥挤"而朝后打钩
|
||||||
|
// (实测:起点离障碍过近时 A* 先规划一条挤出来的参考路径,B 样条起始段 x 递减),
|
||||||
|
// 该切向会与整体前进方向相反,控制器据此进原地转分支、转 130° 以上。
|
||||||
|
//
|
||||||
|
// 兜底判据:仅当"短前视方向"与"指向轨迹终点方向"的点积 < 0 时才认为异常,
|
||||||
|
// 正常路径(朝前)点积 > 0,行为与改动前完全一致;
|
||||||
|
// 目标真在车后时整体方向同样朝后,点积 > 0,掉头不受影响。
|
||||||
|
double t_look = std::min(traj_duration_, t_cur + time_forward_);
|
||||||
Eigen::Vector3d direction = traj_[0].evaluateDeBoorT(t_look) - pos_des;
|
Eigen::Vector3d direction = traj_[0].evaluateDeBoorT(t_look) - pos_des;
|
||||||
|
|
||||||
|
const Eigen::Vector3d dir_end = traj_[0].evaluateDeBoorT(traj_duration_) - pos_des;
|
||||||
|
if (dir_end.head<2>().squaredNorm() > 1e-4 &&
|
||||||
|
direction.head<2>().squaredNorm() > 1e-8 &&
|
||||||
|
direction.head<2>().dot(dir_end.head<2>()) < 0.0)
|
||||||
|
{
|
||||||
|
// 逐段加大前视,跳过起始钩子,直到方向不再背离终点或到达末端
|
||||||
|
const double step = std::max(time_forward_, 0.2);
|
||||||
|
int guard = 0;
|
||||||
|
while (t_look < traj_duration_ && guard++ < 32 &&
|
||||||
|
direction.head<2>().dot(dir_end.head<2>()) < 0.0)
|
||||||
|
{
|
||||||
|
t_look = std::min(traj_duration_, t_look + step);
|
||||||
|
direction = traj_[0].evaluateDeBoorT(t_look) - pos_des;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (direction.head<2>().squaredNorm() < 1e-4)
|
if (direction.head<2>().squaredNorm() < 1e-4)
|
||||||
direction = traj_[1].evaluateDeBoorT(t_cur);
|
direction = traj_[1].evaluateDeBoorT(t_cur);
|
||||||
return direction.head<2>().squaredNorm() < 1e-4
|
return direction.head<2>().squaredNorm() < 1e-4
|
||||||
|
|||||||
Reference in New Issue
Block a user