Skip to main content

CallManageLifecycleNodes Class

Send a command to a Nav2 lifecycle manager. More...

Declaration​

class moveit_pro::behaviors::CallManageLifecycleNodes { ... }

Included Headers​

#include <call_manage_lifecycle_nodes.hpp>

Base class​

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

Private Member Typedefs Index​

usingService = nav2_msgs::srv::ManageLifecycleNodes

Public Constructors Index​

CallManageLifecycleNodes (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &context)

Private Member Functions Index​

tl::expected< std::string, std::string >getServiceName () override

User-provided function to get the name of the service when initializing the service client. More...

tl::expected< Service::Request, std::string >createRequest () override

User-provided function to create the service request. More...

tl::expected< bool, std::string >processResponse (const Service::Response &response) override
tl::expected< std::chrono::duration< double >, std::string >getResponseTimeout () override

Optional user-provided function to set the timeout used when waiting for the service response. More...

std::shared_future< tl::expected< bool, std::string > > &getFuture () override

Gets the shared future which is used to monitor the progress of the async process. More...

Private Member Attributes Index​

std::shared_future< tl::expected< bool, std::string > >future_
unsigned intsubmitted_command_ = Service::Request::STARTUP
std::stringsubmitted_service_

Public Static Functions Index​

static BT::PortsListprovidedPorts ()
static BT::KeyValueVectormetadata ()

Description​

Send a command to a Nav2 lifecycle manager.

Data Port NamePort TypeObject Type
service_nameinputstd::string
commandinputunsigned int
response_timeoutinputdouble

Definition at line 23 of file call_manage_lifecycle_nodes.hpp.

Private Member Typedefs​

Service​

using moveit_pro::behaviors::CallManageLifecycleNodes::Service = nav2_msgs::srv::ManageLifecycleNodes

Definition at line 32 of file call_manage_lifecycle_nodes.hpp.

Public Constructors​

CallManageLifecycleNodes()​

moveit_pro::behaviors::CallManageLifecycleNodes::CallManageLifecycleNodes (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & context)

Declaration at line 26 of file call_manage_lifecycle_nodes.hpp, definition at line 16 of file call_manage_lifecycle_nodes.cpp.

Private Member Functions​

createRequest()​

tl::expected< CallManageLifecycleNodes::Service::Request, std::string > moveit_pro::behaviors::CallManageLifecycleNodes::createRequest ()
nodiscard virtual

User-provided function to create the service request.

Returns

Returns a service request message. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.

Declaration at line 34 of file call_manage_lifecycle_nodes.hpp, definition at line 52 of file call_manage_lifecycle_nodes.cpp.

getFuture()​

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::CallManageLifecycleNodes::getFuture ()
nodiscard virtual

Gets the shared future which is used to monitor the progress of the async process.

Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member.

This exists to prevent destruction of the derived class while the async process is still in-progress. If the derived class is destroyed, the definitions of the functions used within doWork() will be destroyed too, which will result in the virtual functions in the base class being called instead and cause a fault.

This function will force derived classes to add an instance of this type and return a reference to it. The base class can then use this virtual function to access the shared future in functions like onStart.

By adding this virtual function we're properly demonstrating how this future depends on things from the derived class and the natural flow of object lifetimes will do the hard work for us. The std::shared_future destructor will get the value of the future before the derived class is destructed assuming it's the last reference to the shared state. Doing it this way means neither the base nor derived class should need to implement a destructor which is a nice property to have.

Returns

Returns the shared_future, which should be owned by the child class.

Declaration at line 37 of file call_manage_lifecycle_nodes.hpp, definition at line 111 of file call_manage_lifecycle_nodes.cpp.

getResponseTimeout()​

tl::expected< std::chrono::duration< double >, std::string > moveit_pro::behaviors::CallManageLifecycleNodes::getResponseTimeout ()
nodiscard virtual

Optional user-provided function to set the timeout used when waiting for the service response.

If no user-defined implementation is provided, the default implementation returns a negative duration, which will cause the service client to wait for the response without timing out.

Returns

Returns the service response timeout duration. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.

Declaration at line 36 of file call_manage_lifecycle_nodes.hpp, definition at line 89 of file call_manage_lifecycle_nodes.cpp.

getServiceName()​

tl::expected< std::string, std::string > moveit_pro::behaviors::CallManageLifecycleNodes::getServiceName ()
nodiscard virtual

User-provided function to get the name of the service when initializing the service client.

Returns

Returns the name of the service. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.

Declaration at line 33 of file call_manage_lifecycle_nodes.hpp, definition at line 37 of file call_manage_lifecycle_nodes.cpp.

processResponse()​

tl::expected< bool, std::string > moveit_pro::behaviors::CallManageLifecycleNodes::processResponse (const Service::Response & response)
nodiscard

Declaration at line 35 of file call_manage_lifecycle_nodes.hpp, definition at line 78 of file call_manage_lifecycle_nodes.cpp.

Private Member Attributes​

future_​

std::shared_future<tl::expected<bool, std::string> > moveit_pro::behaviors::CallManageLifecycleNodes::future_

Definition at line 38 of file call_manage_lifecycle_nodes.hpp.

submitted_command_​

unsigned int moveit_pro::behaviors::CallManageLifecycleNodes::submitted_command_ = Service::Request::STARTUP

Definition at line 39 of file call_manage_lifecycle_nodes.hpp.

submitted_service_​

std::string moveit_pro::behaviors::CallManageLifecycleNodes::submitted_service_

Definition at line 40 of file call_manage_lifecycle_nodes.hpp.

Public Static Functions​

metadata()​

BT::KeyValueVector moveit_pro::behaviors::CallManageLifecycleNodes::metadata ()
nodiscard static

Declaration at line 29 of file call_manage_lifecycle_nodes.hpp, definition at line 30 of file call_manage_lifecycle_nodes.cpp.

providedPorts()​

BT::PortsList moveit_pro::behaviors::CallManageLifecycleNodes::providedPorts ()
nodiscard static

Declaration at line 28 of file call_manage_lifecycle_nodes.hpp, definition at line 22 of file call_manage_lifecycle_nodes.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.15.0.