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:
@@ -31,7 +31,6 @@
|
||||
#include <move_base2/ports/costmap_status_port.h>
|
||||
#include <move_base2/ports/environment_port.h>
|
||||
#include <move_base2/ports/mission_port.h>
|
||||
#include <move_base2/ports/path_check_port.h>
|
||||
#include <move_base2/ports/planner_port.h>
|
||||
#include <move_base2/ports/pose_port.h>
|
||||
#include <move_base2/ports/recovery_port.h>
|
||||
@@ -864,125 +863,6 @@ private:
|
||||
mutable std::size_t query_count_ = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class FakePathCheckPort
|
||||
* @brief Cổng kiểm tuyến giả: kịch bản quyết định tuyến sạch hay bẩn, không cần costmap thật.
|
||||
*
|
||||
* `available_ = false` mô phỏng "không kết luận được" (thiếu TF/costmap) — bên gọi phải coi đó là
|
||||
* không biết, KHÔNG được suy thành sạch hay bẩn.
|
||||
*/
|
||||
class FakePathCheckPort final : public PathCheckPort
|
||||
{
|
||||
public:
|
||||
bool checkPlan(const std::vector<robot_geometry_msgs::PoseStamped>& plan,
|
||||
std::size_t from_index, double horizon, PlanBlockResult& out) const override
|
||||
{
|
||||
(void)from_index;
|
||||
(void)horizon;
|
||||
++query_count_;
|
||||
|
||||
if (!available_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
out = PlanBlockResult();
|
||||
out.blocked = blocked_;
|
||||
out.distance = distance_;
|
||||
out.scanned = plan.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @param distance [m] khoảng cách tới vật cản — bên gọi so với `min_detour_distance`.
|
||||
void setBlocked(bool blocked, double distance = 1.5)
|
||||
{
|
||||
blocked_ = blocked;
|
||||
distance_ = distance;
|
||||
}
|
||||
|
||||
/// Phép đo 3 (cung lệnh): kịch bản riêng, không dính `setBlocked` của phép đo 1.
|
||||
bool checkMotion(const robot_geometry_msgs::PoseStamped& robot_pose, double v, double omega,
|
||||
const MotionCheckParams& params, MotionBlockResult& out) const override
|
||||
{
|
||||
(void)robot_pose;
|
||||
(void)omega;
|
||||
(void)params;
|
||||
++motion_query_count_;
|
||||
if (!motion_available_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
out = MotionBlockResult();
|
||||
out.scanned = std::fabs(v) >= params.min_speed ? 1 : 0;
|
||||
out.blocked = out.scanned > 0 && motion_blocked_;
|
||||
out.sample = out.blocked ? 1 : -1;
|
||||
out.distance = out.blocked ? motion_distance_ : 0.0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @param distance [m] quãng dọc cung tới điểm chạm — bên gọi so với `collision_stop_distance`.
|
||||
void setMotionBlocked(bool blocked, double distance = 0.2)
|
||||
{
|
||||
motion_blocked_ = blocked;
|
||||
motion_distance_ = distance;
|
||||
}
|
||||
|
||||
bool robotBodyExtents(double& front, double& rear, double& side) const override
|
||||
{
|
||||
if (!body_available_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
front = body_front_;
|
||||
rear = body_rear_;
|
||||
side = body_side_;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @brief Giả lập footprint costmap; mặc định KHÔNG có (như PathCheckPort gốc).
|
||||
void setBodyExtents(double front, double rear, double side)
|
||||
{
|
||||
body_available_ = true;
|
||||
body_front_ = front;
|
||||
body_rear_ = rear;
|
||||
body_side_ = side;
|
||||
}
|
||||
|
||||
void setMotionAvailable(bool available)
|
||||
{
|
||||
motion_available_ = available;
|
||||
}
|
||||
|
||||
std::size_t motionQueryCount() const
|
||||
{
|
||||
return motion_query_count_;
|
||||
}
|
||||
|
||||
void setAvailable(bool available)
|
||||
{
|
||||
available_ = available;
|
||||
}
|
||||
|
||||
std::size_t queryCount() const
|
||||
{
|
||||
return query_count_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool blocked_ = false;
|
||||
bool available_ = true;
|
||||
double distance_ = 1.5; // [m]
|
||||
mutable std::size_t query_count_ = 0;
|
||||
bool motion_blocked_ = false;
|
||||
bool body_available_ = false;
|
||||
double body_front_ = 0.0;
|
||||
double body_rear_ = 0.0;
|
||||
double body_side_ = 0.0;
|
||||
bool motion_available_ = true;
|
||||
double motion_distance_ = 0.2; // [m]
|
||||
mutable std::size_t motion_query_count_ = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class FakeEnvironmentPort
|
||||
* @brief Cổng môi trường giả cho EnvMonitor: kịch bản quyết định cost_to_go / tiếp xúc, không cần costmap.
|
||||
|
||||
Reference in New Issue
Block a user