mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
mrs_lib::SubscriberHandlerOptions Struct Reference

A helper class to simplify setup of SubscriberHandler construction. This class is passed to the SubscriberHandler constructor and specifies its common options. More...

#include <subscriber_handler.h>

Public Member Functions

 SubscriberHandlerOptions (const rclcpp::Node::SharedPtr &node)
 

Public Attributes

rclcpp::Node::SharedPtr node
 The ROS NodeHandle to be used for subscription.
 
std::string node_name = {}
 Name of the ROS node, using this handle (used for messages printed to console).
 
std::string topic_name = {}
 Name of the ROS topic to be handled.
 
std::shared_ptr< mrs_lib::TimeoutManagertimeout_manager = nullptr
 Will be used for handling message timouts if necessary. If no manager is specified, it will be created with rate equal to half of no_message_timeout.
 
rclcpp::Duration no_message_timeout
 If no new message is received for this duration, the timeout_callback function will be called. If timeout_callback is empty, an error message will be printed to the console.
 
std::function< void(const std::string &topic_name, const rclcpp::Time &last_msg)> timeout_callback
 This function will be called if no new message is received for the no_message_timeout duration. If this variable is empty, an error message will be printed to the console.
 
bool threadsafe = true
 If true, all methods of the SubscriberHandler will be mutexed (using a recursive mutex) to avoid data races.
 
bool autostart
 If true, the SubscriberHandler will be started after construction. Otherwise it has to be started using the start() method.
 
rclcpp::QoS qos = rclcpp::SystemDefaultsQoS()
 
rclcpp::SubscriptionOptions subscription_options = rclcpp::SubscriptionOptions()
 

Detailed Description

A helper class to simplify setup of SubscriberHandler construction. This class is passed to the SubscriberHandler constructor and specifies its common options.

Note
Any option, passed directly to the SubscriberHandler constructor outside this structure, OVERRIDES values in this structure. The values in this structure can be thought of as default common values for all SubscriberHandler objects you want to create, and values passed directly to the constructor as specific options for the concrete handler.
Examples
subscriber_handler/example.cpp.

Member Data Documentation

◆ autostart

bool mrs_lib::SubscriberHandlerOptions::autostart
Initial value:
=
true

If true, the SubscriberHandler will be started after construction. Otherwise it has to be started using the start() method.

◆ no_message_timeout

rclcpp::Duration mrs_lib::SubscriberHandlerOptions::no_message_timeout
Initial value:
=
mrs_lib::no_timeout

If no new message is received for this duration, the timeout_callback function will be called. If timeout_callback is empty, an error message will be printed to the console.

◆ timeout_callback

std::function<void(const std::string& topic_name, const rclcpp::Time& last_msg)> mrs_lib::SubscriberHandlerOptions::timeout_callback
Initial value:
=
{}

This function will be called if no new message is received for the no_message_timeout duration. If this variable is empty, an error message will be printed to the console.


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