MK4I swerve drive jittering and jumping

Hi, I am having Problems with the angle control aspect of our modules. We are running a swerve test bot for prototyping, auto-testing, driver practice, etc., but I can’t get the modules to turn smoothly.

here is a description of the problem.

There is an obvious oscillation while applying anything more than a 0.1 proportional. I’ve seen other teams have these values up to 12 without adding an I or D into the mix. Otherwise, the modules also seem to kick and return to a 0 position when I let go of my joystick despite an If statement making the modules stay in the last known position.

P.S. I know this is in 2023 VScode, but I am planning on converting it over once everything works.

I’ve experiences similar problems to this. The issue was the encoder and motor were out of phase, so positive voltage would decrease the encoder position, and vice versa.

I’d perform the following steps:

  1. Connect the Rev Hardware Client to the steer motor spark max
  2. Using the telemetry tab, graph the position of the steer encoder
  3. manually spin the module counter-clockwise. Verify that the encoder value increases. If it doesn’t, invert the encoder value
  4. Apply a low positive voltage to the steer motor. Verify the module spins counter clockwise. If it doesn’t, invert the motor
  5. Double check your position / velocity conversion. I’m not sure which encoders you’re using, but the native units for the spark max absolute encoder is ‘rotations’, and you can convert the Rotation2d angle to rotations, so you shouldn’t need any units conversion for the steer motor.

similar/same issue?
I’ll make sure to check out your suggestions tomorrow and let you know if it works for me!

Thank you for the suggestion, I have tried it and everything was normal. I’m sure this info will help others if they come in the future though.

I fixed the problem a while back, I was scaling the output of the PID to match the module rotation but I should have taken the CANcoder’s angle and fed that into a PID controller to calculate the next output of the motor. I’ve implemented this change and It works extremely well. kinda odd that I didn’t catch this before but every mistake is a learning opportunity. Thank you all for the help.

2 Likes