public class DefaultNode extends java.lang.Object implements ConnectedNode
Node
.Constructor and Description |
---|
DefaultNode(NodeConfiguration nodeConfiguration,
java.util.Collection<NodeListener> nodeListeners,
java.util.concurrent.ScheduledExecutorService scheduledExecutorService)
DefaultNode s should only be constructed using the
DefaultNodeFactory . |
Modifier and Type | Method and Description |
---|---|
void |
addListener(NodeListener listener)
Add a new
NodeListener to the Node . |
void |
executeCancellableLoop(CancellableLoop cancellableLoop)
|
org.ros.message.Time |
getCurrentTime()
In ROS, time can be wallclock (actual) or simulated, so it is important to
use
ConnectedNode.getCurrentTime() instead of using the standard
Java routines for determining the current time. |
org.apache.commons.logging.Log |
getLog() |
java.net.URI |
getMasterUri() |
org.ros.message.MessageSerializationFactory |
getMessageSerializationFactory() |
GraphName |
getName() |
ParameterTree |
getParameterTree()
Create a
ParameterTree to query and set parameters on the ROS
parameter server. |
NodeNameResolver |
getResolver() |
java.util.concurrent.ScheduledExecutorService |
getScheduledExecutorService() |
org.ros.message.MessageFactory |
getServiceRequestMessageFactory() |
org.ros.message.MessageFactory |
getServiceResponseMessageFactory() |
<T,S> ServiceServer<T,S> |
getServiceServer(GraphName serviceName) |
<T,S> ServiceServer<T,S> |
getServiceServer(java.lang.String serviceName) |
org.ros.message.MessageFactory |
getTopicMessageFactory() |
java.net.URI |
getUri() |
java.net.URI |
lookupServiceUri(GraphName serviceName) |
java.net.URI |
lookupServiceUri(java.lang.String serviceName) |
<T> Publisher<T> |
newPublisher(GraphName topicName,
java.lang.String messageType) |
<T> Publisher<T> |
newPublisher(java.lang.String topicName,
java.lang.String messageType) |
<T,S> ServiceClient<T,S> |
newServiceClient(GraphName serviceName,
java.lang.String serviceType)
Create a
ServiceClient . |
<T,S> ServiceClient<T,S> |
newServiceClient(java.lang.String serviceName,
java.lang.String serviceType) |
<T,S> ServiceServer<T,S> |
newServiceServer(GraphName serviceName,
java.lang.String serviceType,
ServiceResponseBuilder<T,S> responseBuilder)
Create a new
ServiceServer . |
<T,S> ServiceServer<T,S> |
newServiceServer(java.lang.String serviceName,
java.lang.String serviceType,
ServiceResponseBuilder<T,S> responseBuilder) |
<T> Subscriber<T> |
newSubscriber(GraphName topicName,
java.lang.String messageType) |
<T> Subscriber<T> |
newSubscriber(java.lang.String topicName,
java.lang.String messageType) |
GraphName |
resolveName(GraphName name)
Resolve the given name, using ROS conventions, into a full ROS namespace
name.
|
GraphName |
resolveName(java.lang.String name) |
void |
shutdown()
Shut the node down.
|
public DefaultNode(NodeConfiguration nodeConfiguration, java.util.Collection<NodeListener> nodeListeners, java.util.concurrent.ScheduledExecutorService scheduledExecutorService)
DefaultNode
s should only be constructed using the
DefaultNodeFactory
.nodeConfiguration
- the NodeConfiguration
for this Node
nodeListeners
- a Collection
of NodeListener
s that will be added
to this Node
before it startspublic <T> Publisher<T> newPublisher(GraphName topicName, java.lang.String messageType)
newPublisher
in interface ConnectedNode
T
- the message type to create the publisher fortopicName
- the topic name, will be pushed down under this namespace unless
'/' is prepended.messageType
- the message data type (e.g. "std_msgs/String")Publisher
for the specified topicpublic <T> Publisher<T> newPublisher(java.lang.String topicName, java.lang.String messageType)
newPublisher
in interface ConnectedNode
ConnectedNode.newPublisher(GraphName, String)
public <T> Subscriber<T> newSubscriber(GraphName topicName, java.lang.String messageType)
newSubscriber
in interface ConnectedNode
T
- the message type to create the Subscriber
fortopicName
- the topic name to be subscribed to, this will be auto resolvedmessageType
- the message data type (e.g. "std_msgs/String")Subscriber
for the specified topicpublic <T> Subscriber<T> newSubscriber(java.lang.String topicName, java.lang.String messageType)
newSubscriber
in interface ConnectedNode
ConnectedNode.newSubscriber(GraphName, String)
public <T,S> ServiceServer<T,S> newServiceServer(GraphName serviceName, java.lang.String serviceType, ServiceResponseBuilder<T,S> responseBuilder)
ConnectedNode
ServiceServer
.newServiceServer
in interface ConnectedNode
serviceName
- the name of the serviceserviceType
- the type of the service (e.g. "rosjava_test_msgs/AddTwoInts")responseBuilder
- called for every request to build a responseServiceServer
public <T,S> ServiceServer<T,S> newServiceServer(java.lang.String serviceName, java.lang.String serviceType, ServiceResponseBuilder<T,S> responseBuilder)
newServiceServer
in interface ConnectedNode
ConnectedNode.newServiceServer(GraphName, String,
ServiceResponseBuilder)
public <T,S> ServiceServer<T,S> getServiceServer(GraphName serviceName)
getServiceServer
in interface ConnectedNode
serviceName
- the GraphName
of the ServiceServer
ServiceServer
with the given name or null
if it
does not existpublic <T,S> ServiceServer<T,S> getServiceServer(java.lang.String serviceName)
getServiceServer
in interface ConnectedNode
ConnectedNode.getServiceServer(GraphName)
public java.net.URI lookupServiceUri(GraphName serviceName)
lookupServiceUri
in interface ConnectedNode
serviceName
- the GraphName
of the service URI
to lookupURI
of the service or null
if it does not existpublic java.net.URI lookupServiceUri(java.lang.String serviceName)
lookupServiceUri
in interface ConnectedNode
ConnectedNode.lookupServiceUri(GraphName)
public <T,S> ServiceClient<T,S> newServiceClient(GraphName serviceName, java.lang.String serviceType) throws ServiceNotFoundException
ConnectedNode
ServiceClient
.newServiceClient
in interface ConnectedNode
serviceName
- the name of the serviceserviceType
- the type of the service (e.g. "rosjava_test_msgs/AddTwoInts")ServiceClient
ServiceNotFoundException
- thrown if no matching service could be foundpublic <T,S> ServiceClient<T,S> newServiceClient(java.lang.String serviceName, java.lang.String serviceType) throws ServiceNotFoundException
newServiceClient
in interface ConnectedNode
ServiceNotFoundException
ConnectedNode.newServiceClient(GraphName, String)
public org.ros.message.Time getCurrentTime()
ConnectedNode
ConnectedNode.getCurrentTime()
instead of using the standard
Java routines for determining the current time.getCurrentTime
in interface ConnectedNode
public GraphName getName()
public org.apache.commons.logging.Log getLog()
public GraphName resolveName(GraphName name)
Node
resolveName
in interface Node
name
- the name to resolvepublic GraphName resolveName(java.lang.String name)
resolveName
in interface Node
Node.resolveName(GraphName)
public void shutdown()
Node
public java.net.URI getMasterUri()
getMasterUri
in interface Node
URI
of MasterXmlRpcEndpoint
that this node is
attached to.public NodeNameResolver getResolver()
getResolver
in interface Node
NodeNameResolver
for this namespacepublic ParameterTree getParameterTree()
ConnectedNode
ParameterTree
to query and set parameters on the ROS
parameter server.getParameterTree
in interface ConnectedNode
ParameterTree
with NameResolver
in this namespace.public java.net.URI getUri()
public org.ros.message.MessageSerializationFactory getMessageSerializationFactory()
getMessageSerializationFactory
in interface Node
MessageSerializationFactory
used by this nodepublic org.ros.message.MessageFactory getTopicMessageFactory()
getTopicMessageFactory
in interface Node
MessageFactory
used by this nodepublic org.ros.message.MessageFactory getServiceRequestMessageFactory()
getServiceRequestMessageFactory
in interface Node
MessageFactory
used by this node for service requestspublic org.ros.message.MessageFactory getServiceResponseMessageFactory()
getServiceResponseMessageFactory
in interface Node
MessageFactory
used by this node for service responsespublic void addListener(NodeListener listener)
Node
NodeListener
to the Node
.addListener
in interface Node
listener
- the NodeListener
to addpublic java.util.concurrent.ScheduledExecutorService getScheduledExecutorService()
getScheduledExecutorService
in interface Node
ScheduledExecutorService
that this Node
usespublic void executeCancellableLoop(CancellableLoop cancellableLoop)
Node
CancellableLoop
using the Node
's
ScheduledExecutorService
. The CancellableLoop
will be
canceled when the Node
starts shutting down.
Any blocking calls executed in the provided CancellableLoop
can
potentially delay Node
shutdown and should be avoided.
executeCancellableLoop
in interface Node
cancellableLoop
- the CancellableLoop
to execute