Three months ago, I explored Java physics simulation in this post, and it turned out to be a fascinating project.
Now, after three months of development, our team is excited to announce the release of our realistic swerve drive physics simulation with collision detection, integrated into 6328’s Advanced Swerve Drive example.
Realistic Swerve Drive Simulation with Collision Detection
This project’s drivetrain simulation calculates the frictional and propelling forces on each swerve module, modeling the drivetrain’s behavior using the dyn4j Java physics engine. Additionally, field obstacles are integrated into the engine, creating a realistic and interactive simulation environment.
By simulating the interaction between the wheels and the floor, our system also accounts for odometry skidding, providing a more accurate and realistic representation of drivetrain behavior.
We also simulate IMU drift when the robot experiences hard impacts, such as hitting a wall, to mimic real-world behavior closely.
Intake Simulation
In our physics simulation, game pieces are fully interactive, allowing us to detect when a piece comes into contact with the intake. This interaction enables the simulation to realistically depict how the intake “captures” the game pieces.
Vision Simulation
This project leverages the PhotonLib Camera Sim and includes a fully realistic simulation of our custom AprilTag vision odometry.
Additionally, we’ve enhanced the vision odometry by integrating 6328’s Log-Replay Technology. This feature enables us to refine our pose estimation strategy during replay, as explained in this talk.
Opponent Robots Simulation
Simulated opponent robots can be either manually controlled using a gamepad for defensive play or set to follow pre-programmed cycle paths. Like real robots, these opponents have collision boundaries, allowing drivers to practice both defensive and offensive strategies effectively.
Getting Started
Unlike the original example, which requires manual calibration, this project can directly import CTRE Chassis configurations from TunerConstants
generated by the CTRE Swerve Project Generator. This allows you to set up the project on your robot in just a few minutes. For detailed instructions, refer to the complete setup guide. As for Rev chassis, please follow the Rev Setup Guide.