Skip to main content

Telemetry Control Bridge

Telemetry Messages are pub/sub type data: a Telemetry Message has a source, but not a destination. On the other hand, a Control Message represents push data: a Control Message has a destination, rather than a source. The two messages types are not directly interchangeable. As suggested by the name, the Telemetry Control Bridge converts Telemetry Messages into Control Messages.

In other words, the Telemetry Control Bridge allows a user to forward Telemetry messages from a particular source to a particular Control endpoint.

As an example, a user may wish to see which Telemetry topics are currently being subscribed to, and make this information available as a ROS message. For this example, we want messages from the Rocos subscriptions diagnostic topic (/rocos/agent/subscription-manager/subscriptions) to be sent to a control destination, which will be a custom ROS topic named rocos_subscriptions.

The settings shown below outline how this could be achieved.

{
"enabled": true,
"id": "telemetry-control-bridge",
"settings": {
"logLevel": 4,
"sources": {
"/transforms/subscriptions_ros_with_meta": "/ros/rocos_subscriptions"
}
}
},
{
"enabled": true,
"id": "conversion",
"settings": {
"name": "transforms",
"logLevel": 4,
"messageParserTimeout": "250ms",
"topicTemplateTimeout": "250ms",
"schemas": {
"custom_schema": "{\"$id\": \"%[1]s\", \"$schema\": \"https://json-schema.org/draft-07/schema#\", \"type\": \"object\"}"
},
"rules": {
"subscriptions_metadata": {
"enabled": true,
"preset": "custom",
"prefix": "ros_subscriptions_",
"source": "/rocos/agent/subscription-manager/subscriptions",
"messageParser": "var result = [];\r\nvar item = {};\r\nitem.id = \"subscriptions_ros_with_meta\";\r\nvar meta = {\"ros.type\": \"std_msgs/String\"};\r\nvar output = {};\r\noutput.payload = {\"data\":$msg};\r\noutput.source = item.id;\r\noutput.meta = meta;\r\nresult.push(output);\r\nresult;",
"payloadSchemaName": "custom_schema"
}
}
}
},

There are two agent components defined here:

  1. telemetry-control-bridge
  2. conversion

Telemetry-Control-Bridge

This component takes a map of sources which are keyed with the subscription you would like to set up. The format is as follows:

"sources": {
"subscriptionSource": "controlOutputDestination"
}

You will notice in the above example that we have our subscription source set to: /transforms/subscriptions_ros_with_meta

This is because, in order to get our subscription messages successfully parsed as ROS string messages, we need to first reformat them into the correct data structure. They also need to contain the following metadata: "ros.type": "std_msgs/String" to allow the agent to build the correct ROS message. The conversions component is set up here to republish the subscriptions messages into this correct format.

Conversion

The conversion component allows a user to modify a message as desired using JavaScript notation. In this case the conversion component handles reformatting the Rocos subscription messages into the desired ROS string message format. The example settings above outline how this has been done. Further information can be found here for the conversion component.