Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
nav2_behavior_tree::BtActionServer< ActionT > Class Template Reference

An action server that uses behavior tree to execute an action. More...

#include <nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server.hpp>

Collaboration diagram for nav2_behavior_tree::BtActionServer< ActionT >:
Collaboration graph
[legend]

Public Types

using ActionServer = nav2_util::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 rclcpp_lifecycle::LifecycleNode::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)
 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...
 
bool loadBehaviorTree (const std::string &bt_xml_filename="")
 Replace current BT with another one. More...
 
BT::Blackboard::Ptr getBlackboard () const
 Getter function for BT Blackboard. More...
 
std::string getCurrentBTFilename () const
 Getter function for current BT XML filename. More...
 
std::string getDefaultBTFilename () const
 Getter function for default BT XML filename. 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)
 

Protected Member Functions

void executeCallback ()
 Action server callback.
 

Protected Attributes

std::string action_name_
 
std::shared_ptr< ActionServeraction_server_
 
BT::Tree tree_
 
BT::Blackboard::Ptr blackboard_
 
std::string current_bt_xml_filename_
 
std::string default_bt_xml_filename_
 
std::unique_ptr< nav2_behavior_tree::BehaviorTreeEnginebt_
 
std::vector< std::string > plugin_lib_names_
 
rclcpp::Node::SharedPtr client_node_
 
rclcpp_lifecycle::LifecycleNode::WeakPtr node_
 
rclcpp::Clock::SharedPtr clock_
 
rclcpp::Logger logger_ {rclcpp::get_logger("BtActionServer")}
 
std::unique_ptr< RosTopicLoggertopic_logger_
 
std::chrono::milliseconds bt_loop_duration_
 
std::chrono::milliseconds default_server_timeout_
 
std::chrono::milliseconds wait_for_service_timeout_
 
bool always_reload_bt_xml_ = false
 
OnGoalReceivedCallback on_goal_received_callback_
 
OnLoopCallback on_loop_callback_
 
OnPreemptCallback on_preempt_callback_
 
OnCompletionCallback on_completion_callback_
 

Detailed Description

template<class ActionT>
class nav2_behavior_tree::BtActionServer< ActionT >

An action server that uses behavior tree to execute an action.

Definition at line 35 of file bt_action_server.hpp.

Member Function Documentation

◆ acceptPendingGoal()

template<class ActionT >
const std::shared_ptr<const typename ActionT::Goal> nav2_behavior_tree::BtActionServer< ActionT >::acceptPendingGoal ( )
inline

Wrapper function to accept pending goal if a preempt has been requested.

Returns
Shared pointer to pending action goal

Definition at line 129 of file bt_action_server.hpp.

◆ getBlackboard()

template<class ActionT >
BT::Blackboard::Ptr nav2_behavior_tree::BtActionServer< ActionT >::getBlackboard ( ) const
inline

Getter function for BT Blackboard.

Returns
BT::Blackboard::Ptr Shared pointer to current BT blackboard

Definition at line 102 of file bt_action_server.hpp.

◆ getCurrentBTFilename()

template<class ActionT >
std::string nav2_behavior_tree::BtActionServer< ActionT >::getCurrentBTFilename ( ) const
inline

Getter function for current BT XML filename.

Returns
string Containing current BT XML filename

Definition at line 111 of file bt_action_server.hpp.

◆ getCurrentGoal()

template<class ActionT >
const std::shared_ptr<const typename ActionT::Goal> nav2_behavior_tree::BtActionServer< ActionT >::getCurrentGoal ( ) const
inline

Wrapper function to get current goal.

Returns
Shared pointer to current action goal

Definition at line 146 of file bt_action_server.hpp.

◆ getDefaultBTFilename()

template<class ActionT >
std::string nav2_behavior_tree::BtActionServer< ActionT >::getDefaultBTFilename ( ) const
inline

Getter function for default BT XML filename.

Returns
string Containing default BT XML filename

Definition at line 120 of file bt_action_server.hpp.

◆ getPendingGoal()

template<class ActionT >
const std::shared_ptr<const typename ActionT::Goal> nav2_behavior_tree::BtActionServer< ActionT >::getPendingGoal ( ) const
inline

Wrapper function to get pending goal.

Returns
Shared pointer to pending action goal

Definition at line 155 of file bt_action_server.hpp.

◆ getTree()

template<class ActionT >
const BT::Tree& nav2_behavior_tree::BtActionServer< ActionT >::getTree ( ) const
inline

Getter function for the current BT tree.

Returns
BT::Tree Current behavior tree

Definition at line 172 of file bt_action_server.hpp.

◆ loadBehaviorTree()

template<class ActionT >
bool nav2_behavior_tree::BtActionServer< ActionT >::loadBehaviorTree ( const std::string &  bt_xml_filename = "")

Replace current BT with another one.

Parameters
bt_xml_filenameThe file containing the new BT, uses default filename if empty
Returns
bool true if the resulting BT correspond to the one in bt_xml_filename. false if something went wrong, and previous BT is maintained

Definition at line 176 of file bt_action_server_impl.hpp.

◆ on_activate()

template<class ActionT >
bool nav2_behavior_tree::BtActionServer< ActionT >::on_activate

Activates action server.

Returns
bool true on SUCCESS and false on FAILURE

Definition at line 144 of file bt_action_server_impl.hpp.

◆ on_cleanup()

template<class ActionT >
bool nav2_behavior_tree::BtActionServer< ActionT >::on_cleanup

Resets member variables.

Returns
bool true on SUCCESS and false on FAILURE

Definition at line 162 of file bt_action_server_impl.hpp.

◆ on_configure()

template<class ActionT >
bool nav2_behavior_tree::BtActionServer< ActionT >::on_configure

Configures member variables Initializes action server for, builds behavior tree from xml file, and calls user-defined onConfigure.

Returns
bool true on SUCCESS and false on FAILURE

Definition at line 76 of file bt_action_server_impl.hpp.

◆ on_deactivate()

template<class ActionT >
bool nav2_behavior_tree::BtActionServer< ActionT >::on_deactivate

Deactivates action server.

Returns
bool true on SUCCESS and false on FAILURE

Definition at line 155 of file bt_action_server_impl.hpp.


The documentation for this class was generated from the following files: