temporary storage 7/9/2026 20:41
This commit is contained in:
@@ -11,8 +11,8 @@ Package hiện có 4 plugin mẫu dưới `plugins/`:
|
||||
1. Kế thừa `recovery_core::RecoveryBehavior`.
|
||||
2. Override hook `onConfigure()` (tuỳ chọn) — đọc param riêng qua `robot::NodeHandle("~/" + name)`;
|
||||
ngữ cảnh tf/global_path/costmap lấy qua `ctx()`.
|
||||
3. Override `onStart(goal)` + `onUpdate(dt)` theo họ (xem dưới). KHÔNG override
|
||||
`configure/start/update/cancel` — base đã lo guard vòng đời/timeout/cancel/elapsed.
|
||||
3. Override `onStart(goal)` + `onUpdate()` theo họ (xem dưới). KHÔNG override
|
||||
`configure/start/update/cancel` — base đã lo guard vòng đời/cancel.
|
||||
4. Thêm factory `static RecoveryBehaviorPtr create()` **không tham số** + `BOOST_DLL_ALIAS(...)`.
|
||||
|
||||
## Vòng đời (goal-driven)
|
||||
@@ -22,7 +22,7 @@ configure(name, ctx) // 1 lần: cache ctx, đọc config chung, gọi onCo
|
||||
│
|
||||
start(goal) // mỗi lượt: chốt mục tiêu RUNTIME (angle/distance/pose), gọi onStart()
|
||||
│
|
||||
loop update(dt) // mỗi cycle tới khi status != kRunning; base tick elapsed + guard
|
||||
loop update() // mỗi cycle tới khi status != kRunning; base guard vòng đời/cancel
|
||||
│
|
||||
[cancel()] // update() kế tiếp -> stop output + kCancelled
|
||||
```
|
||||
@@ -37,7 +37,7 @@ qua `goal.params` (vd `goal.params["angular_speed"] = 0.8`).
|
||||
|----|----------|--------|
|
||||
| A. path | `onUpdate()` (one-shot) | `RecoveryResult::PathOut(path, kSucceeded)` |
|
||||
| B. none | `onUpdate()` (one-shot) | `RecoveryResult::Succeeded()` / `Failed()` |
|
||||
| C. velocity | `onStart()` chốt goal + `onUpdate(dt)` mỗi cycle | `RecoveryResult::Velocity(twist, kRunning\|kSucceeded)` |
|
||||
| C. velocity | `onStart()` chốt goal + `onUpdate()` mỗi cycle | `RecoveryResult::Velocity(twist, kRunning\|kSucceeded)` |
|
||||
|
||||
Mọi kết quả nên gắn feedback qua `.withProgress(progress, remaining)` và `.withMessage(...)` để
|
||||
caller giám sát tiến độ (progress ∈ [0,1], remaining theo rad/m).
|
||||
@@ -55,7 +55,7 @@ class SpinRecovery : public recovery_core::RecoveryBehavior {
|
||||
return std::make_shared<SpinRecovery>();
|
||||
}
|
||||
protected:
|
||||
// override onConfigure()/onStart(goal)/onUpdate(dt)...
|
||||
// override onConfigure()/onStart(goal)/onUpdate()...
|
||||
};
|
||||
} // namespace recovery_plugins
|
||||
|
||||
@@ -80,7 +80,7 @@ recovery_core::RecoveryGoal goal;
|
||||
goal.angle = 1.57; // "quay 90 độ ngay lượt này"
|
||||
recovery_core::RecoveryResult r = behavior->start(goal);
|
||||
while (r.status == recovery_core::RecoveryStatus::kRunning) {
|
||||
r = behavior->update(dt); // publish r.command; đọc r.progress/r.remaining/r.message
|
||||
r = behavior->update(); // publish r.command; đọc r.progress/r.remaining/r.message
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user