Design it, then prove it, before you build it
Top teams validate mechanisms in CAD and simulation before committing material and time. WPILib ships physics simulation classes that model your mechanism from real inputs: motor type/count, gear ratio, mass or moment of inertia, and travel.
The building block: DCMotor
Everything starts with a DCMotor model that encodes a real motor's stall torque, free speed, and stall current. For example, DCMotor.getNEO(1) or DCMotor.getKrakenX60(2) describes the motor(s) driving your mechanism, the same published curves you used to size the reduction (NEO Vortex: 6784 RPM free, 3.6 Nm stall; Kraken X60: 6000 RPM free trapezoidal, 7.09 Nm stall).
Mechanism models
ElevatorSim(motor, gearing, carriageMassKg, drumRadiusM, minHeightM, maxHeightM, simulateGravity, startingHeight, ...)— predicts whether your motor count and ratio can actually lift the carriage and how fast.SingleJointedArmSim(motor, gearing, jKgMetersSquared, armLengthM, minAngle, maxAngle, simulateGravity, startingAngle, ...)— checks if your arm can hold and move under gravity.FlywheelSim— predicts spin-up time and recovery for a shooter.
Getting the inputs from CAD
The key advanced move: pull moment of inertia (MOI) and center of mass straight from your Onshape/CAD model's mass properties instead of estimating. FRC teams combine free-body diagrams with CAD mass data to compute net torque and validate a mechanism, exactly the workflow case-study teams document. Garbage MOI in = misleading sim out, so model the real materials and parts.
A validation loop
- Size reduction by hand (torque math).
- Build the CAD; read MOI/CoM from mass properties.
- Plug into the matching WPILib sim class.
- Command a profile and watch: does it hold? Does it reach the setpoint in time? Does current stay under your limit?
- If it fails in sim, change the ratio/motor count/mass before cutting metal.
Why this wins
Simulation catches under-geared mechanisms, over-current designs, and impossible motion-profile targets in minutes, not after a week of fabrication. It also lets programmers develop and tune control code against a realistic model before the mechanism physically exists, so software is ready when hardware arrives.
Caveats
Sim models friction crudely; real kS will differ. Treat sim as a design filter and a software head-start, then confirm on hardware with SysId. The combination, CAD mass properties feeding a physics sim, then SysId on the real build, is how strong teams arrive at competition with mechanisms that already work.
Key takeaways
- WPILib sim classes (ElevatorSim, SingleJointedArmSim, FlywheelSim) validate motor count, gear ratio, and mass before fabrication.
- Pull moment of inertia and center of mass from CAD mass properties so the simulation reflects the real mechanism.
- Use sim as a design filter and a software head-start, then confirm friction-dependent terms (kS) on hardware with SysId.
Go deeper
Lesson quiz
RequiredAnswer all 3 questions correctly to complete this lesson.
01.In WPILib physics simulation, what does the DCMotor model encode as the building block for the mechanism sims?
02.Which inputs should be pulled straight from a robot's Onshape/CAD model's mass properties when building a physics simulation?
03.What is a key caveat about trusting WPILib physics-sim results, and how should it be addressed?
Answer every question to submit.
All 47 lessons in Mechanical, Build & Pneumatics
- Not started:Mini-Project 1: A Single-Jointed Arm From Math to Motion
- Not started:Mini-Project 2: A Two-Stage Cascade Elevator
- Not started:Mini-Project 3: A Velocity-Controlled Flywheel Shooter
- Not started:Mini-Project 4: A Pivoting Roller Intake
- Not started:Mini-Project 5: Integrating a COTS Swerve Module
- Not started:Pneumatics Won't Fire: A Full Diagnostic Tree
- Not started:The Robot Won't Drive Straight (and Other Drivetrain Sins)
- Not started:Gearboxes That Grenade and Fasteners That Vibrate Loose
- Not started:Closed-Loop Mechanisms That Oscillate, Sag, or Stall
- Not started:Field-Ready Reliability: Inspection, Spares, and the Pit Checklist
- Not started:Characterizing Any Mechanism with SysId
- Not started:Simulation-Driven Design with WPILib Physics Models
- Not started:Motion Profiling and Superstructure Coordination
- Not started:Designing for Weight, Stiffness, and Manufacturability
- Not started:Case Studies: Learning From Open Alliance Robots