Trajectory Joint Interface example
At first, we create a UrDriver
object as usual:
We use a small helper function to make sure that the reverse interface is active and connected before proceeding.
Initialization
As trajectory execution will be triggered asynchronously, we define a callback function to handle a finished trajectory. A trajectory is considered finished when the robot is no longer executing it, independent of whether it successfully reached its final point. The trajectory result will reflect whether it was executed successfully, was canceled upon request or failed for some reason.
That callback can be registered at the UrDriver
object:
MoveJ Trajectory
Then, in order to execute a trajectory, we need to define a trajectory as a sequence of points and
parameters. The following example shows execution of a 2-point trajectory using URScript’s
movej
function:
In fact, the path is followed twice, once parametrized by a segment duration and once using maximum
velocity / acceleration settings. If a duration > 0 is given for a segment, the velocity and
acceleration settings will be ignored as in the underlying URScript functions. In the example
above, each of the g_my_robot->ur_driver_->writeTrajectoryPoint()
calls will be translated into a
movej
command in URScript.
While the trajectory is running, we need to tell the robot program that connection is still active
and we expect the trajectory to be running. This is being done by the
g_my_robot->ur_driver_->writeTrajectoryControlMessage(urcl::control::TrajectoryControlMessage::TRAJECTORY_NOOP);
call.
MoveL Trajectory
Similar to the movej
-based trajectory, execution can be done interpolating in joint space:
Spline based interpolation
Similar to the Spline Interpolation example, the trajectory point interface can be used to execute motions using the spline interpolation: