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
Open the command palette in VS Code (
Ctrl + Shift + P
).Run “WPILib: Simulate Robot Code”.
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
Do not use simulation for PID tuning. The model does not match real-world inertia, friction, or electrical characteristics. Always tune loops on-robot.
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.
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:
Set the robot to Log Replay Mode by modifying
RobotConstants.java
.When the code starts, you’ll be prompted to select a log file.
All input values (sensors, vision data, button presses, etc.) are played back into the code as if they were live.
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
Last updated