Skip to content

Commit e8118fd

Browse files
committed
add some documentation to classes
1 parent 88248a1 commit e8118fd

File tree

8 files changed

+75
-3
lines changed

8 files changed

+75
-3
lines changed

include/behaviortree_cpp/actions/script_node.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818

1919
namespace BT
2020
{
21+
/**
22+
* @brief The ScriptNode executes a piece of script code to set or modify
23+
* entries in the Blackboard.
24+
*
25+
* The script is passed via the input port "code" and can use the BT++ scripting
26+
* language syntax. For instance:
27+
*
28+
* <Script code=" msg:='hello world' " />
29+
* <Script code=" A:=42; B:=3.14 " />
30+
*
31+
* The node always returns SUCCESS after executing the script.
32+
*/
2133
class ScriptNode : public SyncActionNode
2234
{
2335
public:

include/behaviortree_cpp/condition_node.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818

1919
namespace BT
2020
{
21+
/**
22+
* @brief The ConditionNode is a leaf node used to check a condition.
23+
*
24+
* Unlike ActionNodes, a ConditionNode should NOT alter the system
25+
* and should NOT return RUNNING. It should return SUCCESS or FAILURE
26+
* synchronously to indicate whether a condition is met.
27+
*
28+
* Conditions are typically used to check the state of the world or
29+
* the system before performing an action (e.g., "IsDoorOpen", "IsBatteryLow").
30+
*/
2131
class ConditionNode : public LeafNode
2232
{
2333
public:

include/behaviortree_cpp/control_node.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919

2020
namespace BT
2121
{
22+
/**
23+
* @brief The ControlNode is the base class for nodes that can have multiple children.
24+
*
25+
* ControlNodes determine the order and conditions under which their children are
26+
* ticked.
27+
*
28+
* Each derived class implements specific rules about if, when, and how many
29+
* times children are ticked.
30+
*/
2231
class ControlNode : public TreeNode
2332
{
2433
protected:

include/behaviortree_cpp/decorator_node.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55

66
namespace BT
77
{
8+
/**
9+
* @brief The DecoratorNode is the base class for nodes that have exactly one child.
10+
*
11+
* DecoratorNodes modify the behavior of their child in some way.
12+
* They may:
13+
* - Transform the result received from the child (e.g., Inverter)
14+
* - Control when or how many times the child is ticked (e.g., Repeat, Retry)
15+
* - Add timing constraints (e.g., Timeout, Delay)
16+
* - Conditionally execute the child (e.g., Precondition)
17+
*/
818
class DecoratorNode : public TreeNode
919
{
1020
protected:

include/behaviortree_cpp/decorators/force_failure_node.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
namespace BT
1818
{
1919
/**
20-
* @brief The ForceFailureNode returns always FAILURE or RUNNING.
20+
* @brief The ForceFailureNode always returns FAILURE when the child completes,
21+
* regardless of whether the child returned SUCCESS or FAILURE.
22+
*
23+
* - If the child returns RUNNING, this node returns RUNNING.
24+
* - If the child returns SUCCESS or FAILURE, this node returns FAILURE.
2125
*/
2226
class ForceFailureNode : public DecoratorNode
2327
{

include/behaviortree_cpp/decorators/force_success_node.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
namespace BT
1818
{
1919
/**
20-
* @brief The ForceSuccessNode returns always SUCCESS or RUNNING.
20+
* @brief The ForceSuccessNode always returns SUCCESS when the child completes,
21+
* regardless of whether the child returned SUCCESS or FAILURE.
22+
*
23+
* - If the child returns RUNNING, this node returns RUNNING.
24+
* - If the child returns SUCCESS or FAILURE, this node returns SUCCESS.
2125
*/
2226
class ForceSuccessNode : public DecoratorNode
2327
{

include/behaviortree_cpp/decorators/keep_running_until_failure_node.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
namespace BT
1919
{
2020
/**
21-
* @brief The KeepRunningUntilFailureNode returns always FAILURE or RUNNING.
21+
* @brief The KeepRunningUntilFailureNode keeps ticking the child as long
22+
* as it returns SUCCESS, and returns RUNNING.
23+
*
24+
* - If the child returns SUCCESS, reset the child and return RUNNING.
25+
* - If the child returns RUNNING, return RUNNING.
26+
* - If the child returns FAILURE, return FAILURE.
27+
*
28+
* This creates an infinite loop that stops only when the child fails.
2229
*/
2330
class KeepRunningUntilFailureNode : public DecoratorNode
2431
{

include/behaviortree_cpp/decorators/script_precondition.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@
1919

2020
namespace BT
2121
{
22+
/**
23+
* @brief The PreconditionNode evaluates a script condition before ticking its child.
24+
*
25+
* If the script in the "if" port returns true, the child is ticked.
26+
* If the script returns false, the node returns the status specified in the "else" port
27+
* (FAILURE by default).
28+
*
29+
* Once the child starts (returns RUNNING), subsequent ticks will continue
30+
* executing the child without re-evaluating the precondition until completion.
31+
*
32+
* Example usage:
33+
*
34+
* <Precondition if="A > B && color != BLUE" else="FAILURE">
35+
* <SomeAction/>
36+
* </Precondition>
37+
*/
2238
class PreconditionNode : public DecoratorNode
2339
{
2440
public:

0 commit comments

Comments
 (0)