Receiving streaming feedback messages

Generally, a streaming application requires the current state and pose of the robot to determine which actions or motions should be commanded. We offer different feedback messages, which are sent via UDP:

  • Streaming status

  • Cartesian pose

  • Joint positions

The following sections define the required steps to receive the desired feedback messages on the host device.

Configure streaming feedback

To define the type and frequency of messages to be sent, we provide an HTTP API function that forwards the desired settings to the controller.

For details on the payload, refer to API - Set Streaming Feedback Properties.

The JSON formatted payload needs to be sent to the following address: http://{robot ip}/api/v3.0/set-streaming-feedback-properties where robot_IP depends on the connection mode and configuration chosen when connecting the Streaming PC to the CU.

For an example using the RobFlow SDK, please refer to the feedback receiver example.

Python Example: Set streaming feedback properties

The following code shows the required API call to define the desired frequency and endpoint for streaming feedback messages.

 1def set_streaming_feedback_properties(robot_IP: str, f_status: int, f_cartesian_pose: int, f_joint_pose: int, host_IP: str, host_port: int) -> bool:
 2    """
 3        Enables the streaming mode on the robot found at the given IP and defines the settings as desired.
 4    """
 5
 6    # URL to the HTTP API
 7    url = f'http://{robot_IP}/api/v3.0/set-streaming-feedback-properties'
 8
 9    # Fill the payload of the "start-streaming" message with the desired values
10    payload = {
11        "frequency_status": f_status,
12        "frequency_cartesian_pose": f_cartesian_pose,
13        "frequency_joint_pose": f_joint_pose,
14        "desired_remote_address": {
15            "address": host_IP
16        },
17        "desired_remote_port": host_port
18    }
19
20    headers = {
21        "Content-Type": "application/json",
22        "accept": "application/json"
23    }
24
25    SUCCESS_RESPONSE_CODE = 200
26    TIMEOUT = 10
27    try:
28        response = requests.put(url, headers=headers, json=payload, timeout=TIMEOUT)
29
30        if response.status_code == SUCCESS_RESPONSE_CODE:
31            return True
32        else:
33            print(f"Request failed with status code {response.status_code}: {response.text}")
34    except Exception as e:
35        print("An error occurred:", str(e))
36
37    return False

Tip

For all API messages, you can also view the interactive documentation via RobFlow by opening RobFlow, clicking the menu at the top right corner and selecting “API Documentation”.

You may verify that the feedback properties were set successfully by accessing the controller logs via http://{robot ip}/logs/.

Receiving streaming feedback

Once the streaming feedback properties were set, the configured messages will be sent to the specified endpoint.

For information on the message format, refer to the feedback messages documentation.

The streaming SDK contains a helper to decode streaming messages in the correct format in streaming_feedback_messages.py.

The is also an example receiver using this and further existing tooling that may be used as reference for custom implementations.