|
AutoAPMS
Streamlining behaviors in ROS 2
|
Flexible ROS 2 node implementing a standardized interface for dynamically executing behavior trees. More...
#include <auto_apms_behavior_tree/executor/executor_node.hpp>

Public Member Functions | |
| TreeExecutorNode (const std::string &name, const std::string &start_action_name, Options options) | |
| Constructor allowing to specify a custom node name and executor options. | |
| TreeExecutorNode (const std::string &name, Options options) | |
| Constructor allowing to specify a custom node name and executor options. | |
| TreeExecutorNode (rclcpp::NodeOptions ros_options) | |
| Constructor populating both the node's name and the executor options with the default. | |
Public Member Functions inherited from ActionBasedTreeExecutorNode< auto_apms_interfaces::action::StartTreeExecutor > | |
| ActionBasedTreeExecutorNode (const std::string &name, const std::string &action_name, Options options) | |
| Constructor. | |
| ActionBasedTreeExecutorNode (const std::string &name, const std::string &action_name, rclcpp::NodeOptions ros_options=rclcpp::NodeOptions()) | |
| Constructor with default options. | |
Public Member Functions inherited from GenericTreeExecutorNode | |
| GenericTreeExecutorNode (const std::string &name, Options options) | |
| Constructor. | |
| GenericTreeExecutorNode (rclcpp::NodeOptions options) | |
| Constructor with default 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. | |
| 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 | |
| TreeConstructor | getTreeConstructorFromGoal (std::shared_ptr< const TriggerGoal > goal_ptr) override |
| Create a TreeConstructor from a StartTreeExecutor action goal. | |
| bool | shouldAcceptGoal (const rclcpp_action::GoalUUID &uuid, std::shared_ptr< const TriggerGoal > goal_ptr) override |
| Determine whether an incoming start action goal should be accepted. | |
| void | onAcceptedGoal (std::shared_ptr< TriggerGoalHandle > goal_handle_ptr) override |
| Hook called after a start action goal has been accepted and before execution begins. | |
| void | onExecutionStarted (std::shared_ptr< TriggerGoalHandle > goal_handle_ptr) override |
| Hook called after execution has been started successfully. | |
| void | onGoalExecutionTermination (const ExecutionResult &result, TriggerActionContext &context) override |
| Handle the execution result for the StartTreeExecutor action client. | |
Protected Member Functions inherited from ActionBasedTreeExecutorNode< auto_apms_interfaces::action::StartTreeExecutor > | |
| 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 | |
| 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. | |
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 Attributes inherited from GenericTreeExecutorNode | |
| static const std::string | PARAM_VALUE_NO_BUILD_HANDLER = "none" |
| Value indicating that no build handler is loaded. | |
Static Protected 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. | |
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. | |
Flexible ROS 2 node implementing a standardized interface for dynamically executing behavior trees.
This class uses the ActionBasedTreeExecutorNode template with the builtin StartTreeExecutor action type that allows external clients to trigger behavior tree execution via a flexible and standardized interface. The executor is configured using ROS 2 parameters.
A behavior tree can be executed via command line:
or using the ROS 2 CLI integration offered by auto_apms_ros2behavior:
Alternatively, an executor can also be included as part of a ROS 2 components container. The following executor components are provided:
auto_apms_behavior_tree::TreeExecutorNodeauto_apms_behavior_tree::NoUndeclaredParamsExecutorNodeauto_apms_behavior_tree::OnlyScriptingEnumParamsExecutorNodeauto_apms_behavior_tree::OnlyBlackboardParamsExecutorNodeauto_apms_behavior_tree::OnlyInitialScriptingEnumParamsExecutorNodeauto_apms_behavior_tree::OnlyInitialBlackboardParamsExecutorNode Definition at line 58 of file executor_node.hpp.
| TreeExecutorNode | ( | const std::string & | name, |
| const std::string & | start_action_name, | ||
| Options | options ) |
Constructor allowing to specify a custom node name and executor options.
| name | Default name of the rclcpp::Node. |
| start_action_name | Name for the StartTreeExecutor action server. If empty, defaults to <node_name>/start. |
| options | Executor specific options. Simply pass a rclcpp::NodeOptions object to use the default options. |
Definition at line 28 of file executor_node.cpp.
| TreeExecutorNode | ( | const std::string & | name, |
| Options | options ) |
Constructor allowing to specify a custom node name and executor options.
| name | Default name of the rclcpp::Node. |
| options | Executor specific options. Simply pass a rclcpp::NodeOptions object to use the default options. |
Definition at line 58 of file executor_node.cpp.
|
explicit |
Constructor populating both the node's name and the executor options with the default.
| options | Options forwarded to rclcpp::Node constructor. |
Definition at line 60 of file executor_node.cpp.
|
overrideprotected |
Create a TreeConstructor from a StartTreeExecutor action goal.
Loads the build handler (if specified), parses the node manifest, and creates a tree constructor using the build request from the goal.
| goal_ptr | Shared pointer to the StartTreeExecutor action goal. |
| std::exception | if the goal cannot be processed. |
Definition at line 77 of file executor_node.cpp.
|
overrideprotected |
Determine whether an incoming start action goal should be accepted.
The default implementation rejects the goal if the executor is currently busy executing a behavior tree. Derived classes may override this to add additional validation logic.
| 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 65 of file executor_node.cpp.
|
overrideprotected |
Hook called after a start action goal has been accepted and before execution begins.
Clears the global blackboard if the goal's clear_blackboard flag is set.
| goal_handle_ptr | Shared pointer to the accepted goal handle. |
Definition at line 93 of file executor_node.cpp.
|
overrideprotected |
Hook called after execution has been started successfully.
Handles attached vs detached mode: in attached mode, sets up the action context to track execution; in detached mode, immediately succeeds the goal.
| goal_handle_ptr | Shared pointer to the accepted goal handle. |
Definition at line 101 of file executor_node.cpp.
|
overrideprotected |
Handle the execution result for the StartTreeExecutor action client.
Populates the result with tree status information and the terminated tree identity.
| result | The execution result. |
| context | The action context for sending the result back. |
Definition at line 147 of file executor_node.cpp.