refactor: xoá PathMonitor và PathCheckPort, EnvMonitor là bộ giám sát duy nhất; gộp refreshSnapshot
Xoá hạ tầng giám sát cũ đã tắt từ 5/9 (path_monitor/enabled: false), −2947 dòng: - ControlLoop: PathMonitorConfig, updatePathMonitor / updateProgressMonitor / applyCollisionGuard / planIsBlocked / resetPathMonitor / rebuildPlanArcLength, toàn bộ member bốn phép đo, luật "plan mới bẩn thì giữ plan cũ" trong collectPlannerResult. Bốn cổng StateMachineInput giữ nguyên (off_path không còn nguồn, đặt false). - ports/path_check_port.h, CostmapPathCheck trong NavigationRuntime. - plan_inspector: bỏ checkPlan / checkMotion / PlanBlockResult / MotionCheckParams / MotionBlockResult; giữ planarTransform, nearestIndex, trackedNearestIndex, crossTrackError. - Config: readPathMonitor, MoveBase2Config::path_monitor, validate; xoá config/runtime/path_monitor_params.yaml; comment YAML/state_machine đổi sang tên verdict EnvMonitor. - Test: FakePathCheckPort, 30 test WalkingSkeletonPathMonitor/CollisionGuard, 13 test PlanInspectorCheck/Motion, 2 test validate thân guard. P0(b): ControlLoop::step() gọi EnvironmentPort::refresh() một lần đầu cycle (không phụ thuộc env_monitor/enabled); ControllerRunner::setSnapshotRefreshedByLoop(true) làm ba refreshSnapshot() trong runner thành no-op — monitor và controller đọc cùng một lưới, một bản copy mỗi cycle. Test: env_monitor 43, grid_analysis 33, plan_inspector 11, walking_skeleton 57, config_validation 32, scenario 12, state_machine 100, navigation_server 56, controller_runner 28, velocity_arbiter 29, planner_runner 31 — pass. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xXjFjr2DQ6rhmhHSW4fk4
This commit is contained in:
@@ -25,12 +25,10 @@
|
||||
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;
|
||||
|
||||
robot_geometry_msgs::PoseStamped makePose(double x, double y, const std::string& frame = "map")
|
||||
@@ -61,128 +59,6 @@ nav_test_harness::FakeCostmap makeGrid()
|
||||
return nav_test_harness::FakeCostmap::centered(10.0, 0.05);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorCheck, CleanPlanIsNotBlocked)
|
||||
{
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
const auto plan = linePlan(0.0, 3.0, 0.1);
|
||||
|
||||
const PlanBlockResult result = checkPlan(plan, 0, 3.0, *grid.costmap(), PlanarTransform());
|
||||
|
||||
EXPECT_FALSE(result.blocked);
|
||||
EXPECT_GT(result.scanned, 0u);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorCheck, FreeSpaceValueIsNotBlocked)
|
||||
{
|
||||
// Bẫy của fork này: FREE_SPACE = 60, không phải 0. Đặt tường minh giá trị đó lên tuyến để khoá
|
||||
// lại bất biến "so sánh phải dùng hằng số có tên".
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
ASSERT_TRUE(grid.setCostAt(1.0, 0.0, robot_costmap_2d::FREE_SPACE));
|
||||
|
||||
const auto plan = linePlan(0.0, 3.0, 0.1);
|
||||
const PlanBlockResult result = checkPlan(plan, 0, 3.0, *grid.costmap(), PlanarTransform());
|
||||
|
||||
EXPECT_FALSE(result.blocked);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorCheck, LethalCellOnThePlanBlocks)
|
||||
{
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
ASSERT_TRUE(grid.setLethalAt(1.5, 0.0));
|
||||
|
||||
const auto plan = linePlan(0.0, 3.0, 0.1);
|
||||
const PlanBlockResult result = checkPlan(plan, 0, 3.0, *grid.costmap(), PlanarTransform());
|
||||
|
||||
ASSERT_TRUE(result.blocked);
|
||||
EXPECT_NEAR(plan[result.index].pose.position.x, 1.5, 0.06);
|
||||
EXPECT_NEAR(result.distance, 1.5, 0.06);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorCheck, InscribedInflatedCountsAsBlocked)
|
||||
{
|
||||
// Ngưỡng là INSCRIBED_INFLATED_OBSTACLE chứ không phải LETHAL: ở đó tâm robot đặt vào là footprint
|
||||
// đã đệm chạm vật cản.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
ASSERT_TRUE(grid.setCostAt(1.0, 0.0, robot_costmap_2d::INSCRIBED_INFLATED_OBSTACLE));
|
||||
|
||||
const auto plan = linePlan(0.0, 3.0, 0.1);
|
||||
const PlanBlockResult result = checkPlan(plan, 0, 3.0, *grid.costmap(), PlanarTransform());
|
||||
|
||||
EXPECT_TRUE(result.blocked);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorCheck, UnknownCellIsNotBlocked)
|
||||
{
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
ASSERT_TRUE(grid.setCostAt(1.0, 0.0, robot_costmap_2d::NO_INFORMATION));
|
||||
|
||||
const auto plan = linePlan(0.0, 3.0, 0.1);
|
||||
const PlanBlockResult result = checkPlan(plan, 0, 3.0, *grid.costmap(), PlanarTransform());
|
||||
|
||||
// Vùng chưa quét mà tính là chắn thì robot dừng ở mọi tuyến đi vào chỗ chưa thấy.
|
||||
EXPECT_FALSE(result.blocked);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorCheck, HorizonCutsTheScanShort)
|
||||
{
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
ASSERT_TRUE(grid.setLethalAt(2.5, 0.0));
|
||||
|
||||
const auto plan = linePlan(0.0, 3.0, 0.1);
|
||||
|
||||
EXPECT_FALSE(checkPlan(plan, 0, 1.0, *grid.costmap(), PlanarTransform()).blocked);
|
||||
EXPECT_TRUE(checkPlan(plan, 0, 3.0, *grid.costmap(), PlanarTransform()).blocked);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorCheck, ScanStartsAtFromIndex)
|
||||
{
|
||||
// Vật cản NẰM SAU lưng (phần plan đã đi qua) không được tính.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
ASSERT_TRUE(grid.setLethalAt(0.5, 0.0));
|
||||
|
||||
const auto plan = linePlan(0.0, 3.0, 0.1);
|
||||
|
||||
EXPECT_TRUE(checkPlan(plan, 0, 3.0, *grid.costmap(), PlanarTransform()).blocked);
|
||||
EXPECT_FALSE(checkPlan(plan, 15, 3.0, *grid.costmap(), PlanarTransform()).blocked);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorCheck, OutOfGridStopsTheScanInsteadOfBlocking)
|
||||
{
|
||||
nav_test_harness::FakeCostmap grid = makeGrid(); // ±5 m
|
||||
const auto plan = linePlan(0.0, 20.0, 0.5);
|
||||
|
||||
const PlanBlockResult result = checkPlan(plan, 0, 20.0, *grid.costmap(), PlanarTransform());
|
||||
|
||||
EXPECT_FALSE(result.blocked);
|
||||
EXPECT_LT(result.scanned, plan.size()); // dừng ở rìa lưới, không quét hết
|
||||
}
|
||||
|
||||
TEST(PlanInspectorCheck, EmptyPlanAndBadArgumentsAreSafe)
|
||||
{
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
const auto plan = linePlan(0.0, 3.0, 0.1);
|
||||
|
||||
EXPECT_FALSE(checkPlan({}, 0, 3.0, *grid.costmap(), PlanarTransform()).blocked);
|
||||
EXPECT_FALSE(checkPlan(plan, 999, 3.0, *grid.costmap(), PlanarTransform()).blocked);
|
||||
EXPECT_FALSE(checkPlan(plan, 0, 0.0, *grid.costmap(), PlanarTransform()).blocked);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorCheck, TransformIsAppliedToEveryPose)
|
||||
{
|
||||
// Plan ở "map", lưới ở "odom" lệch (2, 1): vật cản đặt theo toạ độ LƯỚI.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
ASSERT_TRUE(grid.setLethalAt(-0.5, -1.0)); // = map (1.5, 0.0) sau khi trừ offset
|
||||
|
||||
PlanarTransform to_grid;
|
||||
to_grid.x = -2.0;
|
||||
to_grid.y = -1.0;
|
||||
|
||||
const auto plan = linePlan(0.0, 3.0, 0.1);
|
||||
|
||||
EXPECT_TRUE(checkPlan(plan, 0, 3.0, *grid.costmap(), to_grid).blocked);
|
||||
EXPECT_FALSE(checkPlan(plan, 0, 3.0, *grid.costmap(), PlanarTransform()).blocked);
|
||||
}
|
||||
|
||||
TEST(PlanInspectorNearest, ProjectsOntoSegmentsNotVertices)
|
||||
{
|
||||
const auto plan = linePlan(0.0, 3.0, 1.0); // pose tại x = 0,1,2,3
|
||||
@@ -305,263 +181,3 @@ int main(int argc, char** argv)
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
// Phép đo 3: cung lệnh — thân robot có sắp chạm vật cản THẬT không (2026-09-03).
|
||||
// =================================================================================================
|
||||
namespace
|
||||
{
|
||||
using move_base2::checkMotion;
|
||||
using move_base2::MotionBlockResult;
|
||||
using move_base2::MotionCheckParams;
|
||||
|
||||
MotionCheckParams bodyParams()
|
||||
{
|
||||
MotionCheckParams p;
|
||||
p.lookahead = 0.8;
|
||||
p.max_samples = 6;
|
||||
p.front_offset = 0.58;
|
||||
p.rear_offset = 0.58;
|
||||
p.side_offset = 0.48;
|
||||
p.padding = 0.05;
|
||||
p.cost_threshold = robot_costmap_2d::LETHAL_OBSTACLE;
|
||||
return p;
|
||||
}
|
||||
|
||||
TEST(MotionCheck, ClearArcIsNotBlocked)
|
||||
{
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, bodyParams(), *grid.costmap());
|
||||
EXPECT_FALSE(r.blocked);
|
||||
// Bước dò bị kẹp về một ô lưới (0.05 m) nên 0.8 m là 16 mẫu, không phải max_samples = 6.
|
||||
EXPECT_EQ(r.scanned, 16);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, ThinWallBetweenCoarseSamplesIsStillCaught)
|
||||
{
|
||||
// Tường dày đúng MỘT ô tại x=1.30. Với bước thưa 0.8/6 = 0.133 m, mũi (0.63 m trước tâm) ở
|
||||
// mẫu 5 là 1.297 (chưa tới), mẫu 6 là 1.43 (đã qua) — cả hai sạch, robot đâm xuyên. Kẹp bước
|
||||
// về một ô lưới thì không mẫu nào nhảy qua được.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
for (double y = -0.6; y <= 0.6; y += 0.05)
|
||||
{
|
||||
ASSERT_TRUE(grid.setLethalAt(1.30, y));
|
||||
}
|
||||
MotionCheckParams p = bodyParams();
|
||||
p.max_samples = 6;
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, p, *grid.costmap());
|
||||
ASSERT_TRUE(r.blocked);
|
||||
EXPECT_NEAR(r.distance, 1.30 - 0.63, 0.06);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, LethalAheadOfTheNoseBlocksWithDistance)
|
||||
{
|
||||
// Tường tại x=1.2. Mũi robot vươn 0.58+0.05 = 0.63 m trước tâm, nên tâm chỉ cần đi ~0.57 m là
|
||||
// mũi chạm — phải báo ở mẫu ~0.53–0.67 m, KHÔNG phải khi tâm tới 1.2 m.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
for (double y = -0.6; y <= 0.6; y += 0.05)
|
||||
{
|
||||
ASSERT_TRUE(grid.setLethalAt(1.2, y));
|
||||
}
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, bodyParams(), *grid.costmap());
|
||||
ASSERT_TRUE(r.blocked);
|
||||
EXPECT_GT(r.distance, 0.4);
|
||||
EXPECT_LT(r.distance, 0.8);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, InflationOnlyIsNotBlocked)
|
||||
{
|
||||
// Đây là toàn bộ lý do phép đo này tồn tại: ô INSCRIBED (253) là biên cho TÂM robot, đặt lên mũi
|
||||
// là đếm biên hai lần. Phủ 253 kín đường đi — robot vẫn phải được chạy.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
for (double x = 0.0; x <= 2.0; x += 0.05)
|
||||
{
|
||||
for (double y = -0.7; y <= 0.7; y += 0.05)
|
||||
{
|
||||
ASSERT_TRUE(grid.setCostAt(x, y, robot_costmap_2d::INSCRIBED_INFLATED_OBSTACLE));
|
||||
}
|
||||
}
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, bodyParams(), *grid.costmap());
|
||||
EXPECT_FALSE(r.blocked);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, LethalUnderTheBodyDoesNotBlockParallelMotion)
|
||||
{
|
||||
// Người kề hông trái: hàng ô LETHAL ở y=0.51 (ngoài thân 0.48, trong thân đệm 0.53), dọc x từ
|
||||
// -0.2 tới 0.3 — đúng ca sim 4/9 làm guard báo 0.05 m mãi. Đi thẳng thì mép trái chỉ quét lại
|
||||
// đúng những ô đã nằm dưới thân -> không có ô mới -> phải cho đi.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
for (double x = -0.2; x <= 0.3; x += 0.05)
|
||||
{
|
||||
ASSERT_TRUE(grid.setLethalAt(x, 0.51));
|
||||
}
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, bodyParams(), *grid.costmap());
|
||||
EXPECT_FALSE(r.blocked) << "blocked at " << r.distance << " m";
|
||||
EXPECT_GE(r.baseline_cells, 1);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, LethalUnderTheBodyStillBlocksWhenTheArcAddsNewCells)
|
||||
{
|
||||
// Khối 3 hàng x 9 cột ở hông trái-sau (y=0.51/0.56/0.61, x từ -0.6 tới -0.2). Hàng trong cùng là
|
||||
// baseline; rẽ phải làm góc trái-sau văng ra ngoài lên hai hàng còn lại -> ô MỚI -> vẫn chặn, và
|
||||
// ở khoảng cách thật (> mẫu đầu 0.05 m) chứ không phải "0.05 m" máy móc.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
for (double x = -0.6; x <= -0.2; x += 0.05)
|
||||
{
|
||||
for (double y = 0.51; y <= 0.62; y += 0.05)
|
||||
{
|
||||
ASSERT_TRUE(grid.setLethalAt(x, y));
|
||||
}
|
||||
}
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.4, -0.1, bodyParams(), *grid.costmap());
|
||||
ASSERT_TRUE(r.blocked);
|
||||
EXPECT_GT(r.distance, 0.05);
|
||||
EXPECT_LT(r.distance, 0.5);
|
||||
EXPECT_GE(r.baseline_cells, 1);
|
||||
// Chi tiết debug: chạm bằng cạnh TRÁI, ô chạm nằm bên trái phía sau tâm, baseline liệt kê ô bên trái.
|
||||
EXPECT_EQ(r.hit_edge, 2);
|
||||
EXPECT_GT(r.hit_y, 0.4);
|
||||
EXPECT_LT(r.hit_x, 0.0);
|
||||
ASSERT_GE(r.baseline_listed, 1);
|
||||
EXPECT_GT(r.baseline_xy[0][1], 0.4);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, LethalAheadOfTheNoseIsUnaffectedByBaseline)
|
||||
{
|
||||
// Có người kề hông (baseline) VÀ tường trước mũi: tường là ô mới, phải chặn y như không có baseline.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
ASSERT_TRUE(grid.setLethalAt(0.0, 0.51));
|
||||
for (double y = -0.6; y <= 0.6; y += 0.05)
|
||||
{
|
||||
ASSERT_TRUE(grid.setLethalAt(1.2, y));
|
||||
}
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, bodyParams(), *grid.costmap());
|
||||
ASSERT_TRUE(r.blocked);
|
||||
EXPECT_GT(r.distance, 0.4);
|
||||
EXPECT_LT(r.distance, 0.8);
|
||||
EXPECT_GE(r.baseline_cells, 1);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, LookaheadAngleTruncatesTheArc)
|
||||
{
|
||||
// R = v/omega = 0.1 m: 0.8 m cung là quay 8 rad. Cắt ở 1.0 rad -> chỉ còn 0.1 m cung = 2 mẫu;
|
||||
// không cắt (pi) -> 0.31 m = 6 mẫu. Không có vật cản: chỉ đo số mẫu.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
MotionCheckParams p = bodyParams();
|
||||
p.lookahead_angle = 1.0;
|
||||
const MotionBlockResult cut = checkMotion(0.0, 0.0, 0.0, 0.4, 4.0, p, *grid.costmap());
|
||||
EXPECT_FALSE(cut.blocked);
|
||||
EXPECT_EQ(cut.scanned, 2);
|
||||
p.lookahead_angle = M_PI;
|
||||
const MotionBlockResult full = checkMotion(0.0, 0.0, 0.0, 0.4, 4.0, p, *grid.costmap());
|
||||
EXPECT_FALSE(full.blocked);
|
||||
EXPECT_GE(full.scanned, 6);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, BaselineDisabledKeepsTheOldVerdict)
|
||||
{
|
||||
// Đường lùi: tắt cờ thì ca "người kề hông + đi thẳng" lại bị chặn ngay mẫu đầu như trước 4/9.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
for (double x = -0.2; x <= 0.3; x += 0.05)
|
||||
{
|
||||
ASSERT_TRUE(grid.setLethalAt(x, 0.51));
|
||||
}
|
||||
MotionCheckParams p = bodyParams();
|
||||
p.exclude_baseline = false;
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, p, *grid.costmap());
|
||||
ASSERT_TRUE(r.blocked);
|
||||
EXPECT_LE(r.distance, 0.1);
|
||||
EXPECT_EQ(r.baseline_cells, 0);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, ArcCurvingAwayFromTheWallIsClear)
|
||||
{
|
||||
// Tường ngay trước mặt tại x=1.0 nhưng lệnh rẽ gắt trái (kappa = 1.5/0.3 = 5 1/m, R=0.2 m):
|
||||
// cung quay đi trước khi mũi tới tường. Gate quỹ đạo giấy cũng nói vậy — và đó là hành vi ĐÚNG
|
||||
// của phép đo này: nó đo lệnh thật, không đoán.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
for (double y = -0.3; y <= 0.3; y += 0.05)
|
||||
{
|
||||
ASSERT_TRUE(grid.setLethalAt(1.0, y));
|
||||
}
|
||||
MotionCheckParams p = bodyParams();
|
||||
p.side_offset = 0.0; // chỉ tâm/mũi/đuôi để test hình học cung, không dính probe hông
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.3, 1.5, p, *grid.costmap());
|
||||
EXPECT_FALSE(r.blocked);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, ThinPillarAtTheFrontCornerIsCaught)
|
||||
{
|
||||
// Trụ mảnh (một ô) tại x=1.0, y=+0.30: nằm giữa đường quét mũi (ngang 0) và đường quét hông
|
||||
// (ngang 0.53) của bản 5 điểm — bản đó không probe nào chạm, robot ôm trụ bằng góc trước-trái
|
||||
// (đo 4/9: near=0.36 m @ +70°). Chu vi bắt được ở mẫu mà cạnh mũi đi qua trụ.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
ASSERT_TRUE(grid.setLethalAt(1.0, 0.30));
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, bodyParams(), *grid.costmap());
|
||||
ASSERT_TRUE(r.blocked);
|
||||
// Cạnh mũi ở 0.58 + 0.05 = 0.63 trước tâm -> chạm khi tâm đi được ~0.37 m.
|
||||
EXPECT_NEAR(r.distance, 1.0 - 0.63, 0.06);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, PillarBetweenTwoWheelsIsCaughtByTheFrontEdge)
|
||||
{
|
||||
// Hai trụ cách nhau 0.45 m, robot chui giữa: bản 5 điểm để lọt cả hai; chu vi mũi chạm ngay.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
ASSERT_TRUE(grid.setLethalAt(1.2, 0.225));
|
||||
ASSERT_TRUE(grid.setLethalAt(1.2, -0.225));
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, bodyParams(), *grid.costmap());
|
||||
EXPECT_TRUE(r.blocked);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, SideProbeCatchesAWallBesideTheArc)
|
||||
{
|
||||
// Tường dọc bên trái tại y=+0.50, robot đi thẳng: chu vi với nửa rộng 0.48 + 0.05 = 0.53 chạm;
|
||||
// thu side_offset về 0 (dải rộng 2 x padding) thì không.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
for (double x = 0.0; x <= 1.5; x += 0.05)
|
||||
{
|
||||
ASSERT_TRUE(grid.setLethalAt(x, 0.50));
|
||||
}
|
||||
MotionCheckParams p = bodyParams();
|
||||
const MotionBlockResult with_side = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, p, *grid.costmap());
|
||||
EXPECT_TRUE(with_side.blocked);
|
||||
p.side_offset = 0.0;
|
||||
const MotionBlockResult no_side = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, p, *grid.costmap());
|
||||
EXPECT_FALSE(no_side.blocked);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, StandingStillScansNothing)
|
||||
{
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
ASSERT_TRUE(grid.setLethalAt(0.3, 0.0));
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.0, 0.5, bodyParams(), *grid.costmap());
|
||||
EXPECT_FALSE(r.blocked);
|
||||
EXPECT_EQ(r.scanned, 0);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, ReverseMotionProbesBehind)
|
||||
{
|
||||
// Tường SAU lưng tại x=-1.2, lệnh lùi: đuôi (0.58+0.05) chạm trước khi tâm tới.
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
for (double y = -0.6; y <= 0.6; y += 0.05)
|
||||
{
|
||||
ASSERT_TRUE(grid.setLethalAt(-1.2, y));
|
||||
}
|
||||
const MotionBlockResult fwd = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, bodyParams(), *grid.costmap());
|
||||
EXPECT_FALSE(fwd.blocked);
|
||||
const MotionBlockResult rev = checkMotion(0.0, 0.0, 0.0, -0.4, 0.0, bodyParams(), *grid.costmap());
|
||||
ASSERT_TRUE(rev.blocked);
|
||||
EXPECT_LT(rev.distance, 0.8);
|
||||
}
|
||||
|
||||
TEST(MotionCheck, UnknownCellsAreNotBlocked)
|
||||
{
|
||||
nav_test_harness::FakeCostmap grid = makeGrid();
|
||||
for (double x = 0.0; x <= 2.0; x += 0.05)
|
||||
{
|
||||
ASSERT_TRUE(grid.setCostAt(x, 0.0, robot_costmap_2d::NO_INFORMATION));
|
||||
}
|
||||
const MotionBlockResult r = checkMotion(0.0, 0.0, 0.0, 0.4, 0.0, bodyParams(), *grid.costmap());
|
||||
EXPECT_FALSE(r.blocked);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user