Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
nav2_behavior_tree::BtServiceNode< ServiceT > Class Template Reference

Abstract class representing a service based BT node. More...

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

Inheritance diagram for nav2_behavior_tree::BtServiceNode< ServiceT >:
Inheritance graph
[legend]
Collaboration diagram for nav2_behavior_tree::BtServiceNode< ServiceT >:
Collaboration graph
[legend]

Public Member Functions

 BtServiceNode (const std::string &service_node_name, const BT::NodeConfiguration &conf, const std::string &service_name="")
 A nav2_behavior_tree::BtServiceNode constructor. More...
 
void initialize ()
 Function to read parameters and initialize class variables.
 
void createROSInterfaces ()
 Function to create ROS interfaces.
 
BT::NodeStatus tick () override
 The main override required by a BT service. More...
 
void halt () override
 The other (optional) override required by a BT service.
 
virtual void on_tick ()
 Function to perform some user-defined operation on tick Fill in service request with information if necessary.
 
virtual BT::NodeStatus on_completion (std::shared_ptr< typename ServiceT::Response >)
 Function to perform some user-defined operation upon successful completion of the service. Could put a value on the blackboard. More...
 
virtual BT::NodeStatus check_future ()
 Check the future and decide the status of BT. More...
 
virtual void on_wait_for_result ()
 Function to perform some user-defined operation after a timeout waiting for a result that hasn't been received yet.
 

Static Public Member Functions

static BT::PortsList providedBasicPorts (BT::PortsList addition)
 Any subclass of BtServiceNode that accepts parameters must provide a providedPorts method and call providedBasicPorts in it. More...
 
static BT::PortsList providedPorts ()
 Creates list of BT ports. More...
 

Protected Member Functions

void increment_recovery_count ()
 Function to increment recovery count on blackboard if this node wraps a recovery.
 

Protected Attributes

std::string service_name_
 
std::string service_node_name_
 
nav2::ServiceClient< ServiceT >::SharedPtr service_client_
 
std::shared_ptr< typename ServiceT::Request > request_
 
nav2::LifecycleNode::SharedPtr node_
 
std::chrono::milliseconds server_timeout_
 
std::chrono::milliseconds max_timeout_
 
std::chrono::milliseconds wait_for_service_timeout_
 
std::shared_future< typename ServiceT::Response::SharedPtr > future_result_
 
bool request_sent_ {false}
 
rclcpp::Time sent_time_
 
bool should_send_request_
 

Detailed Description

template<class ServiceT>
class nav2_behavior_tree::BtServiceNode< ServiceT >

Abstract class representing a service based BT node.

Template Parameters
ServiceTType of service
Note
This is an Asynchronous (long-running) node which may return a RUNNING state while executing. It will re-initialize when halted.

Definition at line 42 of file bt_service_node.hpp.

Constructor & Destructor Documentation

◆ BtServiceNode()

template<class ServiceT >
nav2_behavior_tree::BtServiceNode< ServiceT >::BtServiceNode ( const std::string &  service_node_name,
const BT::NodeConfiguration &  conf,
const std::string &  service_name = "" 
)
inline

A nav2_behavior_tree::BtServiceNode constructor.

Parameters
service_node_nameBT node name
confBT node configuration
service_nameOptional service name this node creates a client for instead of from input port

Definition at line 51 of file bt_service_node.hpp.

Member Function Documentation

◆ check_future()

template<class ServiceT >
virtual BT::NodeStatus nav2_behavior_tree::BtServiceNode< ServiceT >::check_future ( )
inlinevirtual

Check the future and decide the status of BT.

Returns
BT::NodeStatus SUCCESS if future complete before timeout, FAILURE otherwise

Definition at line 213 of file bt_service_node.hpp.

◆ on_completion()

template<class ServiceT >
virtual BT::NodeStatus nav2_behavior_tree::BtServiceNode< ServiceT >::on_completion ( std::shared_ptr< typename ServiceT::Response >  )
inlinevirtual

Function to perform some user-defined operation upon successful completion of the service. Could put a value on the blackboard.

Parameters
responsecan be used to get the result of the service call in the BT Node.
Returns
BT::NodeStatus Returns SUCCESS by default, user may override to return another value

Definition at line 204 of file bt_service_node.hpp.

◆ providedBasicPorts()

template<class ServiceT >
static BT::PortsList nav2_behavior_tree::BtServiceNode< ServiceT >::providedBasicPorts ( BT::PortsList  addition)
inlinestatic

Any subclass of BtServiceNode that accepts parameters must provide a providedPorts method and call providedBasicPorts in it.

Parameters
additionAdditional ports to add to BT port list
Returns
BT::PortsList Containing basic ports along with node-specific ports

Definition at line 129 of file bt_service_node.hpp.

◆ providedPorts()

template<class ServiceT >
static BT::PortsList nav2_behavior_tree::BtServiceNode< ServiceT >::providedPorts ( )
inlinestatic

Creates list of BT ports.

Returns
BT::PortsList Containing basic ports along with node-specific ports

Definition at line 144 of file bt_service_node.hpp.

◆ tick()

template<class ServiceT >
BT::NodeStatus nav2_behavior_tree::BtServiceNode< ServiceT >::tick ( )
inlineoverride

The main override required by a BT service.

Returns
BT::NodeStatus Status of tick execution

Definition at line 153 of file bt_service_node.hpp.


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