Modulo 5.0.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
modulo_core::communication::MessagePair< MsgT, DataT > Class Template Reference

The MessagePair stores a pointer to a variable and translates the value of this pointer back and forth between the corresponding ROS messages. More...

#include <MessagePair.hpp>

Inheritance diagram for modulo_core::communication::MessagePair< MsgT, DataT >:
modulo_core::communication::MessagePairInterface

Public Member Functions

 MessagePair (std::shared_ptr< DataT > data, std::shared_ptr< rclcpp::Clock > clock)
 Constructor of the MessagePair.
 
 MessagePair (std::shared_ptr< DataT > data, std::shared_ptr< rclcpp::Clock > clock)
 Constructor of the MessagePair that requires custom message types only.
 
MsgT write_message () const
 Write the value of the data pointer to a ROS message.
 
void read_message (const MsgT &message)
 Read a ROS message and store the value in the data pointer.
 
std::shared_ptr< DataT > get_data () const
 Get the data pointer.
 
void set_data (const std::shared_ptr< DataT > &data)
 Set the data pointer.
 
 MessagePair (std::shared_ptr< bool > data, std::shared_ptr< rclcpp::Clock > clock)
 
 MessagePair (std::shared_ptr< double > data, std::shared_ptr< rclcpp::Clock > clock)
 
 MessagePair (std::shared_ptr< std::vector< double > > data, std::shared_ptr< rclcpp::Clock > clock)
 
 MessagePair (std::shared_ptr< int > data, std::shared_ptr< rclcpp::Clock > clock)
 
 MessagePair (std::shared_ptr< std::string > data, std::shared_ptr< rclcpp::Clock > clock)
 
 MessagePair (std::shared_ptr< state_representation::State > data, std::shared_ptr< rclcpp::Clock > clock)
 
- Public Member Functions inherited from modulo_core::communication::MessagePairInterface
 MessagePairInterface (MessageType type)
 Constructor with the message type.
 
virtual ~MessagePairInterface ()=default
 Default virtual destructor.
 
 MessagePairInterface (const MessagePairInterface &message_pair)=default
 Copy constructor from another MessagePairInterface.
 
template<typename MsgT , typename DataT >
std::shared_ptr< MessagePair< MsgT, DataT > > get_message_pair (bool validate_pointer=true)
 Get a pointer to a derived MessagePair instance from a MessagePairInterface pointer.
 
template<typename MsgT , typename DataT >
MsgT write ()
 Get the ROS message of a derived MessagePair instance through the MessagePairInterface pointer.
 
template<typename MsgT , typename DataT >
void read (const MsgT &message)
 Read a ROS message and set the data of the derived MessagePair instance through the MessagePairInterface pointer.
 
MessageType get_type () const
 Get the MessageType of the MessagePairInterface.
 

Detailed Description

template<typename MsgT, typename DataT>
class modulo_core::communication::MessagePair< MsgT, DataT >

The MessagePair stores a pointer to a variable and translates the value of this pointer back and forth between the corresponding ROS messages.

Template Parameters
MsgTROS message type of the MessagePair
DataTData type corresponding to the ROS message type

Definition at line 20 of file MessagePair.hpp.

Constructor & Destructor Documentation

◆ MessagePair() [1/8]

template<typename MsgT , typename DataT >
modulo_core::communication::MessagePair< MsgT, DataT >::MessagePair ( std::shared_ptr< DataT >  data,
std::shared_ptr< rclcpp::Clock >  clock 
)

Constructor of the MessagePair.

Parameters
dataThe pointer referring to the data stored in the MessagePair
clockThe ROS clock for translating messages

◆ MessagePair() [2/8]

template<typename MsgT , typename DataT >
modulo_core::communication::MessagePair< MsgT, DataT >::MessagePair ( std::shared_ptr< DataT >  data,
std::shared_ptr< rclcpp::Clock >  clock 
)
inline

Constructor of the MessagePair that requires custom message types only.

Parameters
dataThe pointer referring to the data stored in the MessagePair
clockThe ROS clock for translating messages

Definition at line 34 of file MessagePair.hpp.

◆ MessagePair() [3/8]

modulo_core::communication::MessagePair< std_msgs::msg::Bool, bool >::MessagePair ( std::shared_ptr< bool >  data,
std::shared_ptr< rclcpp::Clock >  clock 
)

Definition at line 8 of file MessagePair.cpp.

◆ MessagePair() [4/8]

modulo_core::communication::MessagePair< std_msgs::msg::Float64, double >::MessagePair ( std::shared_ptr< double >  data,
std::shared_ptr< rclcpp::Clock >  clock 
)

Definition at line 12 of file MessagePair.cpp.

◆ MessagePair() [5/8]

modulo_core::communication::MessagePair< std_msgs::msg::Float64MultiArray, std::vector< double > >::MessagePair ( std::shared_ptr< std::vector< double > >  data,
std::shared_ptr< rclcpp::Clock >  clock 
)

Definition at line 17 of file MessagePair.cpp.

◆ MessagePair() [6/8]

modulo_core::communication::MessagePair< std_msgs::msg::Int32, int >::MessagePair ( std::shared_ptr< int >  data,
std::shared_ptr< rclcpp::Clock >  clock 
)

Definition at line 22 of file MessagePair.cpp.

◆ MessagePair() [7/8]

modulo_core::communication::MessagePair< std_msgs::msg::String, std::string >::MessagePair ( std::shared_ptr< std::string >  data,
std::shared_ptr< rclcpp::Clock >  clock 
)

Definition at line 26 of file MessagePair.cpp.

◆ MessagePair() [8/8]

modulo_core::communication::MessagePair< EncodedState, state_representation::State >::MessagePair ( std::shared_ptr< state_representation::State >  data,
std::shared_ptr< rclcpp::Clock >  clock 
)

Definition at line 31 of file MessagePair.cpp.

Member Function Documentation

◆ get_data()

template<typename MsgT , typename DataT >
std::shared_ptr< DataT > modulo_core::communication::MessagePair< MsgT, DataT >::get_data ( ) const
inline

Get the data pointer.

Definition at line 178 of file MessagePair.hpp.

◆ read_message()

template<typename MsgT , typename DataT >
void modulo_core::communication::MessagePair< MsgT, DataT >::read_message ( const MsgT &  message)
inline

Read a ROS message and store the value in the data pointer.

Parameters
messageThe ROS message to read
Exceptions
modulo_core::exceptions::NullPointerExceptionif the data pointer is null
modulo_core::exceptions::MessageTranslationExceptionif the message could not be read

Definition at line 148 of file MessagePair.hpp.

◆ set_data()

template<typename MsgT , typename DataT >
void modulo_core::communication::MessagePair< MsgT, DataT >::set_data ( const std::shared_ptr< DataT > &  data)
inline

Set the data pointer.

Exceptions
modulo_core::exceptions::NullPointerExceptionif the provided data pointer is null

Definition at line 183 of file MessagePair.hpp.

◆ write_message()

template<typename MsgT , typename DataT >
MsgT modulo_core::communication::MessagePair< MsgT, DataT >::write_message ( ) const
inline

Write the value of the data pointer to a ROS message.

Returns
The value of the data pointer as a ROS message
Exceptions
modulo_core::exceptions::NullPointerExceptionif the data pointer is null
modulo_core::exceptions::MessageTranslationExceptionif the data could not be written to message

Definition at line 112 of file MessagePair.hpp.


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