6328's Advance Swerve Drive Example with More Enhanced Physics Simulation (Collision Detection and More)

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.
robot physics simulation
swervedrivesim

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.
odometrysim

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.
intakesim

Vision Simulation

This project leverages the PhotonLib Camera Sim and includes a fully realistic simulation of our custom AprilTag vision odometry.
visionsim2
visionsim1

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.
opponentrobotsim

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.

87 Likes

This is some incredible stuff… I can’t wait to look into it further

1 Like

How does testing work? If we have time my team could use our rev chassis to help with testing.

1 Like

think you can turn this into a game?

2 Likes

That will be great :grinning: ! Just drive the chassis around and see if there are any issues with the odometry. We’ve made some changes to the advanced_swerve_drive odometry thread, and we are not certain whether this affects how it works on REV hardware.

3 Likes

it has begun

3 Likes