Class: Node

Node()

- Class representing a Node in ROS
Source:

Methods

_runWithMessageType(Type, callback) → {undefined}

Invokes the callback with a raw message of the given type. After the callback completes the message will be destroyed.
Parameters:
Name Type Description
Type function Message type to create.
callback function Callback to invoke. First parameter will be the raw message, and the second is a function to retrieve the deserialized message.
Source:
Returns:
Type
undefined

_setParametersAtomically(parameters, declareParameterMode) → {SetParameterResult}

Internal method for updating parameters atomically. Prior to setting the parameters each SetParameterEventCallback registered using setOnParameterEventCallback() is called in succession with the parameters list. Any SetParameterEventCallback that retuns does not return a successful result will cause the entire operation to terminate with no changes to the parameters. When all SetParameterEventCallbacks return successful then the list of parameters is updated.
Parameters:
Name Type Default Description
parameters Array.<Paramerter> The parameters to update.
declareParameterMode boolean false When true parameters are being declared; otherwise they are being changed.
Source:
Returns:
- A single collective result.
Type
SetParameterResult

addOnSetParametersCallback(callback) → {undefined}

Add a callback to the front of the list of callbacks invoked for parameter declaration and setting. No checks are made for duplicate callbacks.
Parameters:
Name Type Description
callback SetParametersCallback The callback to add.
Source:
Returns:
Type
undefined

countPublishers(topic) → {number}

Return the number of publishers on a given topic.
Parameters:
Name Type Description
topic string The name of the topic.
Source:
Returns:
- Number of publishers on the given topic.
Type
number

countSubscribers(topic) → {number}

Return the number of subscribers on a given topic.
Parameters:
Name Type Description
topic string The name of the topic.
Source:
Returns:
- Number of subscribers on the given topic.
Type
number

createClient(typeClass, serviceName, options) → {Client}

Create a Client.
Parameters:
Name Type Description
typeClass function | string | object The ROS message class, OR a string representing the message class, e.g. 'std_msgs/msg/String', OR an object representing the message class, e.g. {package: 'std_msgs', type: 'msg', name: 'String'}
serviceName string The service name to request.
options object The options argument used to parameterize the client.
Properties
Name Type Description
enableTypedArray boolean The response will use TypedArray if necessary, default: true.
qos QoS ROS Middleware "quality of service" settings for the client, default: QoS.profileDefault.
Source:
Returns:
- An instance of Client.
Type
Client

createGuardCondition(callback) → {GuardCondition}

Create a guard condition.
Parameters:
Name Type Description
callback function The callback to be called when the guard condition is triggered.
Source:
Returns:
- An instance of GuardCondition.
Type
GuardCondition

createPublisher(typeClass, topic, options) → {Publisher}

Create a Publisher.
Parameters:
Name Type Description
typeClass function | string | object The ROS message class, OR a string representing the message class, e.g. 'std_msgs/msg/String', OR an object representing the message class, e.g. {package: 'std_msgs', type: 'msg', name: 'String'}
topic string The name of the topic.
options object The options argument used to parameterize the publisher.
Properties
Name Type Description
enableTypedArray boolean The topic will use TypedArray if necessary, default: true.
qos QoS ROS Middleware "quality of service" settings for the publisher, default: QoS.profileDefault.
Source:
Returns:
- An instance of Publisher.
Type
Publisher

(async) createRate(hz) → {Promise.<Rate>}

Create a Rate.
Parameters:
Name Type Default Description
hz number 1 The frequency of the rate timer; default is 1 hz.
Source:
Returns:
- Promise resolving to new instance of Rate.
Type
Promise.<Rate>

createService(typeClass, serviceName, options, callback) → {Service}

Create a Service.
Parameters:
Name Type Description
typeClass function | string | object The ROS message class, OR a string representing the message class, e.g. 'std_msgs/msg/String', OR an object representing the message class, e.g. {package: 'std_msgs', type: 'msg', name: 'String'}
serviceName string The service name to offer.
options object The options argument used to parameterize the service.
Properties
Name Type Description
enableTypedArray boolean The request will use TypedArray if necessary, default: true.
qos QoS ROS Middleware "quality of service" settings for the service, default: QoS.profileDefault.
callback RequestCallback The callback to be called when receiving request.
Source:
See:
Returns:
- An instance of Service.
Type
Service

