public class PeriodicPublisher extends Object
beginPublishing(int) or beginPublishing(Object, int) methods. Note that subsequent calls
to these method will automatically cancel the previous periodic publishing and start again at the newly specified rate.
To cancel periodic publishing, use the cancelPublishing() method. You can also change the message that is
being published without stopping or restarting the publishing by using the setMsg(Object) method.| Modifier and Type | Class and Description |
|---|---|
protected class |
PeriodicPublisher.PublisherTimerTask
The class that is called by Java's
Timer and invokes the actual
publish call. |
| Modifier and Type | Field and Description |
|---|---|
protected Object |
msg
The ROS message that will be periodically published
|
protected int |
period
The period at which this object is publishing; -1 if it is not currently publishing.
|
protected Publisher |
pub
The
Publisher to which publish calls are made |
protected PeriodicPublisher.PublisherTimerTask |
timerTask
The timer task that calls the publish.
|
| Constructor and Description |
|---|
PeriodicPublisher(Publisher pub)
Initializes with a
Publisher for publishing action messages to ROS. |
PeriodicPublisher(Publisher pub,
Object msg)
Initializes with a
Publisher for publishing action messages to ROS. |
PeriodicPublisher(String topic,
String msgType,
RosBridge rosBridge)
|
PeriodicPublisher(String topic,
String msgType,
RosBridge rosBridge,
Object msg)
|
| Modifier and Type | Method and Description |
|---|---|
void |
beginPublishing(int period)
Causes this object to begin periodically publishing at the specified rate.
|
void |
beginPublishing(Object msg,
int period)
Causes this object to begin periodically publishing the specified message at the specified rate.
|
void |
cancelPublishing()
Stops this object from periodically publishing, or does nothing if it is not currently periodically publishing.
|
Object |
getMsg()
Returns the ROS message that is being or will be periodically published.
|
Publisher |
getPub() |
int |
getPublishingPeriod()
The delay in milliseconds between subsequent periodic publishes.
|
boolean |
isPublishing()
Indicates whether this object is currently periodically publishing.
|
void |
setMsg(Object msg)
Sets the ROS message that will be periodically published.
|
void |
setPub(Publisher pub) |
protected volatile Object msg
protected int period
protected PeriodicPublisher.PublisherTimerTask timerTask
public PeriodicPublisher(String topic, String msgType, RosBridge rosBridge)
Publisher for this action using the specified topic, message type, and RosBridge connection.topic - the ros topic to which messages will be publishedmsgType - the ros message type of th target topicrosBridge - the RosBridge connection to use.public PeriodicPublisher(String topic, String msgType, RosBridge rosBridge, Object msg)
Publisher for this action using the specified topic, message type, and RosBridge connection.topic - the ros topic to which messages will be publishedmsgType - the ros message type of th target topicrosBridge - the RosBridge connection to use.msg - the ROS message to periodically publish when publishing beginspublic PeriodicPublisher(Publisher pub)
Publisher for publishing action messages to ROS.pub - the Publisher to which to publishpublic Publisher getPub()
public void setPub(Publisher pub)
public Object getMsg()
public void setMsg(Object msg)
msg - the ROS message that will be published.public int getPublishingPeriod()
public void cancelPublishing()
public boolean isPublishing()
public void beginPublishing(int period)
setMsg(Object) method or by using the alternative beginPublishing(Object, int)
method that takes the message to publish.period - the time in milliseconds between publishespublic void beginPublishing(Object msg, int period)
msg - the ROS message to publishperiod - the time in milliseconds between publishesCopyright © 2016. All rights reserved.