|
AutoAPMS
Streamlining behaviors in ROS 2
|
Flexible and configurable ROS 2 behavior tree executor node. More...
#include <auto_apms_behavior_tree/executor/generic_executor_node.hpp>

Public Member Functions | |
| 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. | |
Static Public Member Functions | |
| 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 | |
| static const std::string | PARAM_VALUE_NO_BUILD_HANDLER = "none" |
| Value indicating that no build handler is loaded. | |
Protected Member Functions | |
| 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... | |
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 and configurable ROS 2 behavior tree executor node.
This executor extends TreeExecutorBase with configurable support for:
Derived classes can trigger the behavior tree execution by calling GenericTreeExecutorNode::startExecution with a build request or a TreeConstructor directly.
Definition at line 59 of file generic_executor_node.hpp.
| GenericTreeExecutorNode | ( | rclcpp::Node::SharedPtr | node_ptr, |
| Options | options ) |
Constructor using an existing ROS 2 node.
This allows embedding the executor inside another node (e.g. via composition) without creating a separate rclcpp::Node instance.
| node_ptr | Shared pointer to the ROS 2 node to use. |
| options | Executor options. |
Definition at line 31 of file generic_executor_node.cpp.
| GenericTreeExecutorNode | ( | const std::string & | name, |
| Options | options ) |
Constructor which creates a new ROS 2 node.
| name | Name of the rclcpp::Node. |
| options | Executor options. |
Definition at line 170 of file generic_executor_node.cpp.
| GenericTreeExecutorNode | ( | const std::string & | name | ) |
Constructor with default executor options.
| name | Name of the rclcpp::Node. |
Definition at line 175 of file generic_executor_node.cpp.
| std::shared_future< GenericTreeExecutorNode::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.
| build_request | Behavior build request for creating the behavior. |
| entry_point | Single point of entry for behavior execution. |
| node_manifest | Behavior tree node manifest to be loaded for behavior execution. |
Definition at line 185 of file generic_executor_node.cpp.
|
protectedvirtual |
Callback invoked before building the behavior tree.
| builder | Tree builder to be configured. |
| build_request | Behavior build request. |
| entry_point | Single point of entry for behavior execution. |
| node_manifest | Behavior tree node manifest. |
| bb | Local blackboard of the tree being created. |
Definition at line 177 of file generic_executor_node.cpp.
|
protectedvirtual |
Callback invoked after the behavior tree has been instantiated.
| tree | Behavior tree that has been created and is about to be executed. |
Definition at line 183 of file generic_executor_node.cpp.
| GenericTreeExecutorNode::ExecutorParameters getExecutorParameters | ( | ) | const |
Get a copy of the current executor parameters.
Definition at line 252 of file generic_executor_node.cpp.
| std::map< std::string, rclcpp::ParameterValue > getParameterValuesWithPrefix | ( | const std::string & | prefix | ) |
Assemble all parameters of this node that have a specific prefix.
| prefix | Only consider parameters that have this prefix in their names. |
Definition at line 257 of file generic_executor_node.cpp.
|
static |
Get the name of a parameter without its prefix.
| prefix | Prefix to remove from param_name. |
| param_name | Name of the parameter with its prefix. |
Definition at line 270 of file generic_executor_node.cpp.
| bool updateScriptingEnumsWithParameterValues | ( | const std::map< std::string, rclcpp::ParameterValue > & | value_map, |
| bool | simulate = false ) |
Update the internal buffer of scripting enums.
| value_map | Map of parameter names and their respective values. |
| simulate | Set to true to only validate. |
true if updating is possible. Definition at line 278 of file generic_executor_node.cpp.
| bool updateGlobalBlackboardWithParameterValues | ( | const std::map< std::string, rclcpp::ParameterValue > & | value_map, |
| bool | simulate = false ) |
Update the global blackboard using parameter values.
| value_map | Map of parameter names and their respective values. |
| simulate | Set to true to only validate. |
true if updating is possible. Definition at line 313 of file generic_executor_node.cpp.
| void loadBuildHandler | ( | const std::string & | name | ) |
Load a particular behavior tree build handler plugin.
| name | Fully qualified name of the build handler class. Set to "none" to unload. |
Definition at line 349 of file generic_executor_node.cpp.
| 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.
| build_request | Request that specifies how to build the behavior tree. |
| entry_point | Single point of entry for behavior execution. |
| node_manifest | Behavior tree node manifest. |
Definition at line 378 of file generic_executor_node.cpp.
| core::TreeBuilder::SharedPtr createTreeBuilder | ( | ) |
Create a tree builder for building the behavior tree.
Definition at line 418 of file generic_executor_node.cpp.
|
overridevirtual |
Reset the global blackboard and clear all entries.
true if blackboard was cleared, false if executor is not idle. Reimplemented from TreeExecutorBase.
Definition at line 425 of file generic_executor_node.cpp.
| std::shared_future< TreeExecutorBase::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.
Executing the behavior tree is achieved by regularly invoking the internal routine that ticks the behavior tree created using make_tree. This requires to register a timer with the associated ROS 2 node. Consequently, the behavior tree is executed asynchronously. The user is provided a shared future object that allows to check whether the execution finished. Once this future completes, the execution result can be evaluated.
| make_tree | Callback that creates a BT::Tree object which will be ticked to execute the tree. |
| tick_rate_sec | Behavior tree tick rate in seconds (1 tick every tick_rate_sec seconds) i.e. the interval of the timer that regularly invokes the execution routine. |
| groot2_port | Port number used for introspection and debugging with Groot2. -1 means that no BT::Groot2Publisher will be installed. |
Definition at line 116 of file executor_base.cpp.
|
inline |
Start a behavior tree that is built using a callback.
Executing the behavior tree is achieved by regularly invoking the internal routine that ticks the behavior tree created using make_tree. This requires to register a timer with the associated ROS 2 node. Consequently, the behavior tree is executed asynchronously. The user is provided a shared future object that allows to check whether the execution finished. Once this future completes, the execution result can be evaluated.
| make_tree | Callback that creates a BT::Tree object which will be ticked to execute the tree. |
| tick_rate | Behavior tree tick rate i.e. the interval of the timer that regularly invokes the execution routine. |
| groot2_port | Port number used for introspection and debugging with Groot2. -1 means that no BT::Groot2Publisher will be installed. |
Definition at line 135 of file executor_base.hpp.
|
inlinestatic |
Value indicating that no build handler is loaded.
Definition at line 71 of file generic_executor_node.hpp.