|
using | PublisherType = rclcpp::Publisher< MessageT > |
| Provide various typedefs to resemble the rclcpp::Publisher type.
|
|
using | PublisherSharedPtr = typename rclcpp::Publisher< MessageT >::SharedPtr |
|
using | PublishedType = typename rclcpp::TypeAdapter< MessageT >::custom_type |
|
using | ROSMessageType = typename rclcpp::TypeAdapter< MessageT >::ros_message_type |
|
|
| RealtimePublisher (PublisherSharedPtr publisher) |
| Constructor for the realtime publisher.
|
|
| ~RealtimePublisher () |
| Destructor.
|
|
void | stop () |
| Stop the realtime publisher.
|
|
bool | can_publish () const |
| Check if the realtime publisher is in a state to publish messages.
|
|
bool | try_publish (const MessageT &msg) |
| Try to publish the given message.
|
|
std::thread & | get_thread () |
| Get the thread object for the publishing thread.
|
|
const std::thread & | get_thread () const |
| Get the thread object for the publishing thread.
|
|
const MessageT & | get_msg () const |
|
std::mutex & | get_mutex () |
| Get the mutex protecting the stored message.
|
|
const std::mutex & | get_mutex () const |
| Get the mutex protecting the stored message.
|
|
◆ RealtimePublisher()
template<class MessageT >
Constructor for the realtime publisher.
Starts a dedicated thread for message publishing. The publishing thread runs the publishingLoop() function to handle message delivery in a non-realtime context.
- Parameters
-
publisher | the ROS publisher to wrap |
◆ can_publish()
template<class MessageT >
Check if the realtime publisher is in a state to publish messages.
- Returns
- true if the publisher is in a state to publish messages
◆ get_thread() [1/2]
template<class MessageT >
Get the thread object for the publishing thread.
This can be used to set thread properties.
◆ get_thread() [2/2]
template<class MessageT >
Get the thread object for the publishing thread.
This can be used to set thread properties.
◆ stop()
template<class MessageT >
Stop the realtime publisher.
Signals the publishing thread to exit by setting keep_running_ to false and notifying the condition variable. This allows the publishing loop to break out of its wait state and exit cleanly.
◆ try_publish()
template<class MessageT >
Try to publish the given message.
This method attempts to publish the given message if the publisher is in a state to do so. It uses a try_lock to avoid blocking if the mutex is already held by another thread.
- Parameters
-
[in] | msg | The message to publish |
- Returns
- true if the message was successfully published, false otherwise
The documentation for this class was generated from the following file: