@Deprecated public class AsynchronousRosEnvironment extends Object implements burlap.oomdp.singleagent.environment.Environment, ros.RosListenDelegate
RosEnvironment
or subclass the AbstractRosEnvironment instead. If you want actions to
send their message as a string of their name, set the ActionPublisher
for all actions to a ActionStringPublisher.
An environment wrapper for state information provided over ROS with BURLAP actions
that are published to ROS. This environment connects to ROS using ROSBridge, which
must be running. State information
from ROS is expected to use be of
type burlap_msgs/burlap_state. The burlap_state message is parsed into an actual BURLAP
State object using the object classes defined in a provided
BURLAP Domain. This parsed state may be further modified before
the environment's current state is set to it by overriding the onStateReceive(burlap.oomdp.core.states.State)
method, which receives the parsed state and returns a state object to which the environment's current
state will be updated.
When this environment has an action request (via executeAction(burlap.oomdp.singleagent.GroundedAction)),
it turns the request into a GroundedAction
object and a string rep of the object is retrieved (via the GroundedAction.toString()
method, and then published to a ROS topic. The calling thread is then stalled for some delay (giving time
for the action to be executed on the ROS robot and the state updated) before the executeAction(burlap.oomdp.singleagent.GroundedAction)
method returns. The fact that there is no "action completion" checking is why this is considered an asynchronous environment.
After creating an environment, it may be a good idea to call the blockUntilStateReceived() method
before doing anything with it. This method will block the calling thread until the environment receives a
state message from ROS which it uses to set its current state.
A BURLAP reward function and terminal function can also be set
(setRewardFunction(burlap.oomdp.singleagent.RewardFunction) and
setTerminalFunction(burlap.oomdp.core.TerminalFunction)) so that the environment will returns meaningful messages
from the getLastReward() and isInTerminalState() methods.
Note that the the environment's current state will be updated as frequently as ROSBridge provides updates, but the states before and after actions returned are those from fixed time intervals set by the client (and described above).
You may want to specify a throttle rate and queue size for how quickly the environment receives state message from ROS Bridge. If States are published too quickly, you may find the environment's state is lagging behind as it processes each received state in order.
| Modifier and Type | Field and Description |
|---|---|
protected ros.Publisher |
actionPub
Deprecated.
|
protected int |
actionSleepMS
Deprecated.
|
protected boolean |
addHeader
Deprecated.
|
protected burlap.oomdp.core.states.State |
curState
Deprecated.
|
protected int |
debugCode
Deprecated.
|
protected burlap.oomdp.core.Domain |
domain
Deprecated.
|
protected double |
lastReward
Deprecated.
|
protected boolean |
printStateAsReceived
Deprecated.
|
protected Boolean |
receivedFirstState
Deprecated.
|
protected burlap.oomdp.singleagent.RewardFunction |
rf
Deprecated.
|
protected ros.RosBridge |
rosBridge
Deprecated.
|
protected burlap.oomdp.core.TerminalFunction |
tf
Deprecated.
|
| Constructor and Description |
|---|
AsynchronousRosEnvironment(burlap.oomdp.core.Domain domain,
String rosBridgeURI,
String rosStateTopic,
String rosActionTopic,
int actionSleepMS)
Deprecated.
Creates an environment wrapper for state information provided over ROS with BURLAP actions
needing to be published to ROS.
|
AsynchronousRosEnvironment(burlap.oomdp.core.Domain domain,
String rosBridgeURI,
String rosStateTopic,
String rosActionTopic,
int actionSleepMS,
int rosBridgeThrottleRate,
int rosBridgeQueueLength)
Deprecated.
Creates an environment wrapper for state information provided over ROS with BURLAP actions
needing to be published to ROS.
|
AsynchronousRosEnvironment(burlap.oomdp.core.Domain domain,
String rosBridgeURI,
String rosStateTopic,
String rosActionTopic,
String rosStateTopicMessageType,
String rosActionTopicMessageType,
int actionSleepMS,
int rosBridgeThrottleRate,
int rosBridgeQueueLength)
Deprecated.
Creates an environment wrapper for state information provided over ROS with BURLAP actions
needing to be published to ROS.
|
| Modifier and Type | Method and Description |
|---|---|
void |
blockUntilStateReceived()
Deprecated.
A method you can call that forces the calling thread to wait until the first state from ROS has been received.
|
burlap.oomdp.singleagent.environment.EnvironmentOutcome |
executeAction(burlap.oomdp.singleagent.GroundedAction ga)
Deprecated.
|
burlap.oomdp.core.states.State |
getCurrentObservation()
Deprecated.
|
Map<String,Object> |
getHeader()
Deprecated.
Specifies the header data that will be added to an action message if this environment has been set to
add a header (by default headers are not added).
|
double |
getLastReward()
Deprecated.
|
ros.RosBridge |
getRosBridge()
Deprecated.
Returns the
RosBridge object to which this environment is connected. |
boolean |
isInTerminalState()
Deprecated.
|
protected burlap.oomdp.core.states.State |
JSONPreparedToState(List<Map<String,Object>> objects)
Deprecated.
|
protected burlap.oomdp.core.states.State |
JSONToState(com.fasterxml.jackson.databind.JsonNode objects)
Deprecated.
Takes a
JsonNode that represents the BURLAP state and turns it into
a BURLAP State object. |
protected burlap.oomdp.core.states.State |
onStateReceive(burlap.oomdp.core.states.State s)
Deprecated.
This method is called whenever a state message from ROS is received.
|
void |
receive(com.fasterxml.jackson.databind.JsonNode data,
String stringRep)
Deprecated.
|
void |
receive(Map<String,Object> data,
String stringRep)
Deprecated.
|
void |
resetEnvironment()
Deprecated.
|
void |
setAddHeader(boolean addHeader)
Deprecated.
Specify whether a header object should be added to the action message.
|
void |
setPrintStateAsReceived(boolean printStateAsReceived)
Deprecated.
Sets whether the default implementation of
onStateReceive(burlap.oomdp.core.states.State) will print the
state information to the terminal. |
void |
setRewardFunction(burlap.oomdp.singleagent.RewardFunction rf)
Deprecated.
Sets a BURLAP
RewardFunction to use to provide reward signals from the getLastReward() method. |
void |
setTerminalFunction(burlap.oomdp.core.TerminalFunction tf)
Deprecated.
Sets the BURLAP
TerminalFunction to use to provide terminal state checks from the isInTerminalState(). |
protected burlap.oomdp.core.Domain domain
protected ros.RosBridge rosBridge
protected ros.Publisher actionPub
protected int actionSleepMS
protected burlap.oomdp.core.states.State curState
protected boolean addHeader
protected burlap.oomdp.singleagent.RewardFunction rf
protected burlap.oomdp.core.TerminalFunction tf
protected double lastReward
protected Boolean receivedFirstState
protected boolean printStateAsReceived
protected int debugCode
public AsynchronousRosEnvironment(burlap.oomdp.core.Domain domain,
String rosBridgeURI,
String rosStateTopic,
String rosActionTopic,
int actionSleepMS)
State object using the object classes defined in a provided
BURLAP Domain.
When this environment has an action request (via executeAction(burlap.oomdp.singleagent.GroundedAction)),
it turns the request into a GroundedAction
object and a string rep of the object is retrieved (via the GroundedAction.toString()
method, and then published to a ROS topic. The calling thread is then stalled for some delay (giving time
for the action to be executed on the ROS robot and the state updated) before the executeAction(burlap.oomdp.singleagent.GroundedAction)
method returns.
domain - the domain into which ROS burlap_state messages are parsedrosBridgeURI - the URI of the ros bridge server. Note that by default, ros bridge uses port 9090. An example URI is ws://localhost:9090rosStateTopic - the name of the ROS topic that publishes the burlap_msgs/burlap_state messages.rosActionTopic - the name of the ROS topic to which BURLAP actions are published (as strings)actionSleepMS - the amount of time that the executeAction(burlap.oomdp.singleagent.GroundedAction) method stalls after publishing an action.public AsynchronousRosEnvironment(burlap.oomdp.core.Domain domain,
String rosBridgeURI,
String rosStateTopic,
String rosActionTopic,
int actionSleepMS,
int rosBridgeThrottleRate,
int rosBridgeQueueLength)
State object using the object classes defined in a provided
BURLAP Domain.
When this environment has an action request (via executeAction(burlap.oomdp.singleagent.GroundedAction)),
it turns the request into a GroundedAction
object and a string rep of the object is retrieved (via the GroundedAction.toString()
method, and then published to a ROS topic. The calling thread is then stalled for some delay (giving time
for the action to be executed on the ROS robot and the state updated) before the executeAction(burlap.oomdp.singleagent.GroundedAction) )}
method returns.
domain - the domain into which ROS burlap_state messages are parsedrosBridgeURI - the URI of the ros bridge server. Note that by default, ros bridge uses port 9090. An example URI is ws://localhost:9090rosStateTopic - the name of the ROS topic that publishes the burlap_msgs/burlap_state messages.rosActionTopic - the name of the ROS topic to which BURLAP actions are published (as strings)actionSleepMS - the amount of time that the executeAction(burlap.oomdp.singleagent.GroundedAction) method stalls after publishing an action.rosBridgeThrottleRate - the ROS Bridge server throttle rate: how frequently the server will send state messagesrosBridgeQueueLength - the ROS Bridge queue length: how many messages are queued on the server; queueing is a consequence of the throttle ratepublic AsynchronousRosEnvironment(burlap.oomdp.core.Domain domain,
String rosBridgeURI,
String rosStateTopic,
String rosActionTopic,
String rosStateTopicMessageType,
String rosActionTopicMessageType,
int actionSleepMS,
int rosBridgeThrottleRate,
int rosBridgeQueueLength)
State object using the object classes defined in a provided
BURLAP Domain.
When this environment has an action request (via executeAction(burlap.oomdp.singleagent.GroundedAction)),
it turns the request into a GroundedAction
object and a string rep of the object is retrieved (via the GroundedAction.toString()
method, and then published to a ROS topic. The calling thread is then stalled for some delay (giving time
for the action to be executed on the ROS robot and the state updated) before the executeAction(burlap.oomdp.singleagent.GroundedAction)
method returns.
domain - the domain into which ROS burlap_state messages are parsedrosBridgeURI - the URI of the ros bridge server. Note that by default, ros bridge uses port 9090. An example URI is ws://localhost:9090rosStateTopic - the name of the ROS topic that publishes the burlap_msgs/burlap_state messages.rosActionTopic - the name of the ROS topic to which BURLAP actions are published (as strings)rosStateTopicMessageType - the ROS message type used for states.rosActionTopicMessageType - the ROS message type used for actions.actionSleepMS - the amount of time that the executeAction(burlap.oomdp.singleagent.GroundedAction) method stalls after publishing an action.rosBridgeThrottleRate - the ROS Bridge server throttle rate: how frequently the server will send state messagesrosBridgeQueueLength - the ROS Bridge queue length: how many messages are queued on the server; queueing is a consequence of the throttle ratepublic ros.RosBridge getRosBridge()
RosBridge object to which this environment is connected.RosBridge object to which this environment is connected.public void setRewardFunction(burlap.oomdp.singleagent.RewardFunction rf)
RewardFunction to use to provide reward signals from the getLastReward() method.rf - RewardFunction to use to provide reward signals.public void setTerminalFunction(burlap.oomdp.core.TerminalFunction tf)
TerminalFunction to use to provide terminal state checks from the isInTerminalState().tf - the BURLAP TerminalFunction to use to provide terminal state checkspublic burlap.oomdp.core.states.State getCurrentObservation()
getCurrentObservation in interface burlap.oomdp.singleagent.environment.Environmentpublic boolean isInTerminalState()
isInTerminalState in interface burlap.oomdp.singleagent.environment.Environmentpublic void resetEnvironment()
resetEnvironment in interface burlap.oomdp.singleagent.environment.Environmentpublic void setPrintStateAsReceived(boolean printStateAsReceived)
onStateReceive(burlap.oomdp.core.states.State) will print the
state information to the terminal.printStateAsReceived - if true, then the default implementation of onStateReceive(burlap.oomdp.core.states.State) will print states to the screen;
if false, the state receiving is silent by default.public void setAddHeader(boolean addHeader)
getHeader() (which you can override). By default, the returned
header is unpopulated, which will cause RosBridge to auto populate the sequence and time stamp (but leave
the frame as an empty string).addHeader - if true, then a header will be added to the action message; if false, no header is added.public void blockUntilStateReceived()
public void receive(com.fasterxml.jackson.databind.JsonNode data,
String stringRep)
receive in interface ros.RosListenDelegate@Deprecated public void receive(Map<String,Object> data, String stringRep)
protected burlap.oomdp.core.states.State onStateReceive(burlap.oomdp.core.states.State s)
printStateAsReceived data member is set to true, then it will print
to the terminal the string representation of the state. Override this method to provide
special handling of used state (e.g., adding objects to the state that ROS does not perceive).s - the parsed state from the ROS message received.public burlap.oomdp.singleagent.environment.EnvironmentOutcome executeAction(burlap.oomdp.singleagent.GroundedAction ga)
executeAction in interface burlap.oomdp.singleagent.environment.Environmentpublic double getLastReward()
getLastReward in interface burlap.oomdp.singleagent.environment.Environmentpublic Map<String,Object> getHeader()
protected burlap.oomdp.core.states.State JSONToState(com.fasterxml.jackson.databind.JsonNode objects)
JsonNode that represents the BURLAP state and turns it into
a BURLAP State object. The JSonNode at the top level is a list of objects.
Each object has a map with the fields "name", "object_class", and "values". The former are just string definitions.
The latter is another list of values. Each value has the fields "attribute" and "value". Attribute specified the name
of the BURLAP attribute; "value" specifies the string value of the value. If the attribute is a MULTITARGETRELATIONAL type,
then it is assumed the different object names to which it is pointing are separated by a single ',' without spaces.objects - a JsonNode specifying the BURLAP state objects.State representation of the input JSON state.@Deprecated protected burlap.oomdp.core.states.State JSONPreparedToState(List<Map<String,Object>> objects)
objects - the list of OO-MDP object instancesState object.Copyright © 2016. All rights reserved.