feat(control_loop): reserve backup_global_planner for the position profile
A failed primary global planner on a docking, go_straight or rotate request no longer swaps to backup_global_planner. It goes straight to the planning_failed recovery route and aborts. Only the position profile may use the backup planner. Update STATE_MACHINE.md and add test NonPositionPlannerFailureSkipsBackup.
This commit is contained in:
@@ -596,6 +596,39 @@ TEST(ControlLoop, BackupPlannerFailureEscalatesToRecovery)
|
||||
EXPECT_EQ(fixture.recovery_.lastTrigger(), RecoveryTrigger::kPlanningFailed);
|
||||
}
|
||||
|
||||
// Backup chỉ dành cho position. Docking/go_straight/rotate fail thì đi thẳng recovery, planner chính
|
||||
// giữ nguyên — robot KIT 26/10: SBPL thay DockPlanner dựng đường thẳng vào dock, bỏ qua cusp.
|
||||
TEST(ControlLoop, NonPositionPlannerFailureSkipsBackup)
|
||||
{
|
||||
for (const MotionProfile profile :
|
||||
{MotionProfile::kDocking, MotionProfile::kGoStraight, MotionProfile::kRotate})
|
||||
{
|
||||
SCOPED_TRACE(toString(profile));
|
||||
ControlLoopConfig config = baseConfig();
|
||||
config.backup_global_planner_name = "FakeBackupGlobalPlanner";
|
||||
config.state_machine.max_planning_retries = 0;
|
||||
Fixture fixture(config);
|
||||
fixture.planner_.setScript({PlannerScript::kFail, PlannerScript::kFail});
|
||||
fixture.recovery_.setScript({RecoveryScript::kRunning});
|
||||
|
||||
std::string reason;
|
||||
NavigationRequest request = makeRequest(3.0, 73);
|
||||
request.profile = profile;
|
||||
ASSERT_TRUE(fixture.loop_.submit(request, reason)) << reason;
|
||||
|
||||
for (int i = 0; i < 20 && fixture.loop_.state() != NavigationState::kRecovering; ++i)
|
||||
{
|
||||
fixture.stepOnce();
|
||||
}
|
||||
|
||||
EXPECT_EQ(fixture.planner_.activePlanner(), "FakeGlobalPlanner");
|
||||
EXPECT_EQ(fixture.planner_.makePlanCount(), 1u);
|
||||
EXPECT_EQ(fixture.loop_.state(), NavigationState::kRecovering);
|
||||
EXPECT_EQ(fixture.recovery_.startCount(), 1u);
|
||||
EXPECT_EQ(fixture.recovery_.lastTrigger(), RecoveryTrigger::kPlanningFailed);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ControlLoop, PlannerFailureDrivesRecoveryThenSucceeds)
|
||||
{
|
||||
// Kịch bản thật: planner bế tắc cho tới khi recovery gỡ được thế, sau đó lập plan bình thường.
|
||||
|
||||
Reference in New Issue
Block a user