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>
|
|
| Module (const std::string name) |
| |
|
bool | shouldExit () |
| |
|
|
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 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...
|
| |
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
-
| name | name of the module. Is passed to the ROS node. |
◆ 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
-
| Srv | The name of the service to request. |
- Parameters
-
| timeout | The timeout for the service call. |
| client | The client to use to request the service. |
| response | The 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
-
| Srv | The name of the service to request. |
- Parameters
-
| n | Number of times to retry until accepting the service is not available. |
| timeout | The timeout to wait for the service. |
| serviceName | The name of the service to request. |
| response | Response 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
-
| Srv | The name of the service to request. |
- Parameters
-
| n | The number of times to retry. |
| timeout | The timeout to wait for the service. |
| serviceName | The 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
-
| tryExecute | function to execute |
| executeIfFail | if executing tryExecute fails, this function is executed |
| topic | The topic to print. |
| logger | The logger to use. |
- Returns
- true if the initialization was successful, false otherwise
The documentation for this class was generated from the following files:
- common/module.hpp
- modules/JournalControl/src/journalcontrol.cpp
- common/module.cpp