WestlakeLEARN
FTC / Java

First Tech Challenge

FTC / Java

01 · Java for FTC
  • OpMode Anatomy and Hello Robot
  • Variables, Math, and Decisions
  • Methods, Classes, and Robot Helpers
02 · FTC Hardware Essentials
  • Hardware Map and RobotHardware
  • Motors, Servos, and Sensors
  • IMU, Encoders, and Bulk Caching
03 · TeleOp and Mecanum
  • Robot-Centric Mecanum Drive
  • Field-Centric Driving
  • Driver Ergonomics and Safe TeleOp
04 · Subsystems and Commands
  • Subsystem Lifecycle
  • Enums and Finite State Machines
  • Command-Based OpModes
05 · From Timed Steps to Actions
  • Timed and Encoder Autonomous
  • Autonomous State Machines
  • Actions and Sequencing
06 · PID and Feedforward
  • PID Basics
  • Feedforward and PIDF
  • Dashboard Tuning Workflow
07 · Motion Profiling2/3
  • Motion Profile Concepts
  • Implementing a Profiled Mechanism
  • Testing Profiles and Failure Modes
08 · OpenCV and AprilTags
  • VisionPortal Camera Setup
  • OpenCV Color and Region Processors
  • AprilTags and Field Pose
09 · Setup and Tuning
  • Road Runner 1.0 Install and Drive Class
  • Feedforward Tuning
  • Localization and Validation
10 · Trajectories, Actions, and MeepMeep
  • Action Builder and Trajectories
  • MeepMeep Preview
  • Full Road Runner Autonomous
11 · Git, Debugging, and Competition Readiness
  • Git Workflow for FTC Teams
  • Telemetry-First Debugging
  • Competition Readiness Checklist
12 · Driver Control
  • Driver Control
13 · Autonomous Build
  • Simple Autonomous
14 · Debugging
  • Debugging with Telemetry

07 / Motion Profiling

Implementing a Profiled Mechanism

Use profile state plus PID output to control a lift or arm.

75 minAdvancedMotion Profiling

You will

  1. 01Generate a new profile when the target changes.
  2. 02Calculate target state from elapsed time.
  3. 03Combine profile targets with feedback control.

Why Implementing a Profiled Mechanism matters

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.

Starting point

Only regenerate when the target changes

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.

Profile plus PID is the usual pairing

The profile decides where the mechanism should be now. PID compares that target position to the measured position and creates the corrective output.

Build path

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)));

Debugging and failure modes

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.

Practice

Add a profiled target to one mechanism. Telemetry should show target position, actual position, target velocity, and output.

Checks

  • The profile timer resets only on target changes.
  • The controller follows the profile's current position.
  • The mechanism stops or holds safely after the profile completes.

Check your understanding

Module check

Why not recreate the motion profile every loop?

0 of 1 answered

References

Game Manual 0Community FTC programming, control, and robot design reference.FTC DashboardTelemetry, config variables, and tuning support.

Finished reading?

Mark this lesson complete.

You'll move on to “Testing Profiles and Failure Modes” next.

Motion Profile ConceptsTesting Profiles and Failure Modes