fix(env_monitor): stand-down của kContact không bao giờ được vũ trang — đọc trigger ở cycle tick
ControlLoop truyền `output.recovery_trigger == kCollision` vào onRecoveryFinished ở cycle tick, mà StateMachineOutput::recovery_trigger chỉ được điền ở cycle khởi động recovery (và khi trừ ngân sách); cycle tick là mặc định kPlanningFailed nên from_contact luôn false. Run 6/9 16:30 (đám đông): người đứng 7 cm trước mũi → 4 cờ collision cùng chỗ → route cạn → ABORT, JSONL contact_standdown = 0. - ControlLoop::running_recovery_trigger_ ghi ở start_recovery, dùng ở tick kết thúc. - FakeRecoveryPort::setSucceedWithPath; test walking skeleton DetourFromContactThatDidNotMoveTheRobotArmsTheStandDown (cờ → detour có path → chạm lại tại chỗ → không RECOVERING thứ hai trong 1,5 s, lệnh về controller). Test: walking_skeleton 58/58, env_monitor 47/47, các bộ khác pass. Sim 18:07 và 20:26 không hồi quy (chưa có ca cờ collision thứ hai để kiểm sống). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xXjFjr2DQ6rhmhHSW4fk4
This commit is contained in:
@@ -379,6 +379,10 @@ private:
|
||||
PlannerFeedback planner_feedback_ = PlannerFeedback::kIdle;
|
||||
ControllerFeedback controller_feedback_ = ControllerFeedback::kIdle;
|
||||
RecoveryFeedback recovery_feedback_ = RecoveryFeedback::kIdle;
|
||||
/// Trigger của behavior đang chạy. `StateMachineOutput::recovery_trigger` chỉ được điền ở cycle khởi động
|
||||
/// (và khi trừ ngân sách), ở cycle tick nó là giá trị mặc định — đọc nó lúc kết thúc recovery là sai
|
||||
/// (stand-down của kContact không bao giờ được vũ trang, run 6/9 16:30: 4 detour collision cùng chỗ → ABORT).
|
||||
RecoveryTrigger running_recovery_trigger_ = RecoveryTrigger::kPlanningFailed;
|
||||
ActionFeedback action_feedback_ = ActionFeedback::kIdle;
|
||||
|
||||
/// Lý do action handler đưa ra cho lần tick vừa rồi; chỉ giữ khi tick đó HỎNG, xem
|
||||
|
||||
@@ -1073,6 +1073,7 @@ bool ControlLoop::step()
|
||||
|
||||
if (output.start_recovery)
|
||||
{
|
||||
running_recovery_trigger_ = output.recovery_trigger;
|
||||
if (!deps_.recovery->start(output.recovery_index, output.recovery_trigger))
|
||||
{
|
||||
// Behavior từ chối khởi động (ví dụ đã va chạm ngay tại chỗ) — báo hỏng để state machine
|
||||
@@ -1094,7 +1095,7 @@ bool ControlLoop::step()
|
||||
env_monitor_.onRecoveryFinished(now,
|
||||
tick.has_path && !tick.path.empty() ? EnvRecoveryOutcome::kSucceededWithPath
|
||||
: EnvRecoveryOutcome::kSucceeded,
|
||||
output.recovery_trigger == RecoveryTrigger::kCollision);
|
||||
running_recovery_trigger_ == RecoveryTrigger::kCollision);
|
||||
break;
|
||||
case RecoveryTick::Status::kFailed:
|
||||
recovery_feedback_ = RecoveryFeedback::kFailed;
|
||||
|
||||
@@ -606,6 +606,11 @@ public:
|
||||
break;
|
||||
case RecoveryScript::kSucceeded:
|
||||
tick.status = RecoveryTick::Status::kSucceeded;
|
||||
if (succeed_with_path_)
|
||||
{
|
||||
tick.has_path = true;
|
||||
tick.path = success_path_;
|
||||
}
|
||||
active_ = false;
|
||||
break;
|
||||
case RecoveryScript::kFailed:
|
||||
@@ -616,6 +621,13 @@ public:
|
||||
return tick;
|
||||
}
|
||||
|
||||
/// @brief Thành công thì kèm một detour path (như 'detour_path' thật) — cần cho stand-down của kContact.
|
||||
void setSucceedWithPath(std::vector<robot_geometry_msgs::PoseStamped> path)
|
||||
{
|
||||
succeed_with_path_ = true;
|
||||
success_path_ = std::move(path);
|
||||
}
|
||||
|
||||
void cancel() override
|
||||
{
|
||||
++cancel_count_;
|
||||
@@ -699,6 +711,8 @@ private:
|
||||
std::size_t index_ = 0;
|
||||
|
||||
bool start_succeeds_ = true;
|
||||
bool succeed_with_path_ = false;
|
||||
std::vector<robot_geometry_msgs::PoseStamped> success_path_;
|
||||
bool active_ = false;
|
||||
bool emits_velocity_ = false;
|
||||
double recovery_speed_ = -0.1; ///< [m/s], âm = lùi
|
||||
|
||||
@@ -1534,6 +1534,47 @@ TEST(WalkingSkeletonEnvContact, HeldWithTheRouteSpentEscalatesToControllingFaile
|
||||
EXPECT_EQ(nonzero_after_settle, 0) << "brake must hold once re-confirmed";
|
||||
}
|
||||
|
||||
TEST(WalkingSkeletonEnvContact, DetourFromContactThatDidNotMoveTheRobotArmsTheStandDown)
|
||||
{
|
||||
// Run 6/9 16:30 (đám đông): người đứng 7 cm trước mũi -> cờ collision -> detour -> chạm lại ngay -> cờ -> detour ...
|
||||
// 4 lần rồi ABORT, vì stand-down không được vũ trang (trigger đọc ở cycle tick là mặc định). Chuỗi đúng: sau
|
||||
// detour do cờ collision mà robot không dịch, chạm lại thì kContact ĐỨNG RA — không phanh, không cờ thứ hai.
|
||||
Fixture fixture(envContactConfig());
|
||||
driveToControlling(fixture);
|
||||
std::vector<robot_geometry_msgs::PoseStamped> detour{ makeRequest(0.0).goal, makeRequest(3.0).goal };
|
||||
fixture.recovery_.setScript({ RecoveryScript::kSucceeded });
|
||||
fixture.recovery_.setSucceedWithPath(detour);
|
||||
|
||||
fixture.environment_.setContact(true, 0.10);
|
||||
for (int i = 0; i < 12 && fixture.loop_.state() == NavigationState::kControlling; ++i)
|
||||
{
|
||||
fixture.stepOnce();
|
||||
}
|
||||
ASSERT_EQ(fixture.loop_.state(), NavigationState::kRecovering);
|
||||
ASSERT_EQ(fixture.recovery_.lastTrigger(), RecoveryTrigger::kCollision);
|
||||
for (int i = 0; i < 4 && fixture.loop_.state() == NavigationState::kRecovering; ++i)
|
||||
{
|
||||
fixture.stepOnce();
|
||||
}
|
||||
ASSERT_EQ(fixture.loop_.state(), NavigationState::kControlling);
|
||||
|
||||
// Vẫn chạm 0.10 m, robot (pose giả) không dịch: không được có RECOVERING thứ hai trong 1.5 s, và lệnh phải
|
||||
// được trả về controller (đứng ra = không phanh).
|
||||
int recovering_again = 0;
|
||||
double max_cmd = 0.0;
|
||||
for (int i = 0; i < 30; ++i)
|
||||
{
|
||||
fixture.stepOnce();
|
||||
if (fixture.loop_.state() == NavigationState::kRecovering)
|
||||
{
|
||||
++recovering_again;
|
||||
}
|
||||
max_cmd = std::max(max_cmd, fixture.loop_.lastCommand().linear.x);
|
||||
}
|
||||
EXPECT_EQ(0, recovering_again) << "cờ collision nổ lại từ chính chỗ vừa detour";
|
||||
EXPECT_GT(max_cmd, 0.0) << "stand-down phải nhường lệnh cho controller";
|
||||
}
|
||||
|
||||
TEST(WalkingSkeletonEnvContact, ContactBeyondTheStoppingDistanceCapsSpeedWithoutBraking)
|
||||
{
|
||||
Fixture fixture(envContactConfig());
|
||||
|
||||
Reference in New Issue
Block a user