07 / Motion Profiling
Implementing a Profiled Mechanism
Use profile state plus PID output to control a lift or arm.
07 / Motion Profiling
Use profile state plus PID output to control a lift or arm.
You will
This lesson is about planning motion before controlling it. A profile turns a sudden target jump into a time-based path of positions, velocities, and accelerations that a controller can follow more gently.
The centerstage arm subsystem resets its profile when the target differs from the previous target. Recreating the profile every loop would keep starting over and the mechanism would never follow the plan.
The profile decides where the mechanism should be now. PID compares that target position to the measured position and creates the corrective output.
Draw the motion first, then code it. Students should label acceleration, cruise, deceleration, total time, and target position before implementing a profiled mechanism. The code should regenerate the profile only when the target changes, then follow the current profile state each loop.
For this specific lesson, students should first restate the goal in robot terms, then identify the value or behavior they expect to observe, then run the smallest test that proves the idea. The lesson should feel like a guided lab: predict, run, observe, explain, and only then extend.
ProfiledLift.java · Java
if (targetTicks != previousTargetTicks) {
profile = new AsymmetricMotionProfile(currentTicks, targetTicks, constraints);
timer.reset();
previousTargetTicks = targetTicks;
}
ProfileState state = profile.calculate(timer.seconds());
double error = state.x - lift.getCurrentPosition();
double output = kP * error + kV * state.v + kA * state.a;
lift.setPower(Math.max(-1.0, Math.min(1.0, output)));Profiled systems fail when the requested motion is physically unrealistic or when the profile is restarted every loop. Saturated output, growing error, overshoot, and late arrival all point to different fixes. The lesson should make students name the failure mode before touching constants.
Check your understanding
Why not recreate the motion profile every loop?
0 of 1 answered
References
Finished reading?
You'll move on to “Testing Profiles and Failure Modes” next.