ATOS
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Module Class Reference

The Module class This class is the base class for all modules. It is a derived class of ROS2 node. It provides an interface for all modules. More...

#include <module.hpp>

Inheritance diagram for Module:
Inheritance graph
[legend]
Collaboration diagram for Module:
Collaboration graph
[legend]

Public Member Functions

 Module (const std::string name)
 
bool shouldExit ()
 

Protected Member Functions

virtual void onFailureMessage (const ROSChannels::Failure::message_type::SharedPtr)
 
virtual void onGetStatusResponse (const ROSChannels::GetStatusResponse::message_type::SharedPtr)
 
virtual void onGetStatusMessage (const ROSChannels::GetStatus::message_type::SharedPtr)
 
virtual void onInitMessage (const ROSChannels::Init::message_type::SharedPtr)
 
virtual void onConnectMessage (const ROSChannels::Connect::message_type::SharedPtr)
 
virtual void onDisconnectMessage (const ROSChannels::Disconnect::message_type::SharedPtr)
 
virtual void onArmMessage (const ROSChannels::Arm::message_type::SharedPtr)
 
virtual void onDisarmMessage (const ROSChannels::Disarm::message_type::SharedPtr)
 
virtual void onObjectsConnectedMessage (const ROSChannels::ObjectsConnected::message_type::SharedPtr)
 
virtual void onAllClearMessage (const ROSChannels::AllClear::message_type::SharedPtr)
 
virtual void onStartMessage (const ROSChannels::Start::message_type::SharedPtr)
 
virtual void onStartObjectMessage (const ROSChannels::StartObject::message_type::SharedPtr)
 
virtual void onStopMessage (const ROSChannels::Stop::message_type::SharedPtr)
 
virtual void onAbortMessage (const ROSChannels::Abort::message_type::SharedPtr)
 
virtual void onReplayMessage (const ROSChannels::Replay::message_type::SharedPtr)
 
virtual void onExitMessage (const ROSChannels::Exit::message_type::SharedPtr)
 
template<typename Srv >
bool callService (const std::chrono::duration< double > &timeout, std::shared_ptr< rclcpp::Client< Srv >> &client, std::shared_ptr< typename Srv::Response > &response)
 This helper function is performs a service call given a client and yields a response. More...
 
template<typename Srv >
std::shared_ptr< rclcpp::Client< Srv > > nTimesWaitForService (int n, const std::chrono::duration< double > &timeout, const std::string &serviceName)
 This helper function waits for a service to become available and returns a client. More...
 
template<typename Srv >
bool nShotServiceRequest (int n, const std::chrono::duration< double > &timeout, const std::string &serviceName, std::shared_ptr< typename Srv::Response > &response)
 This helper function is used by rosnodes to request a service. More...
 

Static Protected Member Functions

static void tryHandleMessage (std::function< void()> tryExecute, std::function< void()> executeIfFail, const std::string &topic, const rclcpp::Logger &logger)
 A try/catch wrapper that logs messages. More...
 

Protected Attributes

bool quit =false
 
ROSChannels::GetStatusResponse::Pub getStatusResponsePub
 

Detailed Description

The Module class This class is the base class for all modules. It is a derived class of ROS2 node. It provides an interface for all modules.

Parameters
namename of the module. Is passed to the ROS node.

Member Function Documentation

◆ callService()

template<typename Srv >
bool Module::callService ( const std::chrono::duration< double > &  timeout,
std::shared_ptr< rclcpp::Client< Srv >> &  client,
std::shared_ptr< typename Srv::Response > &  response 
)
inlineprotected

This helper function is performs a service call given a client and yields a response.

Template Parameters
SrvThe name of the service to request.
Parameters
timeoutThe timeout for the service call.
clientThe client to use to request the service.
responseThe response of the service.
Returns
The response of the service.

◆ nShotServiceRequest()

template<typename Srv >
bool Module::nShotServiceRequest ( int  n,
const std::chrono::duration< double > &  timeout,
const std::string &  serviceName,
std::shared_ptr< typename Srv::Response > &  response 
)
inlineprotected

This helper function is used by rosnodes to request a service.

Template Parameters
SrvThe name of the service to request.
Parameters
nNumber of times to retry until accepting the service is not available.
timeoutThe timeout to wait for the service.
serviceNameThe name of the service to request.
responseResponse of the service, to be returned.
Returns
The response of the service.

◆ nTimesWaitForService()

template<typename Srv >
std::shared_ptr<rclcpp::Client<Srv> > Module::nTimesWaitForService ( int  n,
const std::chrono::duration< double > &  timeout,
const std::string &  serviceName 
)
inlineprotected

This helper function waits for a service to become available and returns a client.

Template Parameters
SrvThe name of the service to request.
Parameters
nThe number of times to retry.
timeoutThe timeout to wait for the service.
serviceNameThe name of the service to request.
Returns
The response of the service.

◆ tryHandleMessage()

void Module::tryHandleMessage ( std::function< void()>  tryExecute,
std::function< void()>  executeIfFail,
const std::string &  topic,
const rclcpp::Logger &  logger 
)
staticprotected

A try/catch wrapper that logs messages.

Parameters
tryExecutefunction to execute
executeIfFailif executing tryExecute fails, this function is executed
topicThe topic to print.
loggerThe logger to use.
Returns
true if the initialization was successful, false otherwise

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