feat: preempt a running search via robot_nav_core::Preemptable + sbpl abort flag
- Implements Preemptable::preempt() (atomic store), checked between the up
to 3 internal ARA* runs a single makePlan() can do (free_start_heading
retry, realign) — the runs now share one time budget instead of each
getting the full allocated_time, and a preempt between runs stops the
next one from starting (kMinReplanBudget floor so a preempt right at the
edge still gets a minimal attempt).
- Probes for the vendored sbpl's abort flag at runtime via
dlsym(RTLD_DEFAULT, "sbpl_abort_flag_abi_version") before touching
set_abort_flag() — logs an error if the header advertises the flag but
the loaded .so doesn't (header/lib version mismatch), a warning if built
against an sbpl without the flag at all (falls back to the old
run-to-allocated_time behaviour, no crash).
- primitive_filename now resolves relative to PNKX_NAV_CORE_CONFIG_DIR
instead of only working from one dev machine's absolute path.
- CMakeLists.txt: target_include_directories(... BEFORE PRIVATE
${SBPL_INCLUDE_DIRS}) so this package's own sbpl header wins over a
same-named one pulled in transitively (apt ros-noetic-sbpl in
/opt/ros/noetic/include has no abort flag and was winning silently);
configure-time check for SBPL_HAS_ABORT_FLAG in the resolved header with
a loud warning if missing.
Depends on Test/sbpl commit bd89924 (the abort flag itself) and
pnkx_nav_core commit 2b0993b (robot_nav_core::Preemptable header).
Measured on the dev machine (2026-09-12, apt ros-noetic-sbpl removed,
rebuilt): "preempted after N ms" with N in the tens of ms instead of
running to allocated_time (was up to 9 s). Full numbers:
Test/move_base2/docs/PLAN_LIFECYCLE_CANCEL_PAUSE_RESUME.md section 6.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef SBPL_LATTICE_PLANNER_H
|
||||
#define SBPL_LATTICE_PLANNER_H
|
||||
|
||||
#include <atomic>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
@@ -19,10 +20,12 @@ using namespace std;
|
||||
|
||||
// global representation
|
||||
#include <robot_nav_core/base_global_planner.h>
|
||||
#include <robot_nav_core/preemptable.h>
|
||||
|
||||
namespace sbpl_lattice_planner{
|
||||
|
||||
class SBPLLatticePlanner : public robot_nav_core::BaseGlobalPlanner{
|
||||
class SBPLLatticePlanner : public robot_nav_core::BaseGlobalPlanner,
|
||||
public robot_nav_core::Preemptable {
|
||||
public:
|
||||
|
||||
/**
|
||||
@@ -58,6 +61,19 @@ public:
|
||||
const robot_geometry_msgs::PoseStamped& goal,
|
||||
std::vector<robot_geometry_msgs::PoseStamped>& plan);
|
||||
|
||||
/**
|
||||
* @brief Cắt lượt makePlan đang chạy (robot_nav_core::Preemptable, 2026-09-11).
|
||||
*
|
||||
* Gọi từ thread KHÁC thread đang ở trong makePlan: một atomic store, không lock. ARA* thấy cờ ở
|
||||
* vòng expand kế và trả "không có nghiệm"; các lượt replan nội bộ (retry heading thật, căn lại
|
||||
* heading) không được khởi động nữa. makePlan trả false. Cờ được xoá ở đầu mỗi makePlan.
|
||||
*
|
||||
* Chỉ có hiệu lực khi libsbpl đang nạp có abort flag (SBPL_HAS_ABORT_FLAG + probe
|
||||
* sbpl_abort_flag_abi_version lúc initialize); không có thì preempt() chỉ đặt cờ cho phần kiểm
|
||||
* giữa các lượt replan, còn một lượt ARA* đang chạy vẫn đi tới hết allocated_time.
|
||||
*/
|
||||
void preempt() override;
|
||||
|
||||
/**
|
||||
* @brief Nạp lưới NGOÀI thay cho lưới sống của costmap trong các lần makePlan kế tiếp.
|
||||
*
|
||||
@@ -92,6 +108,9 @@ private:
|
||||
bool initialized_;
|
||||
|
||||
SBPLPlanner* planner_;
|
||||
|
||||
std::atomic<bool> preempt_{false}; ///< Cờ cắt lượt makePlan đang chạy (Preemptable).
|
||||
bool sbpl_abort_supported_ = false; ///< libsbpl đang nạp hiểu set_abort_flag (probe lúc initialize).
|
||||
EnvironmentNAVXYTHETALAT* env_;
|
||||
|
||||
std::string planner_type_; /**< sbpl method to use for planning. choices are ARAPlanner and ADPlanner */
|
||||
|
||||
Reference in New Issue
Block a user