Skip to main content
ClaudeWave
Slash Command200 repo starsupdated 4d ago

new-controller

Scaffold a ros2_control controller or broadcaster — base class, command/state interface config, RT-safe update(), generate_parameter_library, pluginlib export, and a test.

Install in Claude Code
Copy
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/harunkurtdev/ros2-claude-code-template/HEAD/.claude/commands/new-controller.md -o ~/.claude/commands/new-controller.md
Then start a new Claude Code session; the slash command loads automatically.

new-controller.md

Scaffold a ros2_control controller/broadcaster inside an existing package.

Argument handling (`$ARGUMENTS`):
1. `<package>` — existing package under `src/` (required).
2. `<ClassName>` — CamelCase controller class (required).
3. `<kind>` — `plain` (`controller_interface::ControllerInterface`),
   `chainable` (`ChainableControllerInterface`), or `broadcaster`
   (read-only, `NONE` command interfaces).
4. `[lang]` — `cpp` (default; ros2_control controllers are C++).

If anything is missing, ask before scaffolding.

Process:
1. Read the skill `ros2_controller_creation` and the rule
   `ros2_control_architecture.md`; pick the closest existing controller
   in `~/nav2_ws/src/ros2_controllers/` to mirror
   (`forward_command_controller` for plain, `diff_drive_controller` for
   chainable, `imu_sensor_broadcaster` for broadcaster).
2. Create:
   * `include/<package>/<snake_class>.hpp` — the class deriving from the
     chosen base, overriding `on_init`, `command_interface_configuration`,
     `state_interface_configuration`, the lifecycle callbacks, and the
     right update method (`update()` for plain; `update_reference_from_subscribers`
     + `update_and_write_commands` for chainable). Broadcasters return
     `NONE` for command config.
   * `src/<snake_class>.cpp` — implementation + `PLUGINLIB_EXPORT_CLASS`
     with the correct base class.
   * `src/<snake_class>_parameters.yaml` — `generate_parameter_library`
     input with sensible `validation` / `read_only`.
   * `<package>_plugin.xml` (or extend an existing one) with the right
     `base_class_type`.
   * `test/test_<snake_class>.cpp` — gtest that drives
     `on_configure → on_activate`, calls the update method with mock
     loaned interfaces, and asserts command values.
3. Wire `CMakeLists.txt`: `generate_parameter_library(...)`,
   `add_library`, link `controller_interface::controller_interface` +
   the params lib + `pluginlib::pluginlib`, and
   `pluginlib_export_plugin_description_file(controller_interface <xml>)`.
4. Add deps to `package.xml` (`controller_interface`, `pluginlib`,
   `generate_parameter_library`, `realtime_tools`, message pkgs).
5. Remind: nothing RT-unsafe in the update method (no alloc/locks/throw/
   unthrottled logging; use `RealtimePublisher`/`RealtimeThreadSafeBox`).
6. `pre-commit run --files <touched files>`.
7. Print: files created, the plugin alias, and a `controllers.yaml`
   snippet plus `ros2 run controller_manager spawner <name>`.

Never put parameter handling outside `generate_parameter_library`, and
never rename the plugin alias of an existing controller.
behaviortree-reviewerSubagent

Use proactively before opening a PR that adds or changes BehaviorTree.CPP nodes or BehaviorTree.ROS2 wrappers (RosActionNode/RosServiceNode/RosTopicPub/SubNode, TreeExecutionServer). Reviews a diff against BT.CPP v4 conventions — node base-class choice, non-blocking ticks, ports/blackboard typing, factory/plugin registration, XML v4, and the ROS 2 wrapper contract. Returns a punch list with file:line anchors, not a rewrite.

clean-arch-architectSubagent

Use when a design decision touches Clean Architecture boundaries in a ROS 2 project — which layer a new behaviour belongs to, whether a port belongs in domain or application, whether a new node should be lifecycle-managed, whether to compose nodes or split packages. Returns an architectural recommendation with trade-offs, not implementation.

ecs-architectSubagent

Use when a design decision touches the gz-sim ECS — where new state should live, which system phase should write it, how to avoid coupling, whether to add a component vs. a member variable, whether a new system should be split or merged with an existing one. Returns an architectural recommendation with trade-offs, not implementation.

gz-style-reviewerSubagent

Use proactively before opening any gz-sim PR. Reviews a diff against the project's C++17 style, ECS conventions, plugin registration patterns, CMake structure, test placement, Migration.md / Changelog.md expectations, and pre-commit configuration. Returns a punch list, not a rewrite.

ros2-controllers-reviewerSubagent

Use proactively before opening a PR that adds or changes a ros2_control controller, broadcaster, or hardware component (incl. URDF <ros2_control> bringup). Reviews a diff against ros2_controllers / ros2_control_demos conventions — controller & hardware lifecycle, command/state interface configuration, real-time safety of update()/read()/write(), generate_parameter_library usage, pluginlib registration, chainable-controller correctness, URDF wiring, and tests. Returns a punch list with file:line anchors, not a rewrite.

ros2-style-reviewerSubagent

Use proactively before opening any ROS 2 / Nav 2 PR. Reviews a diff against this template's Clean Architecture, ROS 2 communication, lifecycle, testing, and Nav 2 plugin conventions. Returns a punch list with file:line anchors, not a rewrite.

vda5050-reviewerSubagent

Use proactively before opening a PR that touches a VDA 5050 connector / fleet bridge. Reviews a diff against VDA 5050 v3.0.0 protocol compliance (topics, QoS, header rules, base/horizon, action state machine, schema validation) and the template's Clean Architecture for the MQTT↔Nav 2 bridge. Returns a punch list with file:line anchors, not a rewrite.

buildSlash Command

Build the colcon workspace (optionally a single package) and report the outcome.