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 of the TCP, calculated from the desired or the measured joint values
- Joint angles and velocities, desired or measured
- Jacobian
- Joint torques
For the content of each message, see Feedback messages.
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 Control Unit.
The request requires a control token in the X-Robflow-Control-Token header. Request it first via
POST http://{robot ip}/api/v3.0/control/request, see
Control token.
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.
import requests
TIMEOUT = 10
def request_control(robot_IP: str) -> str:
"""
Takes control of the robot and returns the control token.
"""
response = requests.post(f'http://{robot_IP}/api/v3.0/control/request', timeout=TIMEOUT)
response.raise_for_status()
return response.json()["token"]
def set_streaming_feedback_properties(robot_IP: str, control_token: str, f_status: int, f_cartesian_measured: int, f_joint_measured: int, host_IP: str, host_port: int) -> bool:
"""
Configures which feedback messages the robot found at the given IP sends, and to which endpoint.
"""
# URL to the HTTP API
url = f'http://{robot_IP}/api/v3.0/set-streaming-feedback-properties'
# Fill the payload with the desired values. Fields that are left out are set to their default.
payload = {
"frequency_status": f_status,
"frequency_cartesian_measured": f_cartesian_measured,
"frequency_joint_measured": f_joint_measured,
"desired_remote_address": {
"address": host_IP
},
"desired_remote_port": host_port
}
headers = {
"Content-Type": "application/json",
"accept": "application/json",
"X-Robflow-Control-Token": control_token
}
SUCCESS_RESPONSE_CODE = 200
try:
response = requests.put(url, headers=headers, json=payload, timeout=TIMEOUT)
if response.status_code == SUCCESS_RESPONSE_CODE:
return True
else:
print(f"Request failed with status code {response.status_code}: {response.text}")
except Exception as e:
print("An error occurred:", str(e))
return False
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: open http://{robot ip}/logs. The Log type selector defaults to Robot Controller.
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.
There is also an example receiver using this and further existing tooling that may be used as reference for custom implementations.
Troubleshooting
This section lists previously encountered issues and possible solutions.
No streaming messages are received
- In the RobControl logs (
http://{robot ip}/logs, with Log type set to Robot Controller), verify that the feedback properties were set. There should be a message stating the desired feedback frequencies as well as the endpoint. - Ensure your firewall allows network communication on the required ports.
- Check the HTTP response of the request: without a valid control token, RobFlow answers with
409 Conflict.