Skip to main content

ros2-lifecycle

Author and debug ROS 2 managed (lifecycle) nodes, lifecycle publishers, ordered bringup, and bond-style managers (Nav2-like). Use when implementing configure/activate/deactivate, inactive topics dropping data, or lifecycle managers.

来源信息

仓库
guilyx/dotfiles
最近来源活动
2026年8月12日 19:39
检测到的 SKILL.md 语言
英语
星标
0
分支
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
ros2-lifecycle
description
Author and debug ROS 2 managed (lifecycle) nodes, lifecycle publishers, ordered bringup, and bond-style managers (Nav2-like). Use when implementing configure/activate/deactivate, inactive topics dropping data, or lifecycle managers.
# ROS 2 Lifecycle (Managed Nodes) ## State machine `unconfigured → inactive → active → finalized` Error from any state → `on_error` → typically back to unconfigured. | Transition | Put here | |------------|----------| | `on_configure` | Allocate, declare params, create pubs/subs that should exist while inactive; load plugins | | `on_activate` | Start processing; activate lifecycle publishers; start bonds | | `on_deactivate` | Stop commanding; keep allocations; deactivate lifecycle pubs | | `on_cleanup` | Destroy entities, unload plugins → unconfigured | | `on_shutdown` | Final teardown | | `on_error` | Best-effort recover; assume hardware may be wedged | ## Lifecycle publishers A `LifecyclePublisher` **does not publish while inactive**. Ordinary `create_publisher` **will** — do not mix unless intentional (e.g. diagnostics always on). ## Ordered bringup (Nav2-style) Activate **dependencies first**: drivers / maps → localization → planning → control → mission. Deactivate **reverse**. Prefer a **lifecycle manager** (service transitions + optional **bond/heartbeat**) over launch `TimerAction` sleeps. If a bonded node dies, deactivate dependents so controllers stop commanding. ## CLI ```bash ros2 lifecycle list /node ros2 lifecycle get /node ros2 lifecycle set /node configure ros2 lifecycle set /node activate ros2 lifecycle set /node deactivate ``` Launch: `LifecycleNode` + `ChangeState` / `OnStateTransition`, or a manager node. ## Failure modes - Stuck `unconfigured`: `on_configure` FAILURE — params, device open, plugin load. - Publisher in graph but silence: still **inactive**, or lifecycle pub not activated. - Crash on activate: work that needed live data done in the wrong transition. - Double-create across cycles: destroy in `on_cleanup`. ## Tests configure-fail; activate; deactivate→reactivate (no leak / no double subscribe); shutdown from each state; kill process under bond and assert safe stop.
在 GitHub 查看