flexivrobotics / flexiv_rdk

RDK (robotic development kit) for Flexiv robots. Supports C++ and Python. Compatible with Linux, macOS, and Windows.
Apache License 2.0
55 stars 17 forks source link

[HELP] streamCartesianMotion Input Validation #64

Closed yellownebula10 closed 1 week ago

yellownebula10 commented 2 weeks ago

Under the documentation for streamCartesianMotionForce, it says to stream smooth and continuous motion commands. Is there a standard we can use to validate that a stream is smooth enough? In other words, what is the maximum allowable delta between two subsequent stream values for the position and the quaternion?

kaibiao-flexiv commented 2 weeks ago

Hi @yellownebula10 ,

When using streamCartesianMotionForce, it is up to the user to create the trajectories and motion control profile for robot actions. You can refer to this picture below when streaming cartesian positions: image [Trapezoidal Velocity Profile from Mathworks]

For linear position on Rizon arms:

For angular rotation on Rizon arms:

Since Streaming is at 1kHz frequency, you could multiply the above numbers by 0.001 seconds to get the delta distance. During the "Phase 2 constant speed" of the motion control profile, with a typical peak velocity, the maximum allowable delta distance is 0.001[s] * 1[m/s] = 0.001[m] (This is not applicable during "Phase 1 Acceleration" and "phase 3 Deceleration").

Using RT streaming control can be quite complex. If your trajectory points are more spread out and less complicated (recommended maximum 100Hz frequency), you could save some time by utilizing an NRT discrete cartesian control [sendCartesianMotionForce] and letting the robot's internal motion generator does all the difficult work. https://github.com/flexivrobotics/flexiv_rdk/blob/06b38ad52fc93b0ffa0b4976d734e2221bf523a4/include/flexiv/Robot.hpp#L495

yellownebula10 commented 1 week ago

Thank you @kaibiao-flexiv . If we were to record the robot's position while in joint floating mode and wanted to stream it back, given that the trajectory is not complicated, would it be better to use NRT streaming at <100Hz or RT streaming at 1kHz? We are already automatically recording all the robot states at 1kHz, so it would just be a matter using every point or not.

kaibiao-flexiv commented 1 week ago

Hi @yellownebula10 ,

If the position data was recorded at 1kHz, it should be better to RT stream them back to the robot at 1kHz in order to replay the action. If PC's RT streaming performance is not perfect at 1kHz rate, then you can downsample the data to 10% (by averaging them per 10 sample data) and apply NRT sendCartesianMotionForce at 100Hz.

yellownebula10 commented 1 week ago

Got it, thanks @kaibiao-flexiv