Trajectory · repose-trajectory
Trajectory payload
CuTrajectoryPayload<N, MAX_POINTS = 64> stores up to MAX_POINTS timed knots and how to interpolate between them. It is a Copper payload, so trajectories are logged and replayable.
Knots
Each CuTrajectoryPoint<N> has time_from_start, positions, velocities and accelerations (used only by quintic interpolation). push, clear, points(), len, is_empty() and duration() do what they say. Pushing beyond capacity is an error.
Capacity is a type parameter. Timing resamples a path at sample_period, so a 10 s move at 20 ms needs 500 knots: the examples use 1024. Producer, timing task and follower must agree on it, which the compiler checks through the message types.
Interpolation
Linear | Positions and velocities interpolated linearly. Velocity jumps at knots. |
Cubic | Cubic Hermite through positions and velocities. Continuous velocity. What parameterize produces. |
Quintic | Quintic Hermite through positions, velocities and accelerations. Continuous acceleration, finite jerk everywhere. What S-curve Cartesian timing produces. |
Sampling
let mut q = [CuJointPosition::default(); 6];
let mut qd = [CuJointVelocity::default(); 6];
traj.sample(Time::new::<second>(1.25), &mut q, &mut qd)?; // uses traj.interpolation
traj.sample_with(CuTrajectoryInterpolation::Linear, t, &mut q, &mut qd)?;Before the first knot the first point is held, after the last the final point is held. Sampling writes into your buffers and never allocates.
Exact limits and time stretching
For the quintic reconstruction the velocity, acceleration and jerk peaks are known in closed form. traj.quintic_limit_ratio(&limits) returns the smallest uniform stretch that brings every peak within limits (largest of v/vmax, √(a/amax), ∛(j/jmax)). traj.stretch_time(k) scales all knot times by k and rescales velocities and accelerations, so the shape stays the same while peaks drop by k, k² and k³. cubic_limit_ratio does the same for cubic velocity and acceleration. Use these to slow down an existing trajectory safely, e.g. for a reduced-speed mode.