|
|
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 | trylock () |
| | Try to acquire the data lock for non-realtime message publishing.
|
| |
| 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.
|
| |
| bool | tryPublish (const MessageT &msg) |
| | Try to publish the given message (deprecated)
|
| |
| void | unlockAndPublish () |
| | Unlock the msg_ variable for the non-realtime thread to start publishing.
|
| |
| void | lock () |
| | Acquire the data lock.
|
| |
|
void | unlock () |
| | Unlocks the data without publishing anything.
|
| |
| 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.
◆ lock()
template<class MessageT >
Acquire the data lock.
This blocking call acquires exclusive access to the msg_ variable. Use trylock() for non-blocking attempts to acquire the lock.
◆ 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
◆ trylock()
template<class MessageT >
Try to acquire the data lock for non-realtime message publishing.
It first checks if the current state allows non-realtime message publishing (turn_ == REALTIME) and then attempts to lock
- Returns
- true if the lock was successfully acquired, false otherwise
◆ tryPublish()
template<class MessageT >
Try to publish the given message (deprecated)
- Deprecated:
- This method is deprecated and should be replaced with try_publish()
This method is deprecated and should be replaced with try_publish(). It 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
◆ unlockAndPublish()
template<class MessageT >
Unlock the msg_ variable for the non-realtime thread to start publishing.
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.
The documentation for this class was generated from the following file: