Trajectory streaming
This guide will cover the necessary steps to stream a trajectory of poses (in joint or Cartesian space) or joint torques to the Robot. For specifics of the different modes, please also refer to Streaming API.
Gather Robot state as initial condition
Prior to starting streaming, you'll need to get the current Robot pose to set as an initial condition for the trajectory to be streamed. Please refer to the section Receiving streaming feedback messages for detailed instructions. We recommend also enabling the streaming status, so you can see when the controller is ready.
Request control
Before start-streaming, the Streaming PC must hold Robot control: call
POST /api/v3.0/control/request, keep the returned token, and send it as
X-Robflow-Control-Token on start-streaming. Requesting control puts every open RobFlow
browser session in View-only mode. An operator can take control back with Take control,
which makes your token invalid. The request is refused while the PLC has control. See
Request control.
Implement a trajectory generation algorithm
This piece of software will be the center piece of any streaming application. A program has to be implemented that receives or defines a target position to move to, and calculates a trajectory, i.e. a timestamped sequence of poses, to get to that position.
Within the examples section, there is:
- a joint streaming example, that calculates an offline joint trajectory satisfying the joint limitations
- a Cartesian streaming example, that tracks the live position of a mouse in a GUI window
The following sub-sections will provide general notes for the different streaming modes.
Streaming trajectory generation: Joint space
For both the Joint Position and the Joint Position and Velocity mode, we expect the
underlying trajectories to be feasible, i.e. the jerk, acceleration, velocity and position limits
are not exceeded for any joints. Please refer to the mode documentation for
position and
position/velocity modes for the
respective limits.
Based on these limits, a trajectory needs to be calculated that realizes a smooth transition from the current joint state (position, velocity, acceleration) to the desired state.
Within the examples, we provide a wrapper around the Ruckig library, which calculates smooth joint trajectories.
Streaming trajectory generation: Cartesian space
In the Cartesian streaming modes Cartesian Pose (absolute) and Cartesian Pose (relative),
there are no direct limits in terms of the velocity and acceleration — the controller tries to
track the streamed positions as quickly as possible, within the limits of every joint.
However, for safety reasons, if the position or orientation error exceeds the safety margin (see mode documentation absolute / relative), the streaming mode is left and the Robot stops. Therefore, a custom Cartesian trajectory generator should keep track of the current pose and ensure the Robot is able to follow the desired trajectory and stays within the error bounds.
Torque streaming
In the torque modes, your program does not generate a trajectory but acts as the controller of the Robot: it reads the measured state from the feedback messages and calculates a torque for each joint. See Joint torque for how the controller applies the torques and what it checks.
Start streaming
- Take control of the Robot via
POST http://{robot ip}/api/v3.0/control/request, see Control token. - Make sure the Robot's brakes are released and the Robot is idle: no Flow running, no motion, all joints within their limits.
- Send Start streaming with the desired mode, your streaming frequency (50 Hz to 500 Hz) and the IP of the Streaming PC.
- Wait until the streaming state in the feedback messages changes to
ready(0x10). If it staysinactive, the controller rejected the request; the reason is in the controller logs (http://{robot ip}/logs/). - Send the streaming messages to port
28000of the Control Unit at the configured frequency. With the first valid message, the state changes tostreaming(0x20).
Streaming stops if no new message arrives in time (50 ms in the motion modes, 100 ms in the torque modes), if the Robot cannot follow, or on a stop request. The Robot then decelerates and holds its position. See Streaming states and stop conditions for details.