feat: lan truyen BaseNavigation::emergency()/clearEmergency() len tren
NavigationServer::emergency() phan anh ngay tren thread goi (getTwist tra 0, getFeedback bao EMERGENCY) truoc khi ham tra ve, du control thread dang block trong plugin nao; don dep that (planner/recovery/ action/mission layer) chay o chu ky ke cua control thread. State NavigationState::kEmergency la state GIU, khong terminal: pause/resume/ cancel/goal moi deu bi bo qua, chi clearEmergency() moi thoat, ve kIdle. MissionLayer: emergency() -> drain hang doi, goi cancel toi navigation dung 1 lan, chuyen MissionState::EMERGENCY; clearEmergency() ve CLEAR_EMERGENCY, khong tu chay lai gi, cho order ke tiep. Test moi cho ca 2 lop (navigation_server_test, mission_layer_test, state_machine_test, walking_skeleton_test) phu: force-zero-truoc-cycle, tu choi moveTo/instantActions khi dang chot, huy goal con pending, mo chot roi nhan goal moi.
This commit is contained in:
@@ -303,6 +303,7 @@ void ControlLoop::reset()
|
||||
pause_requested_ = false;
|
||||
resume_requested_ = false;
|
||||
cancel_requested_ = false;
|
||||
emergency_ = false;
|
||||
|
||||
planner_feedback_ = PlannerFeedback::kIdle;
|
||||
controller_feedback_ = ControllerFeedback::kIdle;
|
||||
@@ -461,6 +462,14 @@ bool ControlLoop::submit(const NavigationRequest& incoming, std::string& reason)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Hàng rào thứ hai (hàng rào một ở NavigationServer, trước cả mission layer): đang giữ dừng khẩn
|
||||
// thì không có goal nào được xếp chờ — xếp chờ là sau khi gỡ chốt robot tự chạy mà không ai gửi.
|
||||
if (emergency_)
|
||||
{
|
||||
reason = "emergency stop latched";
|
||||
return false;
|
||||
}
|
||||
|
||||
// D8: yêu cầu mang action cần có ActionPort; từ chối tại cửa thay vì kẹt sau khi tới goal.
|
||||
if (!request.actions.empty() && deps_.action == nullptr)
|
||||
{
|
||||
@@ -578,6 +587,31 @@ void ControlLoop::requestCancel()
|
||||
cancel_requested_ = true;
|
||||
}
|
||||
|
||||
void ControlLoop::requestEmergency()
|
||||
{
|
||||
if (!emergency_)
|
||||
{
|
||||
// Sườn lên: LỖI mức vận hành, không gắn [debug], không có khoá tắt — dòng này là bằng chứng
|
||||
// duy nhất trong log rằng robot dừng vì lệnh khẩn chứ không phải vì hỏng.
|
||||
robot::log_warning("[move_base2] EMERGENCY STOP latched (mission %llu%s): command zero, planner/"
|
||||
"recovery/action cancelled, mission queue wiped. Goals are rejected until "
|
||||
"clearEmergency().\n",
|
||||
static_cast<unsigned long long>(has_active_request_ ? active_request_.mission_sequence_id : 0),
|
||||
has_pending_request_ ? ", pending request dropped" : "");
|
||||
}
|
||||
emergency_ = true;
|
||||
has_pending_request_ = false;
|
||||
}
|
||||
|
||||
void ControlLoop::requestClearEmergency()
|
||||
{
|
||||
if (emergency_)
|
||||
{
|
||||
robot::log_info("[move_base2] emergency cleared: back to IDLE, waiting for a new goal.\n");
|
||||
}
|
||||
emergency_ = false;
|
||||
}
|
||||
|
||||
void ControlLoop::collectPlannerResult()
|
||||
{
|
||||
PlanResult result;
|
||||
@@ -980,6 +1014,7 @@ bool ControlLoop::step()
|
||||
input.pause_requested = pause_requested_;
|
||||
input.resume_requested = resume_requested_;
|
||||
input.cancel_requested = cancel_requested_;
|
||||
input.emergency = emergency_;
|
||||
input.planner = planner_feedback_;
|
||||
input.controller = controller_feedback_;
|
||||
input.recovery = recovery_feedback_;
|
||||
|
||||
Reference in New Issue
Block a user