|
AutoAPMS
Streamlining behaviors in ROS 2
|
ROS 2 node template for executing behavior trees triggered by a custom ROS 2 action goal. More...
#include <auto_apms_behavior_tree/executor/action_based_executor_node.hpp>

Public Member Functions | |
| ActionBasedTreeExecutorNode (rclcpp::Node::SharedPtr node_ptr, const std::string &action_name, Options options) | |
| Constructor using an existing ROS 2 node. | |
| ActionBasedTreeExecutorNode (const std::string &name, const std::string &action_name, Options options) | |
| Constructor which creates a new ROS 2 node. | |
| ActionBasedTreeExecutorNode (const std::string &name, const std::string &action_name) | |
| Constructor with default executor options. | |
Public Member Functions inherited from GenericTreeExecutorNode | |
| GenericTreeExecutorNode (rclcpp::Node::SharedPtr node_ptr, Options options) | |
| Constructor using an existing ROS 2 node. | |
| GenericTreeExecutorNode (const std::string &name, Options options) | |
| Constructor which creates a new ROS 2 node. | |
| GenericTreeExecutorNode (const std::string &name) | |
| Constructor with default executor options. | |
| std::shared_future< ExecutionResult > | startExecution (const std::string &build_request, const std::string &entry_point="", const core::NodeManifest &node_manifest={}) |
| Start the behavior tree specified by a particular build request. | |
| ExecutorParameters | getExecutorParameters () const |
| Get a copy of the current executor parameters. | |
| std::map< std::string, rclcpp::ParameterValue > | getParameterValuesWithPrefix (const std::string &prefix) |
| Assemble all parameters of this node that have a specific prefix. | |
| bool | updateScriptingEnumsWithParameterValues (const std::map< std::string, rclcpp::ParameterValue > &value_map, bool simulate=false) |
| Update the internal buffer of scripting enums. | |
| bool | updateGlobalBlackboardWithParameterValues (const std::map< std::string, rclcpp::ParameterValue > &value_map, bool simulate=false) |
| Update the global blackboard using parameter values. | |
| void | loadBuildHandler (const std::string &name) |
| Load a particular behavior tree build handler plugin. | |
| TreeConstructor | makeTreeConstructor (const std::string &build_request, const std::string &entry_point="", const core::NodeManifest &node_manifest={}) |
| Create a callback that builds a behavior tree according to a specific request. | |
| core::TreeBuilder::SharedPtr | createTreeBuilder () |
| Create a tree builder for building the behavior tree. | |
| virtual bool | clearGlobalBlackboard () override |
| Reset the global blackboard and clear all entries. | |
| std::shared_future< ExecutionResult > | startExecution (TreeConstructor make_tree, double tick_rate_sec=0.1, int groot2_port=-1) |
| Start a behavior tree that is built using a callback. | |
| template<typename TimeRepT = int64_t, typename TimeT = std::milli> | |
| std::shared_future< ExecutionResult > | startExecution (TreeConstructor make_tree, const std::chrono::duration< TimeRepT, TimeT > &tick_rate, int groot2_port=-1) |
| Start a behavior tree that is built using a callback. | |
Public Member Functions inherited from TreeExecutorBase | |
| TreeExecutorBase (rclcpp::Node::SharedPtr node_ptr, rclcpp::CallbackGroup::SharedPtr tree_node_callback_group_ptr=nullptr) | |
| Constructor. | |
| std::shared_future< ExecutionResult > | startExecution (TreeConstructor make_tree, double tick_rate_sec=0.1, int groot2_port=-1) |
| Start a behavior tree that is built using a callback. | |
| template<typename TimeRepT = int64_t, typename TimeT = std::milli> | |
| std::shared_future< ExecutionResult > | startExecution (TreeConstructor make_tree, const std::chrono::duration< TimeRepT, TimeT > &tick_rate, int groot2_port=-1) |
| Start a behavior tree that is built using a callback. | |
| void | setControlCommand (ControlCommand cmd) |
| Set the command that handles the control flow of the execution routine. | |
| bool | isBusy () |
| Determine whether this executor is currently executing a behavior tree. | |
| ExecutionState | getExecutionState () |
| Get a status code indicating the current state of execution. | |
| std::string | getTreeName () |
| Get the name of the tree that is currently executing. | |
| TreeBlackboardSharedPtr | getGlobalBlackboardPtr () |
| Get a shared pointer to the global blackboard instance. | |
| TreeStateObserver & | getStateObserver () |
| Get a reference to the current behavior tree state observer. | |
| rclcpp::Node::SharedPtr | getNodePtr () |
| Get a shared pointer to the parent ROS 2 node. | |
| rclcpp::node_interfaces::NodeBaseInterface::SharedPtr | get_node_base_interface () |
| Get the node's base interface. Is required to be able to register derived classes as ROS2 components. | |
| rclcpp::CallbackGroup::SharedPtr | getTreeNodeWaitablesCallbackGroupPtr () |
| Get the callback group used for all waitables registered by behavior tree nodes. | |
| rclcpp::executors::SingleThreadedExecutor::SharedPtr | getTreeNodeWaitablesExecutorPtr () |
| Get the ROS 2 executor instance used for spinning waitables registered by behavior tree nodes. | |
Protected Member Functions | |
| virtual TreeConstructor | getTreeConstructorFromGoal (std::shared_ptr< const TriggerGoal > goal_ptr)=0 |
| Create a TreeConstructor from the received action goal. | |
| virtual bool | shouldAcceptGoal (const rclcpp_action::GoalUUID &uuid, std::shared_ptr< const TriggerGoal > goal_ptr) |
| Determine whether an incoming trigger action goal should be accepted. | |
| virtual void | onAcceptedGoal (std::shared_ptr< TriggerGoalHandle > goal_handle_ptr) |
| Hook called after a trigger action goal has been accepted and before execution begins. | |
| virtual void | onExecutionStarted (std::shared_ptr< TriggerGoalHandle > goal_handle_ptr) |
| Hook called after execution has been started successfully. | |
| virtual void | onGoalExecutionTermination (const ExecutionResult &result, TriggerActionContext &context) |
| Handle the execution result for the action client. | |
Protected Member Functions inherited from GenericTreeExecutorNode | |
| virtual void | preBuild (core::TreeBuilder &builder, const std::string &build_request, const std::string &entry_point, const core::NodeManifest &node_manifest, TreeBlackboard &bb) |
| Callback invoked before building the behavior tree. | |
| virtual void | postBuild (Tree &tree) |
| Callback invoked after the behavior tree has been instantiated. | |
Additional Inherited Members | |
Public Types inherited from TreeExecutorBase | |
| enum class | ExecutionState : uint8_t { IDLE , STARTING , RUNNING , PAUSED , HALTED } |
| Enum representing possible behavior tree execution states. More... | |
| enum class | ControlCommand : uint8_t { RUN , PAUSE , HALT , TERMINATE } |
| Enum representing possible commands for controlling the behavior tree execution routine. More... | |
| enum class | TreeExitBehavior : uint8_t { TERMINATE , RESTART } |
| Enum representing possible options for what to do when a behavior tree is completed. More... | |
| enum class | ExecutionResult : uint8_t { TREE_SUCCEEDED , TREE_FAILED , TERMINATED_PREMATURELY , ERROR } |
| Enum representing possible behavior tree execution results. More... | |
Static Public Member Functions inherited from GenericTreeExecutorNode | |
| static std::string | stripPrefixFromParameterName (const std::string &prefix, const std::string ¶m_name) |
| Get the name of a parameter without its prefix. | |
Static Public Attributes inherited from GenericTreeExecutorNode | |
| static const std::string | PARAM_VALUE_NO_BUILD_HANDLER = "none" |
| Value indicating that no build handler is loaded. | |
Protected Attributes inherited from TreeExecutorBase | |
| rclcpp::Node::SharedPtr | node_ptr_ |
| Shared pointer to the parent ROS 2 node. | |
| const rclcpp::Logger | logger_ |
| Logger associated with the parent ROS 2 node. | |
ROS 2 node template for executing behavior trees triggered by a custom ROS 2 action goal.
This class extends GenericTreeExecutorNode to trigger behavior tree execution when an action goal of the specified type ActionT is received. It creates an action server and manages the lifecycle of the action goal in coordination with the behavior tree execution.
Derived classes must implement:
getTreeConstructorFromGoal(): Create a TreeConstructor from the received action goal.Derived classes may optionally override:
shouldAcceptGoal(): Custom goal acceptance logic.onAcceptedGoal(): Hook called after a goal is accepted.onExecutionStarted(): Hook called after execution has started successfully.onGoalExecutionTermination(): Handle the result of the execution for the action client.| ActionT | The ROS 2 action type that triggers the behavior tree execution. |
Definition at line 46 of file action_based_executor_node.hpp.
| ActionBasedTreeExecutorNode | ( | rclcpp::Node::SharedPtr | node_ptr, |
| const std::string & | action_name, | ||
| Options | options ) |
Constructor using an existing ROS 2 node.
| node_ptr | Shared pointer to the ROS 2 node to use. |
| action_name | Name for the trigger action server. |
| options | Executor options. |
Definition at line 150 of file action_based_executor_node.hpp.
| ActionBasedTreeExecutorNode | ( | const std::string & | name, |
| const std::string & | action_name, | ||
| Options | options ) |
Constructor which creates a new ROS 2 node.
| name | Name of the rclcpp::Node. |
| action_name | Name for the trigger action server. |
| options | Executor options. |
Definition at line 162 of file action_based_executor_node.hpp.
| ActionBasedTreeExecutorNode | ( | const std::string & | name, |
| const std::string & | action_name ) |
Constructor with default executor options.
| name | Name of the rclcpp::Node. |
| action_name | Name for the trigger action server. |
Definition at line 169 of file action_based_executor_node.hpp.
|
protectedpure virtual |
Create a TreeConstructor from the received action goal.
Derived classes must implement this to define how the action goal maps to a behavior tree execution. This is where the build request, entry point, and node manifest should be determined from the goal.
| goal_ptr | Shared pointer to the action goal. |
| std::exception | if the goal cannot be processed (will cause goal rejection). |
|
protectedvirtual |
Determine whether an incoming trigger action goal should be accepted.
The default implementation rejects the goal if the executor is currently busy.
| uuid | The unique identifier of the incoming goal. |
| goal_ptr | Shared pointer to the incoming goal. |
true if the goal should be accepted, false if it should be rejected. Definition at line 176 of file action_based_executor_node.hpp.
|
protectedvirtual |
Hook called after a trigger action goal has been accepted and before execution begins.
| goal_handle_ptr | Shared pointer to the accepted goal handle. |
Definition at line 189 of file action_based_executor_node.hpp.
|
protectedvirtual |
Hook called after execution has been started successfully.
The default implementation sets up the action context for tracking the execution result (attached mode). Derived classes may override this to implement detached behavior by succeeding the goal handle immediately.
| goal_handle_ptr | Shared pointer to the accepted goal handle. |
Definition at line 194 of file action_based_executor_node.hpp.
|
protectedvirtual |
Handle the execution result for the action client.
The default implementation succeeds for TREE_SUCCEEDED, aborts for TREE_FAILED, handles cancellation for TERMINATED_PREMATURELY, and aborts for ERROR.
| result | The execution result. |
| context | The action context for sending the result back. |
Definition at line 201 of file action_based_executor_node.hpp.