Class: Ros

Ros(options)

new Ros(options)

Manages connection to the server and all interactions with ROS.

Emits the following events:

  • 'error' - There was an error with ROS.
  • 'connection' - Connected to the WebSocket server.
  • 'close' - Disconnected to the WebSocket server.
  • <topicName> - A message came from rosbridge with the given topic name.
  • <serviceID> - A service response came from rosbridge with the given ID.
Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
url string <optional>

The WebSocket URL for rosbridge or the node server URL to connect using socket.io (if socket.io exists in the page). Can be specified later with connect.

groovyCompatibility boolean <optional>
true

Don't use interfaces that changed after the last groovy release or rosbridge_suite and related tools.

transportLibrary string <optional>
websocket

One of 'websocket', 'workersocket', 'socket.io' or RTCPeerConnection instance controlling how the connection is created in connect.

transportOptions Object <optional>
{}

The options to use when creating a connection. Currently only used if transportLibrary is RTCPeerConnection.

Source:

Methods

authenticate(mac, client, dest, rand, t, level, end)

Send an authorization request to the server.

Parameters:
Name Type Description
mac string

MAC (hash) string given by the trusted source.

client string

IP of the client.

dest string

IP of the destination.

rand string

Random string given by the trusted source.

t Object

Time of the authorization request.

level string

User level as a string given by the client.

end Object

End time of the client's session.

Source:

callOnConnection(message)

Send the message over the WebSocket, but queue the message up if not yet connected.

Parameters:
Name Type Description
message Object

The message to be sent.

Source:

close()

Disconnect from the WebSocket server.

Source:

connect(url)

Connect to the specified WebSocket.

Parameters:
Name Type Description
url string

WebSocket URL or RTCDataChannel label for rosbridge.

Source:

decodeTypeDefs(defs)

Decode a typedef array into a dictionary like rosmsg show foo/bar.

Parameters:
Name Type Description
defs Array.<Object>

Array of type_def dictionary.

Source:

getActionServers(callback, failedCallbackopt)

Retrieve a list of action servers in ROS as an array of string.

Parameters:
Name Type Attributes Description
callback function

Function with the following params:

Properties
Name Type Description
actionservers Array.<string>

Array of action server names.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getMessageDetails(message, callback, failedCallbackopt)

Retrieve the details of a ROS message.

Parameters:
Name Type Attributes Description
message string

The name of the message type.

callback function

Function with the following params:

Properties
Name Type Description
details string

An array of the message details.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getNodeDetails(node, callback, failedCallbackopt)

Retrieve a list of subscribed topics, publishing topics and services of a specific node.
These are the parameters if failedCallback is defined.

Parameters:
Name Type Attributes Description
node string

Name of the node.

callback function

Function with the following params:

Properties
Name Type Description
subscriptions Array.<string>

Array of subscribed topic names.

publications Array.<string>

Array of published topic names.

services Array.<string>

Array of service names hosted.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getNodeDetails(node, callback, failedCallbackopt)

Retrieve a list of subscribed topics, publishing topics and services of a specific node.
These are the parameters if failedCallback is undefined.

Parameters:
Name Type Attributes Description
node string

Name of the node.

callback function

Function with the following params:

Properties
Name Type Description
result Object

The result object with the following params:

Properties
Name Type Description
subscribing Array.<string>

Array of subscribed topic names.

publishing Array.<string>

Array of published topic names.

services Array.<string>

Array of service names hosted.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getNodes(callback, failedCallbackopt)

Retrieve a list of active node names in ROS.

Parameters:
Name Type Attributes Description
callback function

Function with the following params:

Properties
Name Type Description
nodes Array.<string>

Array of node names.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getParams(callback, failedCallbackopt)

Retrieve a list of parameter names from the ROS Parameter Server.

Parameters:
Name Type Attributes Description
callback function

Function with the following params:

Properties
Name Type Description
params Array.<string>

Array of param names.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getServiceRequestDetails(type, callback, failedCallbackopt)

Retrieve the details of a ROS service request.

Parameters:
Name Type Attributes Description
type string

The type of the service.

callback function

Function with the following params:

Properties
Name Type Description
result Object

The result object with the following params:

Properties
Name Type Description
typedefs Array.<string>

An array containing the details of the service request.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getServiceResponseDetails(type, callback, failedCallbackopt)

Retrieve the details of a ROS service response.

Parameters:
Name Type Attributes Description
type string

The type of the service.

callback function

Function with the following params:

Properties
Name Type Description
result Object

The result object with the following params:

Properties
Name Type Description
typedefs Array.<string>

An array containing the details of the service response.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getServices(callback, failedCallbackopt)

Retrieve a list of active service names in ROS.

Parameters:
Name Type Attributes Description
callback function

Function with the following params:

Properties
Name Type Description
services Array.<string>

Array of service names.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getServicesForType(serviceType, callback, failedCallbackopt)

Retrieve a list of services in ROS as an array as specific type.

Parameters:
Name Type Attributes Description
serviceType string

The service type to find.

callback function

Function with the following params:

Properties
Name Type Description
topics Array.<string>

Array of service names.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getServiceType(service, callback, failedCallbackopt)

Retrieve the type of a ROS service.

Parameters:
Name Type Attributes Description
service string

Name of the service.

callback function

Function with the following params:

Properties
Name Type Description
type string

The type of the service.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getTopics(callback, failedCallbackopt)

Retrieve a list of topics in ROS as an array.

Parameters:
Name Type Attributes Description
callback function

Function with the following params:

Properties
Name Type Description
result Object

The result object with the following params:

Properties
Name Type Description
topics Array.<string>

Array of topic names.

types Array.<string>

Array of message type names.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getTopicsAndRawTypes(callback, failedCallbackopt)

Retrieve a list of topics and their associated type definitions.

Parameters:
Name Type Attributes Description
callback function

Function with the following params:

Properties
Name Type Description
result Object

The result object with the following params:

Properties
Name Type Description
topics Array.<string>

Array of topic names.

types Array.<string>

Array of message type names.

typedefs_full_text Array.<string>

Array of full definitions of message types, similar to gendeps --cat.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getTopicsForType(topicType, callback, failedCallbackopt)

Retrieve a list of topics in ROS as an array of a specific type.

Parameters:
Name Type Attributes Description
topicType string

The topic type to find.

callback function

Function with the following params:

Properties
Name Type Description
topics Array.<string>

Array of topic names.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

getTopicType(topic, callback, failedCallbackopt)

Retrieve the type of a ROS topic.

Parameters:
Name Type Attributes Description
topic string

Name of the topic.

callback function

Function with the following params:

Properties
Name Type Description
type string

The type of the topic.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source:

sendEncodedMessage(messageEncoded)

Send an encoded message over the WebSocket.

Parameters:
Name Type Description
messageEncoded Object

The encoded message to be sent.

Source:

setStatusLevel(level, idopt)

Send a set_level request to the server.

Parameters:
Name Type Attributes Description
level string

Status level (none, error, warning, info).

id number <optional>

Operation ID to change status level on.

Source: