Receiving teleop heartbeats

What is a teleop heartbeat?

During a teleop session, a continuous stream of empty protocol messages are sent from the operator to the device at a rate of 50Hz with UDP-like reliability settings.

This stream of messages represents a near-continuous signal that the operator is able to control the device.

Message structure

A teleop heartbeat message provides a timestamp, an ID for the session which is connected to the device, and the type of session. The session types are: TELEOP, OBSERVE, PORT_FORWARD, and UNKNOWN.

A typical heartbeat message looks like this:

Received heartbeat callback at 1683819820.846151  
Received heartbeat: peer_id: "2b278980-a1a4-4dba-9b0d-85329eb1a28c"  
session_type: "TELEOP"

When to use teleop heartbeat

For safety or UX reasons, your Agent SDK application running on your robot may want to know if the operator or device has lost the ability to receive heartbeats.

The session_type message allows you to make decisions based on the type of connection to your device. For example, your code may halt all activity if a disconnection is detected from session_type: "TELEOP", but may ignore disconnections of session_type: "OBSERVE".

Reacting to missing heartbeats is the fastest way to react to a lost network signal or lag spike in teleop on the robot-side application.

Example code

The following example is available on our GitHub page. This code sample monitors heartbeat messages coming from the Formant UI and reports the timestamp, session ID, and session type. If there is a lag between heartbeat messages longer than 0.1 sec, it calls a function to alert the user that the session has been disconnected.

👋

If you notice an issue with this page or need help, please reach out to us! Use the 'Did this page help you?' buttons below, or get in contact with our Customer Success team via the Intercom messenger in the bottom-right corner of this page, or at [email protected].