Need help with swerve code

Our team is working on developing new swerve drive code in order to utilize the PathPlanner software. We are using Yet Another Generic Swerve Drive’s example for general motion control. When testing, our angle motors begin rotating without input. When we test translational motion we are able to move the wheels to face different directions but they are not consistently the same and they are not accurate. When attempting to rotate our wheels don’t face the proper directions and begin to spin uncontrollably. Any help would be much appreciated. Our code can be found here.

Hello!

Did you generate your config files with this?
https://broncbotz3481.github.io/YAGSL-Example/

What swerve module type do you have as well?

I don’t believe we did, so we’ll try that. We are using Mk4i swerve modules.

1 Like

What gearing? MK4i L2, L4, etc?

We just went through this bring-up and you’re welcome to look at our code (and the change history) here.

We’re using SparkMax, Neos, Mk4i (L2 gearing), CANCoders, and an ADIS16448.

I can’t promise that we got everything perfectly tuned (especially the PID fields), but it does run and drive and competed OK.

Edit to add: Methodically going through this step in the docs got us going. (We proved again that hours and hours of experimentation can save 15 minutes of reading the docs.)

1 Like

We are using L2 gearing.

Your conversion factors should be

"conversionFactors": {
	"angle": {"gearRatio": 21.4285714286},
	"drive": {"gearRatio": 6.75, "diameter": 4}
}

not this

for starters