Swerve Simulations

Hey everyone,

My team is trying to simulate a swerve drive, but we’re having trouble getting started. Our swerve drive code is based off of the MAXSwerveModule Java Template, but with several modifications.

This is our code: GitHub - femaidens/2024-Crescendo: our code for 2024 crescendo!

This year, we changed to Krakens, but we don’t know how much it will affect the code. We are also using NavX for our gyro. Additionally, we want to simulate our code using AdvantageScope and test our autonomous paths through PathPlanner simulations. We are planning on changing our swerve code based on the simulation code. If anyone can give any guidance that would be highly appreciated!

1 Like

We started with the YAGSL-example repo and I can heartily recommend it.

It might feel like starting over, but was worth it for us off-season.

1 Like

Which motors are Krakens and which are Spark Maxes?

I created YAGSL, and would highly recommend it for exactly this. You can modify your existing code to work and add simulation to it (you can even pull the sim from YAGSL itself for all i care! YAGSL-Example/src/main/java/swervelib/simulation/SwerveModuleSimulation.java at dev · BroncBotz3481/YAGSL-Example · GitHub ). simulation is built-into YAGSL so all you have to do is open up the simui and show the field.

Even when you do all of that you may not have the same programmers next season or the following season but YAGSL will still be maintained and up to date with optimizations that take a season or 2 to learn about and implement.

YAGSL is also agnostic to your current program and you can drop it in however you see fit, you don’t need to use our example code!

However you don’t need it! You can absolutely read the code and implement everything yourself and nothing is stopping you except time.

MAXSwerve is finicky with YAGSL bc the neo550’s + sparkmax with attached throughbores require the usage of the zero tool in the hardware client and won’t work via JSON like everything else unless you use SwerveDrive.pushOffsetsToEncoders().

1 Like

could you elaborate on this? krakens have built in motor controllers, you cant control them with spark max motor controllers. even if you could use spark maxes, i would recommend not to. there are many benefits to the talonFX controllers built into the krakens

Are you connecting the Krakens to the output of the spark max? If so you need to stop doing that immediately.

9 Likes

My interpretation is that they’re using krakens as azimuth/steering/angle motors and sparkmax as drive motors.

1 Like

If so I’m like insanely impressed

2 Likes

I just double checked with my team and they’re not using SparkMaxes for Swerve. Instead they’re using the built in motor controllers

1 Like

This may be easier if you post a photo of your swerve module.