Beyond a single PID#
Advanced superstructures (an arm + elevator + wrist) must move fast without slamming, drawing brownout-level current, or colliding with themselves. The tools are motion profiles and coordinated state machines.
Motion profiles#
A TrapezoidProfile generates a smooth position/velocity/acceleration trajectory between setpoints, ramp up to a max velocity, cruise, ramp down, bounded by max-velocity and max-acceleration constraints. ProfiledPIDController wraps a PID controller around this so the mechanism tracks a physically realistic path instead of a step:
var constraints = new TrapezoidProfile.Constraints(maxVel, maxAccel);
var controller = new ProfiledPIDController(kP, 0, kD, constraints);
// each loop:
double pidV = controller.calculate(measured, goal);
double ffV = feedforward.calculate(
controller.getSetpoint().position, // for arm: angle
controller.getSetpoint().velocity);
motor.setVoltage(pidV + ffV);
The feedforward acts on the profile's instantaneous setpoint, so the mechanism is always commanded the physically correct voltage for where the profile says it should be.
Tuning constraints#
Start conservative, confirm clean tracking, then raise until the motion plot shows the actual curve diverging from the desired, that's your usable limit. Pushing past it just causes overshoot and current spikes.
Coordinating multiple DOF#
With several joints, naive simultaneous moves can self-collide (e.g., the arm sweeps through the elevator's path). Solutions used by strong teams:
- State machine: define safe named states (STOWED, INTAKE, SCORE_HIGH) and legal transitions; the superstructure only moves through allowed intermediate states.
- Setpoint sequencing: hold one DOF until another clears a danger zone (e.g., raise the elevator before rotating the arm forward), expressed cleanly with command-based
sequence/parallel/waitUntil. - Soft limits / keep-out zones: clamp each joint's range as a function of the others so a bad command can't drive into a collision.
Worked pattern#
A score sequence: (1) profile the elevator up to clear height, (2) waitUntil it clears, (3) in parallel profile the arm to the scoring angle and pre-spin a roller, (4) confirm all at-goal, (5) release the game piece. Each step uses profiled motion + feedforward, so the whole sequence is fast yet smooth.
The result#
Profiled, coordinated superstructures cycle quickly and repeatably without brownouts or self-destruction, the difference between a robot that scores fast every match and one that occasionally crashes its own arm.
the part worth keeping
Key takeaways
- Wrap PID in a TrapezoidProfile/ProfiledPIDController and feed feedforward the profile's setpoint so motion is fast yet physically realistic.
- Start motion constraints conservative and raise until the actual curve diverges from the desired on the plot.
- Coordinate multi-DOF superstructures with a state machine, setpoint sequencing, and keep-out limits to prevent self-collision and brownouts.
Mechanical, Build & PneumaticsAdvanced Techniques & Case Studieslesson 3 of 5
Keep going
Take the quiz+10 XP with an accountMore in Advanced Techniques & Case Studies
where this came from
Sources and corrections
This lesson is AI-assisted: drafted from primary sources, then reviewed and edited by hand. Errors still get through. When one is reported we fix it and write down what changed, in public, in the corrections log.
sources and further reading
- docs.wpilib.orgWPILib ProfiledPIDController
- docs.wpilib.orgWPILib Combining Motion Profiling and PID (Command-Based)
- docs.wpilib.orgWPILib TrapezoidProfile
clipped to this lesson
Articles that go further on this
The lesson gets you through the topic. These go wider on it, and they read in one sitting.
- 7 min readFRC Motion Profiling Explained: TrapezoidProfile and ProfiledPIDControllerHow WPILib's TrapezoidProfile and ProfiledPIDController smooth mechanism motion, how to pick velocity and acceleration constraints, and when a profile beats plain PID./blogread it
- 16 min readFRC Elevator and Arm Design: Staging, Rigging, Motors, Gravity, and SafetyA primary-source FRC guide to designing elevators and arms: cascade vs continuous rigging, staging, motor and gear-ratio sizing, gravity math, and safe holding./blogread it
answer sheet
Lesson quiz
All 3 right completes the lesson. Miss one and only that question comes back, anything you already answered correctly stays banked.
0 of 3 answered
01What two parameters define a WPILib TrapezoidProfile.Constraints object?
02What does a WPILib ProfiledPIDController combine into a single class?
03Why is motion profiling especially valuable when coordinating a multi-joint superstructure (e.g., an arm plus an elevator)?
Answer every question to submit.
All 47 lessons in Mechanical, Build & Pneumaticsopenclose
01 / prerequisites
02 / drivetrains
03 / power-transmission
04 / structure-materials-fasteners
05 / mechanisms-fabrication-assembly
06 / pneumatics-fundamentals
07 / pneumatic-components
08 / build-wire-program
09 / safety-rules-testing
10 / worked-examples-mini-projects
- Not read yet:Mini-Project 1: A Single-Jointed Arm From Math to Motion
- Not read yet:Mini-Project 2: A Two-Stage Cascade Elevator
- Not read yet:Mini-Project 3: A Velocity-Controlled Flywheel Shooter
- Not read yet:Mini-Project 4: A Pivoting Roller Intake
- Not read yet:Mini-Project 5: Integrating a COTS Swerve Module
11 / common-mistakes-troubleshooting
- Not read yet:Pneumatics Won't Fire: A Full Diagnostic Tree
- Not read yet:The Robot Won't Drive Straight (and Other Drivetrain Sins)
- Not read yet:Gearboxes That Grenade and Fasteners That Vibrate Loose
- Not read yet:Closed-Loop Mechanisms That Oscillate, Sag, or Stall
- Not read yet:Field-Ready Reliability: Inspection, Spares, and the Pit Checklist
12 / advanced-techniques-case-studies
- Not read yet:Characterizing Any Mechanism with SysId
- Not read yet:Simulation-Driven Design with WPILib Physics Models
- Not read yet:Motion Profiling and Superstructure Coordination
- Not read yet:Designing for Weight, Stiffness, and Manufacturability
- Not read yet:Case Studies: Learning From Open Alliance Robots