createSubscription(typeClass, topic, options, callback) → {Subscription}

Create a Subscription.
Parameters:
Name Type Description
typeClass function | string | object The ROS message class, OR a string representing the message class, e.g. 'std_msgs/msg/String', OR an object representing the message class, e.g. {package: 'std_msgs', type: 'msg', name: 'String'}
topic string The name of the topic.
options object The options argument used to parameterize the subscription.
Properties
Name Type Description
enableTypedArray boolean The topic will use TypedArray if necessary, default: true.
qos QoS ROS Middleware "quality of service" settings for the subscription, default: QoS.profileDefault.
isRaw boolean The topic is serialized when true, default: false.
callback SubscriptionCallback The callback to be call when receiving the topic subscribed.
Source:
See:
Returns:
- An instance of Subscription.
Type
Subscription

createTimer(period, callback, clockopt) → {Timer}

Create a Timer.
Parameters:
Name Type Attributes Default Description
period number The number representing period in millisecond.
callback function The callback to be called when timeout.
clock Clock <optional>
null The clock which the timer gets time from.
Source:
Returns:
- An instance of Timer.
Type
Timer

declareParameter(parameter, descriptoropt, ignoreOverideopt) → {Parameter}

Declare a parameter. Internally, register a parameter and it's descriptor. If a parameter-override exists, it's value will replace that of the parameter unless ignoreOverride is true. If the descriptor is undefined, then a ParameterDescriptor will be inferred from the parameter's state. If a parameter by the same name has already been declared then an Error is thrown. A parameter must be undeclared before attempting to redeclare it.
Parameters:
Name Type Attributes Default Description
parameter Parameter Parameter to declare.
descriptor ParameterDescriptor <optional>
Optional descriptor for parameter.
ignoreOveride boolean <optional>
false When true disregard any parameter-override that may be present.
Source:
Returns:
- The newly declared parameter.
Type
Parameter

declareParameters(parameters, descriptorsopt, ignoreOverrides) → {Array.<Parameter>}

Declare a list of parameters. Internally register parameters with their corresponding descriptor one by one in the order they are provided. This is an atomic operation. If an error occurs the process halts and no further parameters are declared. Parameters that have already been processed are undeclared. While descriptors is an optional parameter, when provided there must be a descriptor for each parameter; otherwise an Error is thrown. If descriptors is not provided then a descriptor will be inferred from each parameter's state. When a parameter-override is available, the parameter's value will be replaced with that of the parameter-override unless ignoreOverrides is true. If a parameter by the same name has already been declared then an Error is thrown. A parameter must be undeclared before attempting to redeclare it. Prior to declaring the parameters each SetParameterEventCallback registered using setOnParameterEventCallback() is called in succession with the parameters list. Any SetParameterEventCallback that retuns does not return a successful result will cause the entire operation to terminate with no changes to the parameters. When all SetParameterEventCallbacks return successful then the list of parameters is updated.
Parameters:
Name Type Attributes Default Description
parameters Array.<Parameter> The parameters to declare.
descriptors Array.<ParameterDescriptor> <optional>
Optional descriptors, a 1-1 correspondence with parameters.
ignoreOverrides boolean false When true, parameter-overrides are not considered, i.e.,ignored.
Source:
Returns:
- The declared parameters.
Type
Array.<Parameter>

destroy() → {undefined}

Destroy all resource allocated by this node, including Timers/Publishers/Subscriptions /Clients/Services
Source:
Returns:
Type
undefined

destroyClient(client) → {undefined}

Destroy a Client.
Parameters:
Name Type Description
client Client The Client to be destroyed.
Source:
Returns:
Type
undefined

destroyGuardCondition(guard) → {undefined}

Destroy a guard condition.
Parameters:
Name Type Description
guard GuardCondition The guard condition to be destroyed.
Source:
Returns:
Type
undefined

