Skip to main content

CallSaveMapService Class

Save the occupancy grid map built by slam_toolbox by calling a slam_toolbox/srv/SaveMap service. More...

Declaration​

class moveit_pro::behaviors::CallSaveMapService { ... }

Included Headers​

#include <call_save_map_service.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...

Public Constructors Index​

CallSaveMapService (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
CallSaveMapService (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< ClientInterfaceBase< SlamToolboxSaveMap > > client_interface)

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< std::chrono::duration< double >, std::string >getResponseTimeout () override

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

tl::expected< std::chrono::duration< double >, std::string >getWaitForServerAvailableTimeout () override

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

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

Creates a service request message containing the map name read from the "map_name" input port. More...

tl::expected< bool, std::string >processResponse (const SlamToolboxSaveMap::Response &response) override

Determines whether the map was saved based on the response's result code. More...

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

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

Private Member Attributes Index​

std::shared_future< tl::expected< bool, std::string > >future_

Holds the result of calling the service asynchronously. More...

std::stringmap_name_

Map name validated by createRequest, kept so processResponse can name it without re-reading the port. More...

Public Static Functions Index​

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

Description​

Save the occupancy grid map built by slam_toolbox by calling a slam_toolbox/srv/SaveMap service.

Data Port NamePort TypeObject Type
map_nameinputstd::string
service_nameinputstd::string
wait_for_server_available_timeoutinputdouble
response_timeoutinputdouble

Definition at line 29 of file call_save_map_service.hpp.

Public Constructors​

CallSaveMapService()​

moveit_pro::behaviors::CallSaveMapService::CallSaveMapService (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources)
explicit

Declaration at line 32 of file call_save_map_service.hpp, definition at line 95 of file call_save_map_service.cpp.

CallSaveMapService()​

moveit_pro::behaviors::CallSaveMapService::CallSaveMapService (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources, std::unique_ptr< ClientInterfaceBase< SlamToolboxSaveMap > > client_interface)
explicit

Declaration at line 35 of file call_save_map_service.hpp, definition at line 101 of file call_save_map_service.cpp.

Private Member Functions​

createRequest()​

tl::expected< SlamToolboxSaveMap::Request, std::string > moveit_pro::behaviors::CallSaveMapService::createRequest ()
virtual

Creates a service request message containing the map name read from the "map_name" input port.

Returns

Returns an error if the "map_name" port is not set or is empty. slam_toolbox validates the name against ^[A-Za-z0-9_./-]+$, which an empty name fails, so it would answer with the same RESULT_UNDEFINED_FAILURE it uses for a failed write. Rejecting it here keeps that distinction in the message the operator sees.

Declaration at line 55 of file call_save_map_service.hpp, definition at line 176 of file call_save_map_service.cpp.

getFuture()​

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

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

Definition at line 66 of file call_save_map_service.hpp.

getResponseTimeout()​

tl::expected< std::chrono::duration< double >, std::string > moveit_pro::behaviors::CallSaveMapService::getResponseTimeout ()
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 46 of file call_save_map_service.hpp, definition at line 138 of file call_save_map_service.cpp.

getServiceName()​

tl::expected< std::string, std::string > moveit_pro::behaviors::CallSaveMapService::getServiceName ()
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 44 of file call_save_map_service.hpp, definition at line 126 of file call_save_map_service.cpp.

getWaitForServerAvailableTimeout()​

tl::expected< std::chrono::duration< double >, std::string > moveit_pro::behaviors::CallSaveMapService::getWaitForServerAvailableTimeout ()
virtual

Optional user-provided function to set the timeout used when waiting for the service server to be available.

If no user-defined implementation is provided, the default implementation returns 3.0 seconds, which will be the timeout duration for waiting for the service server to become available.

Returns

Returns the service server wait 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 47 of file call_save_map_service.hpp, definition at line 157 of file call_save_map_service.cpp.

processResponse()​

tl::expected< bool, std::string > moveit_pro::behaviors::CallSaveMapService::processResponse (const SlamToolboxSaveMap::Response & response)

Determines whether the map was saved based on the response's result code.

Parameters
response

Response message received from the service server.

Returns

True only when the result code is RESULT_SUCCESS. Any other code is reported as an error naming the code, because slam_toolbox reports a failed save in this field rather than by failing the call.

Declaration at line 63 of file call_save_map_service.hpp, definition at line 231 of file call_save_map_service.cpp.

Private Member Attributes​

future_​

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

Holds the result of calling the service asynchronously.

Definition at line 74 of file call_save_map_service.hpp.

map_name_​

std::string moveit_pro::behaviors::CallSaveMapService::map_name_

Map name validated by createRequest, kept so processResponse can name it without re-reading the port.

Definition at line 77 of file call_save_map_service.hpp.

Public Static Functions​

metadata()​

BT::KeyValueVector moveit_pro::behaviors::CallSaveMapService::metadata ()
static

Declaration at line 41 of file call_save_map_service.hpp, definition at line 121 of file call_save_map_service.cpp.

providedPorts()​

BT::PortsList moveit_pro::behaviors::CallSaveMapService::providedPorts ()
static

Declaration at line 39 of file call_save_map_service.hpp, definition at line 108 of file call_save_map_service.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.15.0.