githubEdit

chart-lineExponential Profiles

What is a Motion Profile?

A motion profile is a trajectory that defines how a mechanism should move from one position to another over time. Instead of commanding a mechanism to instantly jump to a target position (which would require infinite acceleration), motion profiles generate a smooth path that respects the physical limitations of your system.

Motion profiles output a series of intermediate setpoints (position and velocity) that your closed-loop controller tracks. This results in:

  • Predictable motion - You know exactly how long a movement will take

  • Smooth transitions - No jerky movements that stress mechanical components

  • Controlled acceleration - Prevents excessive current draw and brownouts

Trapezoidal vs Exponential Profiles

Trapezoidal Profiles

Trapezoidal profiles are the most common type. The name comes from the trapezoidal shape of the velocity-time graph.

Velocity
  ^
  |      ___________
  |     /           \
  |    /             \
  |   /               \
  |  /                 \
  |_/___________________\____> Time

Key characteristics:

  • Constant acceleration until max velocity is reached

  • Cruise at max velocity (if distance is long enough)

  • Constant deceleration to stop at target

  • Assumes unlimited torque during acceleration phases

When trapezoidal profiles struggle:

  • When a disturbance knocks the mechanism off the profile

  • When the motor cannot actually provide the commanded acceleration

  • When current limiting reduces available torque

Exponential Profiles

Exponential profiles model how DC motors actually behave. Instead of assuming constant acceleration, they account for the motor's torque-speed curve and the system's physical dynamics.

Key characteristics:

  • Acceleration naturally decreases as velocity increases (following motor physics)

  • Uses motor kV (velocity constant) and kA (acceleration constant) to model behavior

  • More accurately represents what the motor can actually achieve

  • Better disturbance rejection

circle-info

Exponential profiles are named for the exponential approach to maximum velocity, which mirrors the natural response of a first-order system like a DC motor.

The Physics Behind Exponential Profiles

DC motors produce torque proportional to current. However, as the motor spins faster, back-EMF reduces the effective voltage across the windings, which reduces current and therefore torque.

The relationship is:

V=kS+kVω+kAαV = kS + kV \cdot \omega + kA \cdot \alpha

Where:

  • V = Applied voltage

  • kS = Static friction voltage (voltage to overcome stiction)

  • kV = Velocity constant (volts per unit velocity)

  • kA = Acceleration constant (volts per unit acceleration)

  • ω = Angular velocity

  • α = Angular acceleration

Rearranging for acceleration:

α=VkSkVωkA\alpha = \frac{V - kS - kV \cdot \omega}{kA}

This shows that as velocity (ω) increases, the available acceleration (α) decreases. This is the fundamental insight that exponential profiles capture.

When to Use Each Profile Type

Situation
Recommended Profile
Why

Motor is always current-limited

Trapezoidal

Current limiting makes torque roughly constant regardless of speed

Motor is never current-limited

Exponential

Motor follows natural torque-speed curve

Sometimes current-limited

Hybrid (not yet in YAMS)

Heavy mechanism with adequate motor

Exponential

Gravity/friction dominate, exponential handles disturbances better

Lightweight mechanism

Either

Both work well when inertia is low

Mechanism with significant disturbances

Exponential

Better recovery when knocked off profile

Precise timing required

Trapezoidal

Deterministic duration calculation

circle-check

Exponential Profiles in YAMS

YAMS provides ExponentialProfilePIDController which combines an exponential motion profile with a PID controller. This replaces ProfiledPIDController (which uses trapezoidal profiles) or PIDController (which has no profiling).

Creating Constraints

YAMS provides factory methods to create exponential profile constraints for common mechanism types:

For Elevators

For Arms

For Flywheels

Custom Constraints

If the factory methods don't fit your use case, you can create constraints directly:

Using with SmartMotorControllerConfig

Tuning Exponential Profiles

Step 1: Characterize Your System

The exponential profile needs accurate kV and kA values. You have two options:

  1. Use the factory methods - They calculate kV and kA from motor specs and mechanism parameters

  2. Run SysId - Get experimental values from your actual mechanism

circle-exclamation

Step 2: Set Maximum Voltage

The maximum voltage determines how aggressively the profile will command the mechanism. Consider:

  • 12V - Full battery voltage, most aggressive

  • 10V - Leaves headroom for PID corrections

  • 8V - Conservative, good for testing

Step 3: Tune PID Gains

With exponential profiles, the feedforward does most of the work. The PID handles:

  • kP - Corrects position error. Start low (1-5) and increase until responsive

  • kI - Usually not needed with good feedforward. Use only if steady-state error persists

  • kD - Dampens oscillations. Add if mechanism oscillates around target

Step 4: Add Feedforward

Even with exponential profiles, you still need feedforward for:

  • Gravity compensation (arms, elevators) - The profile doesn't know about gravity

  • Friction compensation (kS) - Helps overcome stiction

circle-info

When using exponential profiles, the profile itself handles the velocity and acceleration feedforward. You typically only need kS (static friction) and kG (gravity) in your feedforward object.

Motor Controller Support

Motor Controller
Trapezoidal Profile
Exponential Profile
Notes

TalonFX (Kraken, Falcon)

On-device (Motion Magic)

On-device (Motion Magic Expo)

Best performance

TalonFXS

On-device (Motion Magic)

On-device (Motion Magic Expo)

Best performance

SparkMax/SparkFlex

On-device (MAXMotion)

RoboRIO

Exponential runs on RoboRIO

Nova

RoboRIO

RoboRIO

All profiles run on RoboRIO

circle-info

When exponential profiles run on the RoboRIO, there's slightly more latency compared to on-device execution. However, the profile calculation is still very fast and suitable for most mechanisms.

Common Issues and Solutions

Profile is too slow

  • Increase maximum voltage

  • Check that your mechanism parameters (mass, length, gearing) are accurate

  • Verify motor type matches actual hardware

Profile overshoots target

  • Decrease kP

  • Add kD for damping

  • Check that kV and kA values aren't underestimated

Mechanism can't keep up with profile

  • Your motor may be undersized for the mechanism

  • Reduce maximum voltage

  • Check for mechanical binding or excessive friction

Profile works in sim but not on real robot

  • Run SysId to get real kV and kA values

  • Account for friction with kS in feedforward

  • Check current limits aren't restricting torque

Example: Complete Elevator with Exponential Profile

Further Reading

Last updated