feat: EnvMonitor thay PathMonitor — giám sát môi trường bằng EDT/geodesic/quỹ đạo thật
Bộ giám sát mới trong ControlLoop (core/env_monitor, core/grid_analysis, ports/environment_port, io/env_logger), thay bốn phép đo của PathMonitor (code cũ còn, tắt bằng path_monitor/enabled: false): - kContact: dò tiếp xúc dọc quỹ đạo local planner (thay cung v/omega), bao tốc độ sqrt(2a(d - margin)) có dư, phanh chỉ khi vượt bao, cờ collision khi kề mũi tĩnh 1 s; cổng xoay tại chỗ theo lệnh controller muốn; hysteresis + xác nhận khi nhả; đứng ra sau detour không dịch robot (nhường controller); giữ phanh khi route khoá thì báo no valid command để controller_patience leo thang. - kStall: cost_to_go = geodesic tới điểm thoát 2 m dọc plan + phần plan còn lại, index plan bám cửa sổ, bộ lọc lật liên thông; cờ no_progress chỉ khi cổng dịch chuyển thực mở (robot không đi được đâu trong 12 s dù lệnh >= 1,5 m) — thay ngân sách replan cho stall. - kUnreachable: liên thông tới điểm thoát, đang ở action log. - EnvLogger ghi JSONL mỗi tick nặng; config/runtime/env_monitor_params.yaml đủ khoá, comment tiếng Việt; ControllerPort::measuredVelocity; FakeEnvironmentPort cho test. Sim 5–6/9: hết churn detour, khe 1,25 m đi qua 0,5 m/s, lượt 6/9 10:15 2 detour/142 s không oan. Test: grid_analysis 31, env_monitor 43, plan_inspector 37, walking_skeleton 87, các bộ khác pass. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xXjFjr2DQ6rhmhHSW4fk4
This commit is contained in:
@@ -28,6 +28,7 @@ namespace
|
||||
using move_base2::checkPlan;
|
||||
using move_base2::crossTrackError;
|
||||
using move_base2::nearestIndex;
|
||||
using move_base2::trackedNearestIndex;
|
||||
using move_base2::PlanarTransform;
|
||||
using move_base2::PlanBlockResult;
|
||||
using move_base2::planarTransform;
|
||||
@@ -202,6 +203,30 @@ TEST(PlanInspectorNearest, PlanFoldingBackOnItselfPicksTheNearerLeg)
|
||||
EXPECT_EQ(nearestIndex(plan, makePose(1.0, 0.95)), 2u);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorNearest, TrackedIndexStaysOnTheCurrentLegOfAFoldedPlan)
|
||||
{
|
||||
// Plan ra 4 m rồi vòng lại song song cách 0.6 m: robot đứng giữa hai đoạn (0.35 m tới đoạn đầu, 0.25 m tới
|
||||
// đoạn về). nearestIndex toàn plan nhảy sang đoạn về (index 2); bám từ hint 0 với cửa sổ 1 m lùi / 3 m tiến
|
||||
// thì đoạn về nằm ngoài 3 m dọc plan -> giữ đoạn đầu.
|
||||
std::vector<robot_geometry_msgs::PoseStamped> plan{ makePose(0.0, 0.0), makePose(4.0, 0.0), makePose(4.0, 0.6),
|
||||
makePose(0.0, 0.6) };
|
||||
const auto robot = makePose(1.0, 0.35);
|
||||
EXPECT_EQ(nearestIndex(plan, robot), 2u);
|
||||
EXPECT_EQ(trackedNearestIndex(plan, robot, 0, 1.0, 3.0), 0u);
|
||||
// Cửa sổ đủ dài thì bằng nearest toàn plan.
|
||||
EXPECT_EQ(trackedNearestIndex(plan, robot, 0, 1.0, 20.0), 2u);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorNearest, TrackedIndexAdvancesAndClampsTheHint)
|
||||
{
|
||||
const auto plan = linePlan(0.0, 5.0, 0.5); // 11 pose, 10 đoạn
|
||||
EXPECT_EQ(trackedNearestIndex(plan, makePose(2.3, 0.1), 2, 1.0, 3.0), 4u); // tiến
|
||||
EXPECT_EQ(trackedNearestIndex(plan, makePose(1.2, 0.0), 4, 1.0, 3.0), 2u); // lùi trong 1 m
|
||||
EXPECT_EQ(trackedNearestIndex(plan, makePose(0.1, 0.0), 8, 1.0, 3.0), 6u); // lùi bị chặn ở 1 m: đoạn 6
|
||||
EXPECT_EQ(trackedNearestIndex(plan, makePose(4.9, 0.0), 99, 1.0, 3.0), 9u); // hint vượt cỡ -> kẹp
|
||||
EXPECT_EQ(trackedNearestIndex({}, makePose(0.0, 0.0), 3, 1.0, 3.0), 0u);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorNearest, ShortPlansAreSafe)
|
||||
{
|
||||
EXPECT_EQ(nearestIndex({}, makePose(0.0, 0.0)), 0u);
|
||||
|
||||
Reference in New Issue
Block a user