public class RepeatingActionPublisher extends ActionPublisher.DirectActionPublisher
ActionPublisher that allows a single call to publishAction(Action)
to publish a ROS message multiple times at a given rate. This is useful, for example, if to execute a complete "rotate" action
a geometry_msgs/Twist message needs to be published to a robot multiple times in quick succession. This class can either
be synchronous, in which the publishAction(Action) method blocks until
all repeated publishes are complete; or asynchronous, in which the publishAction(Action) method
returns immediately after starting its multiple publish calls in a separate thread.
Note that by default, the publishAction(Action) method will return a delay time
of zero if set to asynchronous, or the period is set to synchronous.
However, you can change this value with the setDelayTime(int) method or by using the more complete constructor.
| Modifier and Type | Class and Description |
|---|---|
protected class |
RepeatingActionPublisher.PublishTask
Callback class for timer event that publishes the ROS message every time it is called
until it's been called for all initial n times specified.
|
ActionPublisher.DirectActionPublisher| Modifier and Type | Field and Description |
|---|---|
protected int |
delayTime
The time delay to return
|
protected Object |
msg
The ROS message to publish
|
protected int |
n
The number of times a message will be published for each call of
publishAction(Action) |
protected int |
period
The length of time in milliseconds between publish messages
|
protected boolean |
synchronous
If true, then
publishAction(Action) blocks until all messages
have been published. |
pub| Constructor and Description |
|---|
RepeatingActionPublisher(ros.Publisher pub,
Object msg,
int period,
int n,
boolean synchronous)
Initializes
|
RepeatingActionPublisher(ros.Publisher pub,
Object msg,
int period,
int n,
boolean synchronous,
int delayTime)
Initializes
|
RepeatingActionPublisher(String topic,
String msgType,
ros.RosBridge rosBridge,
Object msg,
int period,
int n,
boolean synchronous)
Initializes.
|
RepeatingActionPublisher(String topic,
String msgType,
ros.RosBridge rosBridge,
Object msg,
int period,
int n,
boolean synchronous,
int delayTime)
Initializes
|
| Modifier and Type | Method and Description |
|---|---|
int |
getDelayTime()
Returns the value that the method
publishAction(Action) will return. |
Object |
getMsg() |
int |
getN() |
int |
getPeriod() |
boolean |
isSynchronous() |
int |
publishAction(burlap.mdp.core.action.Action a)
Takes a BURLAP
Action turns into a ROS message, and publishes it to ROS through this
object's ROS Bridge Publisher object. |
void |
setDelayTime(int delayTime)
By default,
publishAction(Action) will return zero; use this method
to set an alternative value for it to return. |
void |
setMsg(Object msg) |
void |
setN(int n) |
void |
setPeriod(int period) |
void |
setSynchronous(boolean synchronous) |
getPub, publish, setPubprotected Object msg
protected int period
protected int n
publishAction(Action)protected boolean synchronous
publishAction(Action) blocks until all messages
have been published. If false, then the method immediately returns after starting publishingprotected int delayTime
public RepeatingActionPublisher(String topic, String msgType, ros.RosBridge rosBridge, Object msg, int period, int n, boolean synchronous)
publishAction(Action) will
be set to the same as the period.topic - the ROS topic to publish tomsgType - the ROS message type of the ROS topicrosBridge - the RosBridge connectionmsg - the constant ROS message that will always be publishedperiod - the time delay between subsequent publishes to rosn - the number of times a ros message will be published for each call of publishAction(Action)synchronous - if true, publishAction(Action) returns immediately; if false, waits for all n publishes to complete.public RepeatingActionPublisher(String topic, String msgType, ros.RosBridge rosBridge, Object msg, int period, int n, boolean synchronous, int delayTime)
topic - the ROS topic to publish tomsgType - the ROS message type of the ROS topicrosBridge - the RosBridge connectionmsg - the constant ROS message that will always be publishedperiod - the time delay between subsequent publishes to rosn - the number of times a ros message will be published for each call of publishAction(Action)synchronous - if true, publishAction(Action) returns immediately; if false, waits for all n publishes to complete.delayTime - the time to delay returned by publishAction(Action).public RepeatingActionPublisher(ros.Publisher pub,
Object msg,
int period,
int n,
boolean synchronous)
pub - the Publisher used to publish action messages.msg - the constant ROS message that will always be publishedperiod - the time delay between subsequent publishes to rosn - the number of times a ros message will be published for each call of publishAction(Action)synchronous - if true, publishAction(Action) returns immediately; if false, waits for all n publishes to complete.public RepeatingActionPublisher(ros.Publisher pub,
Object msg,
int period,
int n,
boolean synchronous,
int delayTime)
pub - the Publisher used to publish action messages.msg - the constant ROS message that will always be publishedperiod - the time delay between subsequent publishes to rosn - the number of times a ros message will be published for each call of publishAction(Action)synchronous - if true, publishAction(Action) returns immediately; if false, waits for all n publishes to complete.delayTime - the time to delay returned by publishAction(Action).public Object getMsg()
public void setMsg(Object msg)
public int getPeriod()
public void setPeriod(int period)
public int getN()
public void setN(int n)
public boolean isSynchronous()
public void setSynchronous(boolean synchronous)
public int getDelayTime()
publishAction(Action) will return.publishAction(Action) will return.public void setDelayTime(int delayTime)
publishAction(Action) will return zero; use this method
to set an alternative value for it to return.delayTime - the value that the method publishAction(Action) will return.public int publishAction(burlap.mdp.core.action.Action a)
ActionPublisherAction turns into a ROS message, and publishes it to ROS through this
object's ROS Bridge Publisher object. Note that when you implement this method, you must make the publish
call to ROSBridge yourself using a Publisher object.a - The BURLAP Action to turn into a ROS message and publish.Copyright © 2016. All rights reserved.