JSim is a physics simulation library for FIRST Robotics Competition (FRC) robots. It provides a layered simulation pipeline that can add physical field interactions to a WPILib or YAMS swerve drive, including 2D drivetrain collisions and 3D game-piece simulation.
- Swerve-drive ground-truth physics with WPILib pose estimation support.
- Layered physics processing through the
PhysicsLayerinterface. - 2D robot collision handling powered by dyn4j.
- Field geometry for the 2026 REBUILT game, including walls, HUBs, TOWER uprights, and TRENCH gates.
- 3D FUEL simulation with gravity, bouncing, rolling, field structures, HUB scoring, robot interaction, and intake callbacks.
- NetworkTables publishers for simulated poses, intake zones, and scores.
example/
example_robot_project/ WPILib Java project demonstrating JSim
The implementation currently lives in the example project under
example/example_robot_project/src/main/java/jsim/physics. The example robot in
src/main/java/frc/robot shows how to connect the simulation to a YAMS swerve subsystem.
- Java 17
- A 2026 WPILib installation and GradleRIO environment
- A desktop-capable FRC development environment for simulation
Run these commands from example/example_robot_project:
./gradlew build
./gradlew testTo start the desktop robot simulation with the example project:
./gradlew simulateJavaOn Windows, use gradlew.bat instead of ./gradlew.
Create a SwerveDrivePhysics instance for the drivebase, then add the physics layers needed by the
simulation:
physicsSim = new SwerveDrivePhysics(drive)
.addLayer(new Dyn4jCollisionLayer(robotMass, field))
.addLayer(new FuelLayer(field));Call drive.simIterate() followed by physicsSim.update() from the subsystem's
simulationPeriodic() method. See
SwerveSubsystem.java
and FuelLayer.java
for the complete integration examples.
JSim is under active development. APIs and simulation behavior may change as additional FRC field elements and physics features are added.