Skip to content
learnFRC.org
programminglesson35 min

Mechanism Physics Models with DCMotor

Modeling single-jointed arms, cascading elevators, and high-inertia flywheels using WPILib physics simulators and brushless DCMotor models.

What you will learn

  • Select and parameterize WPILib DCMotor models for modern brushless actuators.
  • Extract mechanism mass, center-of-mass distance, and moment of inertia from Onshape or CAD models.
  • Instantiate and configure ElevatorSim, SingleJointedArmSim, and FlywheelSim classes.
  • Apply physical travel stops and gravity vectors in simulated state equations.

Prerequisites:Guided Learning Course

When simulating a mechanism, software should not merely advance a position variable at a fixed rate. Real mechanisms accelerate according to Newton’s second law (F=maF = ma, τ=Jα\tau = J\alpha), slow down as back-EMF opposes applied voltage, and sag under gravitational torque.

WPILib provides dedicated numerical physics models that integrate the differential equations of standard FRC mechanisms every simulation cycle.


Before writing simulation models:

  1. Verify CAD mass properties for your mechanism. Open Onshape or your CAD package, select the moving assembly (carriage, arm tube, intake rollers), and inspect the calculated mass and moment of inertia.
  2. Determine your mechanical gear reduction (G = N_motor / N_mechanism) and effective spool drum radius or arm length.

WPILib’s DCMotor class encapsulates standard motor electrical characteristics:

  • Free speed (omega_free in rad/s)
  • Free current (I_free in A)
  • Stall torque (tau_stall in N·m)
  • Stall current (I_stall in A)
  • Motor internal resistance (R = V_nom / I_stall)
  • Motor torque constant (K_t = tau_stall / I_stall)
  • Motor back-EMF constant (K_v = omega_free / (V_nom - I_free * R))
import edu.wpi.first.math.system.plant.DCMotor;
// 1 Kraken X60 motor:
DCMotor armMotor = DCMotor.getKrakenX60(1);
// 2 NEO motors powering an elevator:
DCMotor elevatorGearbox = DCMotor.getNEO(2);
// Modern compact motors:
DCMotor wristMotor = DCMotor.getMinion(1);
DCMotor intakeMotor = DCMotor.getX44(1);

3. Modeling an Articulated Arm (SingleJointedArmSim)

Section titled “3. Modeling an Articulated Arm (SingleJointedArmSim)”

A single-jointed arm rotates around a pivot and experiences variable gravitational torque proportional to cos⁡(θ)\cos(\theta):

tau_net = tau_motor * G - m * g * r_com * cos(theta) - b * theta_dot

In Java, instantiate SingleJointedArmSim:

package frc.robot.sim;
import edu.wpi.first.math.system.plant.DCMotor;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.wpilibj.simulation.SingleJointedArmSim;
public class SimulatedArm {
// Physical plant parameters from CAD:
private static final DCMotor MOTOR_PLANT = DCMotor.getKrakenX60(1);
private static final double GEAR_RATIO = 65.0; // 65:1 overall reduction
private static final double MOMENT_OF_INERTIA = 0.42; // kg * m²
private static final double ARM_LENGTH_METERS = 0.72; // 0.72m pivot-to-tip length
private static final double MIN_ANGLE_RADS = Units.degreesToRadians(-20.0);
private static final double MAX_ANGLE_RADS = Units.degreesToRadians(105.0);
private static final boolean SIMULATE_GRAVITY = true;
private final SingleJointedArmSim m_armSim = new SingleJointedArmSim(
MOTOR_PLANT,
GEAR_RATIO,
MOMENT_OF_INERTIA,
ARM_LENGTH_METERS,
MIN_ANGLE_RADS,
MAX_ANGLE_RADS,
SIMULATE_GRAVITY,
Units.degreesToRadians(0.0) // Starting position
);
public SingleJointedArmSim getSim() {
return m_armSim;
}
}

4. Modeling a Cascading Elevator (ElevatorSim)

Section titled “4. Modeling a Cascading Elevator (ElevatorSim)”

A vertical elevator experiences constant downward gravitational force (Fg=mgF_g = mg) regardless of height:

package frc.robot.sim;
import edu.wpi.first.math.system.plant.DCMotor;
import edu.wpi.first.wpilibj.simulation.ElevatorSim;
public class SimulatedElevator {
private static final DCMotor MOTOR_PLANT = DCMotor.getKrakenX60(2); // Dual Kraken drive
private static final double GEAR_RATIO = 8.5; // 8.5:1 reduction
private static final double CARRIAGE_MASS_KG = 7.5; // 7.5 kg moving mass
private static final double DRUM_RADIUS_METERS = 0.022; // 44mm pitch diameter spool
private static final double MIN_HEIGHT_METERS = 0.0;
private static final double MAX_HEIGHT_METERS = 1.65; // 1.65m maximum extension
private static final boolean SIMULATE_GRAVITY = true;
private final ElevatorSim m_elevatorSim = new ElevatorSim(
MOTOR_PLANT,
GEAR_RATIO,
CARRIAGE_MASS_KG,
DRUM_RADIUS_METERS,
MIN_HEIGHT_METERS,
MAX_HEIGHT_METERS,
SIMULATE_GRAVITY,
0.0 // Starting height
);
public ElevatorSim getSim() {
return m_elevatorSim;
}
}

5. Modeling a High-Inertia Flywheel (FlywheelSim)

Section titled “5. Modeling a High-Inertia Flywheel (FlywheelSim)”

Flywheels have no travel stops or gravity, but high rotational kinetic energy (E_k = 0.5 * J * omega²):

package frc.robot.sim;
import edu.wpi.first.math.system.plant.DCMotor;
import edu.wpi.first.wpilibj.simulation.FlywheelSim;
public class SimulatedFlywheel {
private static final DCMotor MOTOR_PLANT = DCMotor.getKrakenX60(2);
private static final double GEAR_RATIO = 1.0; // 1:1 direct belt drive
private static final double MOMENT_OF_INERTIA = 0.0035; // kg * m² for dual aluminum wheels
private final FlywheelSim m_flywheelSim = new FlywheelSim(
MOTOR_PLANT,
GEAR_RATIO,
MOMENT_OF_INERTIA
);
public FlywheelSim getSim() {
return m_flywheelSim;
}
}

  1. Physical Convergence:
    • Apply 0.0 Volts to the simulated arm when initialized at 45 degrees.
    • The arm must drop downward due to simulated gravity until it hits the minimum hardstop at -20 degrees.
  2. Current Draw Consistency:
    • Check m_armSim.getCurrentDrawAmps(). Holding the arm horizontal against gravity should draw between 8 A and 15 A, matching physical benchmark measurements.
  3. Free Speed Limit:
    • Apply 12.0 Volts to the flywheel simulation.
    • The flywheel speed must asymptote to the motor’s theoretical free speed (≈ 6000 RPM for Kraken X60) without exceeding physical limits.

Now that your physics models accurately represent mechanism dynamics, proceed to Simulated Hardware & AdvantageScope to connect simulated physics to production robot subsystems.

Verified Sources & Standards

Evergreen Standard Verified: Sep 25, 2026