feat: resume driving during a stationary recovery; host intrusion detector
- recovery_resume: while an allowed stationary behavior (detour_path) runs, probe the local planner; its command never reaches the arbiter; after N moving cycles cancel the recovery and resume the current plan, capped per leg - host the env_monitor_core IntrusionDetector (EnvContext, footprint) - runtime config: recovery_resume keys, priest_fallback keys, evade max_tf_gap / view_loss_timeout, SBPL detour options, env_monitor tuning
This commit is contained in:
@@ -473,7 +473,6 @@ private:
|
||||
|
||||
// --- EnvMonitor -------------------------------------------------------------------------------
|
||||
env_monitor_core::EnvNeeds env_needs_;
|
||||
std::vector<env_monitor_core::EnvScan> env_scan_scratch_;
|
||||
std::vector<std::pair<double, double>> env_footprint_scratch_;
|
||||
env_monitor_core::EnvVerdict env_verdict_; ///< verdict của cycle này (vào state machine + trọng tài).
|
||||
EnvGeometry env_geometry_; ///< mẫu nặng gần nhất (giữ giữa hai tick 5 Hz để log/ghi).
|
||||
|
||||
@@ -161,6 +161,12 @@ struct StateMachineConfig
|
||||
/// Cho phép chạy recovery hay không. false = mọi lỗi dẫn thẳng tới ABORTED.
|
||||
bool recovery_enabled = true;
|
||||
|
||||
bool recovery_resume_enabled = false; ///< [bool] Bật thử controller trong recovery đứng yên.
|
||||
std::vector<std::string> recovery_resume_behaviors = {"detour_path"}; ///< [tên] Behavior được thử.
|
||||
int recovery_resume_confirm_cycles = 3; ///< [cycle] Số lệnh chuyển động liên tiếp cần xác nhận.
|
||||
double recovery_resume_min_speed = 0.05; ///< [m/s] Độ lớn tốc độ tiến/lùi tối thiểu của lệnh thử.
|
||||
int recovery_resume_max_per_leg = 3; ///< [lần/leg] Trần số lần huỷ recovery trong một chặng.
|
||||
|
||||
/// Route đã resolve của từng @ref RecoveryTrigger. Rỗng = mọi trigger dùng list legacy chung.
|
||||
RecoveryRoutes recovery_routes;
|
||||
|
||||
@@ -212,6 +218,7 @@ struct StateMachineInput
|
||||
bool planner_costmap_wait_finished = false;
|
||||
ControllerFeedback controller = ControllerFeedback::kIdle;
|
||||
RecoveryFeedback recovery = RecoveryFeedback::kIdle;
|
||||
bool recovery_probe_moving = false; ///< Lệnh thử hợp lệ có |linear.x| đạt ngưỡng [m/s].
|
||||
ActionFeedback action = ActionFeedback::kIdle;
|
||||
|
||||
/**
|
||||
@@ -318,6 +325,7 @@ struct StateMachineOutput
|
||||
bool start_recovery = false; ///< Khởi động behavior @ref recovery_index với @ref recovery_trigger.
|
||||
bool tick_recovery = false; ///< Gọi update() của behavior đang chạy.
|
||||
bool cancel_recovery = false; ///< Yêu cầu behavior đang chạy dừng.
|
||||
bool recovery_resumed = false; ///< Huỷ recovery vì controller có lệnh trở lại.
|
||||
|
||||
bool start_action = false; ///< D8: khởi động action thứ @ref action_index của yêu cầu hiện tại.
|
||||
bool tick_action = false; ///< D8: gọi update() của action đang chạy.
|
||||
@@ -438,6 +446,12 @@ public:
|
||||
return config_;
|
||||
}
|
||||
|
||||
/// @brief Cho phép thử resume khi tính năng bật và quota [lần/leg] còn.
|
||||
bool recoveryResumeAvailable() const
|
||||
{
|
||||
return config_.recovery_resume_enabled && recovery_resumes_this_leg_ < config_.recovery_resume_max_per_leg;
|
||||
}
|
||||
|
||||
/// @brief Index behavior đang chạy / sẽ chạy ở lần recovery kế tiếp. Dùng để assert trong test.
|
||||
std::size_t nextRecoveryIndex() const
|
||||
{
|
||||
@@ -548,6 +562,8 @@ private:
|
||||
bool sensor_stale_active_ = false; ///< Đang trong chuỗi stale (sensor_stale_since_ có nghĩa).
|
||||
|
||||
std::size_t recovery_index_ = 0;
|
||||
int recovery_resume_cycles_ = 0;
|
||||
int recovery_resumes_this_leg_ = 0;
|
||||
RecoveryTrigger active_recovery_trigger_ = RecoveryTrigger::kPlanningFailed;
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#define MOVE_BASE2_NAVIGATION_RUNTIME_H_
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -108,8 +107,7 @@ public:
|
||||
tf_ = tf;
|
||||
}
|
||||
|
||||
void setSensorReader(const robot_sensor_ports::SensorReader* reader) { sensors_ = reader; }
|
||||
bool sampleScans(const std::vector<std::string>& topics, env_monitor_core::EnvSample& out) override;
|
||||
bool sampleFootprint(std::vector<std::pair<double, double>>& out) override;
|
||||
void refresh() override;
|
||||
bool sampleGeometry(const EnvGeometryRequest& request, EnvGeometry& out) override;
|
||||
bool sweepTrajectory(const EnvTrajectoryRequest& request, SweepResult& out,
|
||||
@@ -122,8 +120,6 @@ private:
|
||||
|
||||
robot_costmap_2d::Costmap2DROBOT* costmap_ = nullptr;
|
||||
std::shared_ptr<tf3::BufferCore> tf_;
|
||||
const robot_sensor_ports::SensorReader* sensors_ = nullptr; ///< Non-owning.
|
||||
std::map<std::string, bool> scan_failed_;
|
||||
GridScratch scratch_; ///< chỉ control thread dùng
|
||||
std::vector<robot_geometry_msgs::PoseStamped> traj_scratch_; ///< quỹ đạo đã quy về frame lưới
|
||||
};
|
||||
|
||||
@@ -133,10 +133,9 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Raw scans and fixed-frame poses; false means footprint or base pose unavailable.
|
||||
virtual bool sampleScans(const std::vector<std::string>& topics, env_monitor_core::EnvSample& out)
|
||||
/// @brief Unpadded footprint in the base frame; false means unavailable.
|
||||
virtual bool sampleFootprint(std::vector<std::pair<double, double>>& out)
|
||||
{
|
||||
(void)topics;
|
||||
(void)out;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user