destroyPublisher(publisher) → {undefined}

Destroy a Publisher.
Parameters:
Name Type Description
publisher Publisher The Publisher to be destroyed.
Source:
Returns:
Type
undefined

destroyService(service) → {undefined}

Destroy a Service.
Parameters:
Name Type Description
service Service The Service to be destroyed.
Source:
Returns:
Type
undefined

destroySubscription(subscription) → {undefined}

Destroy a Subscription.
Parameters:
Name Type Description
subscription Subscription The Subscription to be destroyed.
Source:
Returns:
Type
undefined

destroyTimer(timer) → {undefined}

Destroy a Timer.
Parameters:
Name Type Description
timer Timer The Timer to be destroyed.
Source:
Returns:
Type
undefined

getClock() → {Clock}

Get the clock used by the node.
Source:
Returns:
- The nodes clock.
Type
Clock

getLogger() → {Logger}

Get the nodes logger.
Source:
Returns:
- The logger for the node.
Type
Logger

getNodeNames() → {array}

Get the list of nodes discovered by the provided node.
Source:
Returns:
- An array of the names.
Type
array

getNodeNamesAndNamespaces() → {array}

Get the list of nodes and their namespaces discovered by the provided node.
Source:
Returns:
- An array of the names and namespaces.
Type
array

getParameter(name) → {Parameter}

Get a declared parameter by name. If unable to locate a declared parameter then a parameter with type == PARAMETER_NOT_SET is returned.
Parameters:
Name Type Description
name string The name of the parameter.
Source:
Returns:
- The parameter.
Type
Parameter

getParameterDescriptor(name) → {ParameterDescriptor}

Get a declared parameter descriptor by name. If unable to locate a declared parameter descriptor then a descriptor with type == PARAMETER_NOT_SET is returned.
Parameters:
Name Type Description
name string The name of the parameter descriptor to find.
Source:
Returns:
- The parameter descriptor.
Type
ParameterDescriptor

getParameterDescriptors(namesopt) → {Array.<ParameterDescriptor>}

Find a list of declared ParameterDescriptors. If no names are provided return all declared descriptors. If unable to locate a declared descriptor then a descriptor with type == PARAMETER_NOT_SET is returned in it's place.
Parameters:
Name Type Attributes Description
names Array.<string> <optional>
The names of the declared parameter descriptors to find or null indicating to return all declared descriptors.
Source:
Returns:
- The parameter descriptors.
Type
Array.<ParameterDescriptor>

getParameterNames() → {Array.<string>}

Get the names of all declared parameters.
Source:
Returns:
- The declared parameter names or empty array if no parameters have been declared.
Type
Array.<string>

getParameterOverrides() → {array}

Get the list of parameter-overrides found on the commandline and in the NodeOptions.parameter_overrides property.
Source:
Returns:
- An array of Parameters
Type
array

getParameters(namesopt) → {Array.<Parameter>}

Get a list of parameters. Find and return the declared parameters. If no names are provided return all declared parameters. If unable to locate a declared parameter then a parameter with type == PARAMETER_NOT_SET is returned in it's place.
Parameters:
Name Type Attributes Description
names Array.<string> <optional>
The names of the declared parameters to find or null indicating to return all declared parameters.
Source:
Returns:
- The parameters.
Type
Array.<Parameter>

getPublisherNamesAndTypesByNode(nodeName, namespace, noDemangle) → {array}

Get the list of published topics discovered by the provided node for the remote node name.
Parameters:
Name Type Default Description
nodeName string The name of the node.
namespace string The name of the namespace.
noDemangle boolean false If true topic names and types returned will not be demangled, default: false.
Source:
Returns:
- An array of the names and types.
Type
array

getServiceNamesAndTypes() → {array}

Get the list of services discovered by the provided node.
Source:
Returns:
- An array of the names and types.
Type
array

getServiceNamesAndTypesByNode(nodeName, namespace) → {array}

