This commit is contained in:
2026-08-10 17:20:30 +07:00
parent 2b4c897015
commit 65f8c7ce1c
3 changed files with 122 additions and 0 deletions

View File

@@ -302,6 +302,35 @@ void NavigationServer::refreshFeedback()
host_state = robot::move_base_core::State::ACTIVE;
}
// Chốt kết quả cuối — xem @ref latched_result_. Phải chạy SAU khối mask ở trên: giữa hai chặng
// của cùng một order, SUCCEEDED đã được đổi thành ACTIVE nên không bị chốt nhầm thành "order xong".
//
// Ba nhánh, loại trừ nhau:
// terminal -> ghi chốt (lõi chỉ đi qua đây một cycle);
// PENDING (kIdle) mà đang có chốt -> báo lại chốt thay vì PENDING;
// mọi state hoạt động khác -> có việc mới, xoá chốt.
//
// Xoá chốt theo STATE chứ không theo lời gọi `submit`: goal còn vào qua mission layer
// (`missionLayer().submitGoal`) và qua bridge, ba đường vào khác nhau. Bám vào state là chỗ duy
// nhất cả ba đường đều đi qua.
if (host_state == robot::move_base_core::State::SUCCEEDED ||
host_state == robot::move_base_core::State::ABORTED ||
host_state == robot::move_base_core::State::PREEMPTED)
{
latched_result_ = host_state;
}
else if (host_state == robot::move_base_core::State::PENDING)
{
if (latched_result_ != robot::move_base_core::State::PENDING)
{
host_state = latched_result_;
}
}
else
{
latched_result_ = robot::move_base_core::State::PENDING;
}
nav_feedback_->navigation_state = host_state;
const char* reason = loop_.lastReason();