#include <realtime_publisher.h>
Public Member Functions | |
void | init (const ros::NodeHandle &node, const std::string &topic, int queue_size, bool latched=false) |
void | lock () |
Get the data lock form non-realtime. More... | |
RealtimePublisher (const ros::NodeHandle &node, const std::string &topic, int queue_size, bool latched=false) | |
Constructor for the realtime publisher. More... | |
RealtimePublisher () | |
void | stop () |
Stop the realtime publisher from sending out more ROS messages. More... | |
bool | trylock () |
Try to get the data lock from realtime. More... | |
void | unlock () |
Unlocks the data without publishing anything. More... | |
void | unlockAndPublish () |
Unlock the msg_ variable. More... | |
~RealtimePublisher () | |
Destructor. More... | |
Public Attributes | |
Msg | msg_ |
The msg_ variable contains the data that will get published on the ROS topic. More... | |
Private Types | |
enum | { REALTIME, NON_REALTIME, LOOP_NOT_STARTED } |
Private Member Functions | |
void | construct (int queue_size, bool latched=false) |
bool | is_running () const |
RealtimePublisher & | operator= (const RealtimePublisher &)=delete |
void | publishingLoop () |
RealtimePublisher (const RealtimePublisher &)=delete | |
Private Attributes | |
volatile bool | is_running_ |
volatile bool | keep_running_ |
std::mutex | msg_mutex_ |
ros::NodeHandle | node_ |
ros::Publisher | publisher_ |
std::thread | thread_ |
std::string | topic_ |
int | turn_ |
Definition at line 52 of file realtime_publisher.h.
|
private |
Enumerator | |
---|---|
REALTIME | |
NON_REALTIME | |
LOOP_NOT_STARTED |
Definition at line 239 of file realtime_publisher.h.
|
inline |
Constructor for the realtime publisher.
node | the nodehandle that specifies the namespace (or prefix) that is used to advertise the ROS topic |
topic | the topic name to advertise |
queue_size | the size of the outgoing ROS buffer |
latched | . optional argument (defaults to false) to specify is publisher is latched or not |
Definition at line 66 of file realtime_publisher.h.
|
inline |
Definition at line 72 of file realtime_publisher.h.
|
inline |
Destructor.
Definition at line 78 of file realtime_publisher.h.
|
privatedelete |
|
inlineprivate |
Definition at line 182 of file realtime_publisher.h.
|
inline |
Definition at line 93 of file realtime_publisher.h.
|
inlineprivate |
Definition at line 190 of file realtime_publisher.h.
|
inline |
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 aquired, and false if it failed to get the lock.
Definition at line 156 of file realtime_publisher.h.
|
privatedelete |
|
inlineprivate |
Definition at line 192 of file realtime_publisher.h.
|
inline |
Stop the realtime publisher from sending out more ROS messages.
Definition at line 101 of file realtime_publisher.h.
|
inline |
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 aquired, and false if it failed to get the lock.
Definition at line 115 of file realtime_publisher.h.
|
inline |
Unlocks the data without publishing anything.
Definition at line 172 of file realtime_publisher.h.
|
inline |
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.
Definition at line 141 of file realtime_publisher.h.
|
private |
Definition at line 228 of file realtime_publisher.h.
|
private |
Definition at line 229 of file realtime_publisher.h.
Msg realtime_tools::RealtimePublisher< Msg >::msg_ |
The msg_ variable contains the data that will get published on the ROS topic.
Definition at line 57 of file realtime_publisher.h.
|
private |
Definition at line 233 of file realtime_publisher.h.
|
private |
Definition at line 226 of file realtime_publisher.h.
|
private |
Definition at line 227 of file realtime_publisher.h.
|
private |
Definition at line 231 of file realtime_publisher.h.
|
private |
Definition at line 225 of file realtime_publisher.h.
|
private |
Definition at line 240 of file realtime_publisher.h.