Nav2 Navigation Stack - rolling
main
ROS 2 Navigation Stack
|
An action server that uses behavior tree to execute an action. More...
#include <nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server.hpp>
Public Types | |
using | ActionServer = nav2::SimpleActionServer< ActionT > |
typedef std::function< bool(typename ActionT::Goal::ConstSharedPtr)> | OnGoalReceivedCallback |
typedef std::function< void()> | OnLoopCallback |
typedef std::function< void(typename ActionT::Goal::ConstSharedPtr)> | OnPreemptCallback |
typedef std::function< void(typename ActionT::Result::SharedPtr, nav2_behavior_tree::BtStatus)> | OnCompletionCallback |
Public Member Functions | |
BtActionServer (const typename NodeT::WeakPtr &parent, const std::string &action_name, const std::vector< std::string > &plugin_lib_names, const std::string &default_bt_xml_filename, OnGoalReceivedCallback on_goal_received_callback, OnLoopCallback on_loop_callback, OnPreemptCallback on_preempt_callback, OnCompletionCallback on_completion_callback, const std::vector< std::string > &search_directories=std::vector< std::string >{}) | |
A constructor for nav2_behavior_tree::BtActionServer class. | |
~BtActionServer () | |
A destructor for nav2_behavior_tree::BtActionServer class. | |
bool | on_configure () |
Configures member variables Initializes action server for, builds behavior tree from xml file, and calls user-defined onConfigure. More... | |
bool | on_activate () |
Activates action server. More... | |
bool | on_deactivate () |
Deactivates action server. More... | |
bool | on_cleanup () |
Resets member variables. More... | |
void | setGrootMonitoring (const bool enable, const unsigned server_port) |
Enable (or disable) Groot2 monitoring of BT. More... | |
bool | loadBehaviorTree (const std::string &bt_xml_filename_or_id="") |
Replace current BT with another one. More... | |
std::string | extractBehaviorTreeID (const std::string &file_or_id) |
Extract BehaviorTree ID from XML file. More... | |
BT::Blackboard::Ptr | getBlackboard () const |
Getter function for BT Blackboard. More... | |
std::string | getCurrentBTFilenameOrID () const |
Getter function for current BT XML filename. More... | |
std::string | getDefaultBTFilenameOrID () const |
Getter function for default BT XML filename or ID. More... | |
const std::shared_ptr< const typename ActionT::Goal > | acceptPendingGoal () |
Wrapper function to accept pending goal if a preempt has been requested. More... | |
void | terminatePendingGoal () |
Wrapper function to terminate pending goal if a preempt has been requested. | |
const std::shared_ptr< const typename ActionT::Goal > | getCurrentGoal () const |
Wrapper function to get current goal. More... | |
const std::shared_ptr< const typename ActionT::Goal > | getPendingGoal () const |
Wrapper function to get pending goal. More... | |
void | publishFeedback (typename std::shared_ptr< typename ActionT::Feedback > feedback) |
Wrapper function to publish action feedback. | |
const BT::Tree & | getTree () const |
Getter function for the current BT tree. More... | |
void | haltTree () |
Function to halt the current tree. It will interrupt the execution of RUNNING nodes by calling their halt() implementation (only for Async nodes that may return RUNNING) This should already done for all the exit states of the action but preemption. | |
void | setInternalError (uint16_t error_code, const std::string &error_msg) |
Set internal error code and message. More... | |
void | resetInternalError (void) |
reset internal error code and message | |
bool | populateInternalError (typename std::shared_ptr< typename ActionT::Result > result) |
populate result with internal error code and error_msg if not NONE More... | |
Protected Member Functions | |
void | executeCallback () |
Action server callback. | |
void | populateErrorCode (typename std::shared_ptr< typename ActionT::Result > result) |
updates the action server result to the highest priority error code posted on the blackboard More... | |
void | cleanErrorCodes () |
Setting BT error codes to success. Used to clean blackboard between different BT runs. | |
Protected Attributes | |
std::string | action_name_ |
ActionServer::SharedPtr | action_server_ |
BT::Tree | tree_ |
BT::Blackboard::Ptr | blackboard_ |
std::string | current_bt_file_or_id_ |
std::string | default_bt_xml_filename_or_id_ |
std::vector< std::string > | search_directories_ |
std::unique_ptr< nav2_behavior_tree::BehaviorTreeEngine > | bt_ |
std::vector< std::string > | plugin_lib_names_ |
std::vector< std::string > | error_code_name_prefixes_ |
nav2::LifecycleNode::SharedPtr | client_node_ |
NodeT::WeakPtr | node_ |
rclcpp::Clock::SharedPtr | clock_ |
rclcpp::Logger | logger_ {rclcpp::get_logger("BtActionServer")} |
std::unique_ptr< RosTopicLogger > | topic_logger_ |
std::chrono::milliseconds | bt_loop_duration_ |
std::chrono::milliseconds | default_server_timeout_ |
std::chrono::milliseconds | wait_for_service_timeout_ |
bool | always_reload_bt_ = false |
bool | enable_groot_monitoring_ = false |
int | groot_server_port_ = 1667 |
OnGoalReceivedCallback | on_goal_received_callback_ |
OnLoopCallback | on_loop_callback_ |
OnPreemptCallback | on_preempt_callback_ |
OnCompletionCallback | on_completion_callback_ |
uint16_t | internal_error_code_ |
std::string | internal_error_msg_ |
An action server that uses behavior tree to execute an action.
Definition at line 37 of file bt_action_server.hpp.
|
inline |
Wrapper function to accept pending goal if a preempt has been requested.
Definition at line 146 of file bt_action_server.hpp.
std::string nav2_behavior_tree::BtActionServer< ActionT, NodeT >::extractBehaviorTreeID | ( | const std::string & | file_or_id | ) |
Extract BehaviorTree ID from XML file.
filename | The file containing the BT |
|
inline |
Getter function for BT Blackboard.
Definition at line 119 of file bt_action_server.hpp.
|
inline |
Getter function for current BT XML filename.
Definition at line 128 of file bt_action_server.hpp.
|
inline |
Wrapper function to get current goal.
Definition at line 163 of file bt_action_server.hpp.
|
inline |
Getter function for default BT XML filename or ID.
Definition at line 137 of file bt_action_server.hpp.
|
inline |
Wrapper function to get pending goal.
Definition at line 172 of file bt_action_server.hpp.
|
inline |
Getter function for the current BT tree.
Definition at line 189 of file bt_action_server.hpp.
bool nav2_behavior_tree::BtActionServer< ActionT, NodeT >::loadBehaviorTree | ( | const std::string & | bt_xml_filename_or_id = "" | ) |
Replace current BT with another one.
bt_xml_filename_or_id | The file containing the new BT, uses default filename if empty or BT ID |
Definition at line 250 of file bt_action_server_impl.hpp.
bool nav2_behavior_tree::BtActionServer< ActionT, NodeT >::on_activate |
Activates action server.
Definition at line 205 of file bt_action_server_impl.hpp.
bool nav2_behavior_tree::BtActionServer< ActionT, NodeT >::on_cleanup |
Resets member variables.
Definition at line 224 of file bt_action_server_impl.hpp.
bool nav2_behavior_tree::BtActionServer< ActionT, NodeT >::on_configure |
Configures member variables Initializes action server for, builds behavior tree from xml file, and calls user-defined onConfigure.
Definition at line 132 of file bt_action_server_impl.hpp.
bool nav2_behavior_tree::BtActionServer< ActionT, NodeT >::on_deactivate |
Deactivates action server.
Definition at line 217 of file bt_action_server_impl.hpp.
|
protected |
updates the action server result to the highest priority error code posted on the blackboard
result | the action server result to be updated |
Definition at line 438 of file bt_action_server_impl.hpp.
bool nav2_behavior_tree::BtActionServer< ActionT, NodeT >::populateInternalError | ( | typename std::shared_ptr< typename ActionT::Result > | result | ) |
populate result with internal error code and error_msg if not NONE
result | the action server result to be updated |
Definition at line 426 of file bt_action_server_impl.hpp.
void nav2_behavior_tree::BtActionServer< ActionT, NodeT >::setGrootMonitoring | ( | const bool | enable, |
const unsigned | server_port | ||
) |
Enable (or disable) Groot2 monitoring of BT.
enable | Groot2 monitoring |
server_port | Groot2 Server port, first of the pair (server_port, publisher_port) |
Definition at line 241 of file bt_action_server_impl.hpp.
void nav2_behavior_tree::BtActionServer< ActionT, NodeT >::setInternalError | ( | uint16_t | error_code, |
const std::string & | error_msg | ||
) |
Set internal error code and message.
error_code | the internal error code |
error_msg | the internal error message |
Definition at line 408 of file bt_action_server_impl.hpp.