Get the list of service topics discovered by the provided node for the remote node name.
Parameters:
Name Type Description
nodeName string The name of the node.
namespace string The name of the namespace.
Source:
Returns:
- An array of the names and types.
Type
array

getSubscriptionNamesAndTypesByNode(nodeName, namespace, noDemangle) → {array}

Get the list of published topics discovered by the provided node for the remote node name.
Parameters:
Name Type Default Description
nodeName string The name of the node.
namespace string The name of the namespace.
noDemangle boolean false If true topic names and types returned will not be demangled, default: false.
Source:
Returns:
- An array of the names and types.
Type
array

getTopicNamesAndTypes(noDemangle) → {array}

Get the list of topics discovered by the provided node.
Parameters:
Name Type Default Description
noDemangle boolean false If true topic names and types returned will not be demangled, default: false.
Source:
Returns:
- An array of the names and types.
Type
array

hasParameter(name) → {boolean}

Determine if a parameter has been declared.
Parameters:
Name Type Description
name string name of parameter
Source:
Returns:
- Return true if parameter is declared; false otherwise.
Type
boolean

hasParameterDescriptor(name) → {boolean}

Determine if a parameter descriptor exists.
Parameters:
Name Type Description
name string The name of a descriptor to for.
Source:
Returns:
- True if a descriptor has been declared; otherwise false.
Type
boolean

now() → {Time}

Get the current time using the node's clock.
Source:
Returns:
- The current time.
Type
Time

removeOnSetParametersCallback(callback) → {undefined}

Remove a callback from the list of SetParametersCallbacks. If the callback is not found the process is a nop.
Parameters:
Name Type Description
callback SetParametersCallback The callback to be removed
Source:
Returns:
Type
undefined

setParameter(parameter) → {rclnodejs.rcl_interfaces.msg.SetParameterResult}

Replace a declared parameter. The parameter being replaced must be a declared parameter who's descriptor is not readOnly; otherwise an Error is thrown.
Parameters:
Name Type Description
parameter Parameter The new parameter.
Source:
Returns:
- The result of the operation.
Type
rclnodejs.rcl_interfaces.msg.SetParameterResult

setParameters(parameters) → {Array.<rclnodejs.rcl_interfaces.msg.SetParameterResult>}

Replace a list of declared parameters. Declared parameters are replaced in the order they are provided and a ParameterEvent is published for each individual parameter change. Prior to setting the parameters each SetParameterEventCallback registered using setOnParameterEventCallback() is called in succession with the parameters list. Any SetParameterEventCallback that retuns does not return a successful result will cause the entire operation to terminate with no changes to the parameters. When all SetParameterEventCallbacks return successful then the list of parameters is updated. If an error occurs, the process is stopped and returned. Parameters set before an error remain unchanged.
Parameters:
Name Type Description
parameters Array.<Parameter> The parameters to set.
Source:
Returns:
- A list of SetParameterResult, one for each parameter that was set.
Type
Array.<rclnodejs.rcl_interfaces.msg.SetParameterResult>

setParametersAtomically(parameters) → {rclnodejs.rcl_interfaces.msg.SetParameterResult}

Repalce a list of declared parameters atomically. Declared parameters are replaced in the order they are provided. A single ParameterEvent is published collectively for all changed parameters. Prior to setting the parameters each SetParameterEventCallback registered using setOnParameterEventCallback() is called in succession with the parameters list. Any SetParameterEventCallback that retuns does not return a successful result will cause the entire operation to terminate with no changes to the parameters. When all SetParameterEventCallbacks return successful then the list of parameters is updated.d If an error occurs, the process stops immediately. All parameters updated to the point of the error are reverted to their previous state.
Parameters:
Name Type Description
parameters Array.<Parameter> The parameters to set.
Source:
Returns:
- describes the result of setting 1 or more parameters.
Type
rclnodejs.rcl_interfaces.msg.SetParameterResult

undeclareParameter(name) → {undefined}

Undeclare a parameter. Readonly parameters can not be undeclared or updated.
Parameters:
Name Type Description
name string Name of parameter to undeclare.
Source:
Returns:
-
Type
undefined