Simulation and Log Replay

1. WPILib Simulation

WPILib’s built-in simulation allows for rapid iteration on code when a physical robot is not available. It is not intended for control tuning, but is a great tool for development and validation prior to hardware access.

  • Getting Started

    1. Open the command palette in VS Code (Ctrl + Shift + P).

    2. Run “WPILib: Simulate Robot Code”.

    3. The simulator starts and mimics periodic robot loop execution.

  • Advantage Scope Integration Once running, press Ctrl + Shift + K to connect to the simulator in Advantage Scope, where you can view real-time data, verify state transitions, and visually inspect behavior across multiple subsystems.

  • Primary Use Cases

    • Rapid iteration before hardware is available

    • Developing state machines, request/action flows, and autonomous routines

    • Testing sensor emulation, command triggering, and superstructure coordination

    • Validating outputs, behaviors, and transitions in a closed loop


2. MapleSim

MapleSim is a simulation library used for selectively modeling and emulating more complex behaviors in software.

  • Typical Uses Include:

    • Simulated projectile motion

    • Intake detection logic

    • Game pieces

    • Drivetrain collisions and virtual wall interactions

    • Localization testing (Only one that isn't just for fun)

We deviate from MapleSim when simulating other inputs/outputs, such as beam breaks, vision, or full subsystem logic. These are better tested through custom IO simulation implementations or directly on hardware.

This is mainly for fun but takes very little time to set up and you will work harder when having fun


3. Log Replay

Thanks to full log replay support via Advantage Kit, we are able to simulate a real match or test session against updated robot code without re-deploying or retesting on the field.

  • How It Works:

    1. Set the robot to Log Replay Mode by modifying RobotConstants.java.

    2. When the code starts, you’ll be prompted to select a log file.

    3. All input values (sensors, vision data, button presses, etc.) are played back into the code as if they were live.

    4. A log file will be generated containing your new outputs

  • Why It’s Valuable:

    • Test new vision filters or standard deviation parameters

    • Logging an output you forgot to log (or didn't make sense to log)

    • Validate behavior of improved subsystems without risking hardware

    • Ensure that control code behaves identically on known data before redeploy

    • Enable offline debugging and tuning during competition or travel

I thought I would use this all the time but usually you either:

  • Don't have time

  • Immediately know what change to make based on the log file and the match

Last updated