Template Class RealtimePublisher
Defined in File realtime_publisher.hpp
Class Documentation
-
template<class MessageT>
class RealtimePublisher Public Types
-
using PublisherType = rclcpp::Publisher<MessageT>
Provide various typedefs to resemble the rclcpp::Publisher type.
Public Functions
Constructor for the realtime publisher.
- Parameters:
publisher – the publisher to wrap
-
inline RealtimePublisher()
-
inline ~RealtimePublisher()
Destructor.
-
inline void stop()
Stop the realtime publisher from sending out more ROS messages.
-
inline bool trylock()
Try to get the data lock from realtime.
To publish data from the realtime loop, you need to run trylock to attempt to get unique access to the msg_ variable. Trylock returns true if the lock was acquired, and false if it failed to get the lock.
-
inline bool tryPublish(const MessageT &msg)
Try to get the data lock from realtime and publish the given message.
Tries to gain unique access to msg_ variable. If this succeeds update the msg_ variable and call unlockAndPublish
- Returns:
false in case no lock for the realtime variable could be acquired
-
inline void unlockAndPublish()
Unlock the msg_ variable.
After a successful trylock and after the data is written to the mgs_ variable, the lock has to be released for the message to get published on the specified topic.
-
inline void lock()
Get the data lock form non-realtime.
To publish data from the realtime loop, you need to run trylock to attempt to get unique access to the msg_ variable. Trylock returns true if the lock was acquired, and false if it failed to get the lock.
-
inline void unlock()
Unlocks the data without publishing anything.
-
inline std::thread &get_thread()
-
inline const std::thread &get_thread() const
-
using PublisherType = rclcpp::Publisher<MessageT>