Package org.ros.internal.node
Class DefaultNode
java.lang.Object
org.ros.internal.node.DefaultNode
- All Implemented Interfaces:
ConnectedNode,Node
The default implementation of a
Node.- Author:
- ethan.rublee@gmail.com (Ethan Rublee), kwc@willowgarage.com (Ken Conley), damonkohler@google.com (Damon Kohler)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultNode(NodeConfiguration nodeConfiguration, Collection<NodeListener> nodeListeners, ScheduledExecutorService scheduledExecutorService) DefaultNodes should only be constructed using theDefaultNodeFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(NodeListener listener) Add a newNodeListenerto theNode.voidexecuteCancellableLoop(CancellableLoop cancellableLoop) org.ros.message.TimeIn ROS, time can be wallclock (actual) or simulated, so it is important to useConnectedNode.getCurrentTime()instead of using the standard Java routines for determining the current time.org.apache.commons.logging.LoggetLog()org.ros.message.MessageSerializationFactorygetName()Create aParameterTreeto query and set parameters on the ROS parameter server.org.ros.message.MessageFactoryorg.ros.message.MessageFactory<T,S> ServiceServer<T, S> getServiceServer(String serviceName) <T,S> ServiceServer<T, S> getServiceServer(GraphName serviceName) org.ros.message.MessageFactorygetUri()lookupServiceUri(String serviceName) lookupServiceUri(GraphName serviceName) <T> Publisher<T>newPublisher(String topicName, String messageType) <T> Publisher<T>newPublisher(GraphName topicName, String messageType) <T,S> ServiceClient<T, S> newServiceClient(String serviceName, String serviceType) <T,S> ServiceClient<T, S> newServiceClient(GraphName serviceName, String serviceType) Create aServiceClient.<T,S> ServiceServer<T, S> newServiceServer(String serviceName, String serviceType, ServiceResponseBuilder<T, S> responseBuilder) <T,S> ServiceServer<T, S> newServiceServer(GraphName serviceName, String serviceType, ServiceResponseBuilder<T, S> responseBuilder) Create a newServiceServer.<T> Subscriber<T>newSubscriber(String topicName, String messageType) <T> Subscriber<T>newSubscriber(String topicName, String messageType, TransportHints transportHints) <T> Subscriber<T>newSubscriber(GraphName topicName, String messageType) <T> Subscriber<T>newSubscriber(GraphName topicName, String messageType, TransportHints transportHints) voidStops and Clears node listeners.resolveName(String name) resolveName(GraphName name) Resolve the given name, using ROS conventions, into a full ROS namespace name.voidshutdown()Shut the node down.
-
Constructor Details
-
DefaultNode
public DefaultNode(NodeConfiguration nodeConfiguration, Collection<NodeListener> nodeListeners, ScheduledExecutorService scheduledExecutorService) DefaultNodes should only be constructed using theDefaultNodeFactory.- Parameters:
nodeConfiguration- theNodeConfigurationfor thisNodenodeListeners- aCollectionofNodeListeners that will be added to thisNodebefore it starts
-
-
Method Details
-
newPublisher
- Specified by:
newPublisherin interfaceConnectedNode- Type Parameters:
T- the message type to create the publisher for- Parameters:
topicName- the topic name, will be pushed down under this namespace unless '/' is prepended.messageType- the message data type (e.g. "std_msgs/String")- Returns:
- a
Publisherfor the specified topic
-
newPublisher
- Specified by:
newPublisherin interfaceConnectedNode- See Also:
-
newSubscriber
- Specified by:
newSubscriberin interfaceConnectedNode- Type Parameters:
T- the message type to create theSubscriberfor- Parameters:
topicName- the topic name to be subscribed to, this will be auto resolvedmessageType- the message data type (e.g. "std_msgs/String")- Returns:
- a
Subscriberfor the specified topic
-
newSubscriber
public <T> Subscriber<T> newSubscriber(GraphName topicName, String messageType, TransportHints transportHints) - Specified by:
newSubscriberin interfaceConnectedNode- Type Parameters:
T- the message type to create theSubscriberfor- Parameters:
topicName- the topic name to be subscribed to, this will be auto resolvedmessageType- the message data type (e.g. "std_msgs/String")transportHints- the transport hints- Returns:
- a
Subscriberfor the specified topic
-
newSubscriber
- Specified by:
newSubscriberin interfaceConnectedNode- See Also:
-
newSubscriber
public <T> Subscriber<T> newSubscriber(String topicName, String messageType, TransportHints transportHints) - Specified by:
newSubscriberin interfaceConnectedNode- See Also:
-
newServiceServer
public <T,S> ServiceServer<T,S> newServiceServer(GraphName serviceName, String serviceType, ServiceResponseBuilder<T, S> responseBuilder) Description copied from interface:ConnectedNodeCreate a newServiceServer.- Specified by:
newServiceServerin interfaceConnectedNode- Parameters:
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 response- Returns:
- a
ServiceServer
-
newServiceServer
public <T,S> ServiceServer<T,S> newServiceServer(String serviceName, String serviceType, ServiceResponseBuilder<T, S> responseBuilder) - Specified by:
newServiceServerin interfaceConnectedNode- See Also:
-
getServiceServer
- Specified by:
getServiceServerin interfaceConnectedNode- Parameters:
serviceName- theGraphNameof theServiceServer- Returns:
- the
ServiceServerwith the given name ornullif it does not exist
-
getServiceServer
- Specified by:
getServiceServerin interfaceConnectedNode- See Also:
-
lookupServiceUri
- Specified by:
lookupServiceUriin interfaceConnectedNode- Parameters:
serviceName- theGraphNameof the serviceURIto lookup- Returns:
- the
URIof the service ornullif it does not exist
-
lookupServiceUri
- Specified by:
lookupServiceUriin interfaceConnectedNode- See Also:
-
newServiceClient
public <T,S> ServiceClient<T,S> newServiceClient(GraphName serviceName, String serviceType) throws ServiceNotFoundException Description copied from interface:ConnectedNodeCreate aServiceClient.- Specified by:
newServiceClientin interfaceConnectedNode- Parameters:
serviceName- the name of the serviceserviceType- the type of the service (e.g. "rosjava_test_msgs/AddTwoInts")- Returns:
- a
ServiceClient - Throws:
ServiceNotFoundException- thrown if no matching service could be found
-
newServiceClient
public <T,S> ServiceClient<T,S> newServiceClient(String serviceName, String serviceType) throws ServiceNotFoundException - Specified by:
newServiceClientin interfaceConnectedNode- Throws:
ServiceNotFoundException- See Also:
-
getCurrentTime
public org.ros.message.Time getCurrentTime()Description copied from interface:ConnectedNodeIn ROS, time can be wallclock (actual) or simulated, so it is important to useConnectedNode.getCurrentTime()instead of using the standard Java routines for determining the current time.- Specified by:
getCurrentTimein interfaceConnectedNode- Returns:
- the current time
-
getName
-
getLog
public org.apache.commons.logging.Log getLog() -
resolveName
Description copied from interface:NodeResolve the given name, using ROS conventions, into a full ROS namespace name. Will be relative to the current namespace unless the name is global.- Specified by:
resolveNamein interfaceNode- Parameters:
name- the name to resolve- Returns:
- fully resolved ros namespace name
-
resolveName
- Specified by:
resolveNamein interfaceNode- See Also:
-
shutdown
public void shutdown()Description copied from interface:NodeShut the node down. -
getMasterUri
- Specified by:
getMasterUriin interfaceNode- Returns:
URIofMasterXmlRpcEndpointthat this node is attached to.
-
getResolver
- Specified by:
getResolverin interfaceNode- Returns:
NodeNameResolverfor this namespace
-
getParameterTree
Description copied from interface:ConnectedNodeCreate aParameterTreeto query and set parameters on the ROS parameter server.- Specified by:
getParameterTreein interfaceConnectedNode- Returns:
ParameterTreewithNameResolverin this namespace.
-
getUri
-
getMessageSerializationFactory
public org.ros.message.MessageSerializationFactory getMessageSerializationFactory()- Specified by:
getMessageSerializationFactoryin interfaceNode- Returns:
- the
MessageSerializationFactoryused by this node
-
getTopicMessageFactory
public org.ros.message.MessageFactory getTopicMessageFactory()- Specified by:
getTopicMessageFactoryin interfaceNode- Returns:
- the
MessageFactoryused by this node
-
getServiceRequestMessageFactory
public org.ros.message.MessageFactory getServiceRequestMessageFactory()- Specified by:
getServiceRequestMessageFactoryin interfaceNode- Returns:
- the
MessageFactoryused by this node for service requests
-
getServiceResponseMessageFactory
public org.ros.message.MessageFactory getServiceResponseMessageFactory()- Specified by:
getServiceResponseMessageFactoryin interfaceNode- Returns:
- the
MessageFactoryused by this node for service responses
-
addListener
Description copied from interface:NodeAdd a newNodeListenerto theNode.- Specified by:
addListenerin interfaceNode- Parameters:
listener- theNodeListenerto add
-
removeListeners
public void removeListeners()Description copied from interface:NodeStops and Clears node listeners.- Specified by:
removeListenersin interfaceNode
-
getScheduledExecutorService
- Specified by:
getScheduledExecutorServicein interfaceNode- Returns:
- the
ScheduledExecutorServicethat thisNodeuses
-
executeCancellableLoop
Description copied from interface:NodeExecutes aCancellableLoopusing theNode'sScheduledExecutorService. TheCancellableLoopwill be canceled when theNodestarts shutting down.Any blocking calls executed in the provided
CancellableLoopcan potentially delayNodeshutdown and should be avoided.- Specified by:
executeCancellableLoopin interfaceNode- Parameters:
cancellableLoop- theCancellableLoopto execute
-