behaviortree_node_creation

Scaffolds BehaviorTree.CPP and BehaviorTree.ROS2 leaf nodes with ports, registration, and XML usage.

Updated Aug 16, 2026
One-click install
npx skills add https://github.com/three1324/yeonjinautomotive --skill behaviortree-node-creation-three1324
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: behaviortree_node_creation
Source: https://github.com/three1324/yeonjinautomotive/tree/main/.claude/skills/behaviortree_node_creation
Command: npx skills add https://github.com/three1324/yeonjinautomotive --skill behaviortree-node-creation-three1324

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing a custom behavior-tree leaf node requires choosing the correct base class, declaring ports, registering the node with the factory, and wiring it into XML — mistakes in any step cause runtime failures that are hard to diagnose. ## Core Features & Use Cases - Base-class selection guide: Maps your node's behavior (sync, async, condition, ROS action/service/topic) to the right BehaviorTree.CPP or BehaviorTree.ROS2 base class. - Complete code templates: Provides working C++ skeletons for SyncActionNode, StatefulActionNode, RosActionNode, and the other wrappers, including port declarations and callback overrides. - Registration and XML v4 wiring: Shows factory registration, plugin export via BT_REGISTER_NODES / CreateRosNodePlugin, and BTCPP_format="4" tree definitions. - Use Case: You need a node that calls a ROS 2 action from a behavior tree — follow the RosActionNode template, override setGoal and onResultReceived, register it with RosNodeParams, and reference it in your XML. ## Quick Start Ask the AI to write a behavior tree node that calls a ROS 2 action named sleep_action with a msec input port, including registration and XML usage.

Frequently Asked Questions about behaviortree_node_creation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a custom behavior tree node in ROS 2?

Subclass the appropriate BehaviorTree.ROS2 wrapper such as RosActionNode or RosServiceNode, override callbacks like setGoal and onResultReceived, then register it with the factory using RosNodeParams carrying your node handle. Reference it by name in your XML tree.

Which BehaviorTree.CPP base class should I use for my node?

Use SyncActionNode for quick work finishing in one tick, StatefulActionNode for async or long-running tasks, and ConditionNode for boolean checks. For ROS 2 interfaces, use the RosActionNode, RosServiceNode, RosTopicPubNode, or RosTopicSubNode wrappers instead.

How do I register a behavior tree node as a plugin?

Use the BT_REGISTER_NODES macro for plain BT.CPP nodes and load with registerFromPlugin, or use CreateRosNodePlugin plus RegisterRosNode for ROS 2 wrappers. ROS 2 plugins require RosNodeParams with the node handle passed at registration.

Why does my behavior tree node throw when returning IDLE from onFeedback?

RosActionNode's onFeedback callback must not return IDLE — doing so throws an exception. Return RUNNING to continue, or SUCCESS/FAILURE to finish the node early based on the feedback content.

Can I mix BehaviorTree.CPP v3 and v4 XML formats?

No, mixing formats causes parsing issues. Set BTCPP_format="4" on the root element for new trees, and migrate existing v3 trees using the convert_v3_to_v4.py script provided by BehaviorTree.CPP.