SDS MK4i Current Angle and Absolute Encoder Readouts in Driver Station

Hello, we are having a problem with the MK4i modules aligning to the correct angle. In the attached video, I’m spinning the Back right module by hand and you can see the Current Angle and Absolute Encoder Positions going farther away from each other. After approximately 10 seconds, the two values suddenly snap to each other.

Here is a video. *fixed video link
https://drive.google.com/file/d/1dGxrVocDYOkuNpdkP04oU70wg6w7tot1/view?usp=sharing

We are using the Swerve Drive Specialties template - set up at MK4, but I imagine that we have to invert the steering sensor or something… Any advice would be greatly appreciated!

The absolute encoder position is only used once at the very beginning to understand the starting position.

What is your actual problem? Have you followed the setup instructions? When you enable teleop do all of your wheels face the same direction?

1 Like

Yes, I’ve followed the setup instructions and the wheels do not currently face the same direction at this time.

The problem is that the robot does not seem to understand what the forward direction is even after configuring the offsets per the instructions.

Also, the wheels twitch every ~10 seconds which seems to be when the absolute encoder and current angle are reset to equal each other. I’m not sure why this happens but it can be seen at the end of the video.

I would like to add that we’ve used similar code on our MK3 chassis which leads me to believe it’s something with the motor controllers being inverted, but I’m not sure what to change.

Thanks for the reply!

The “twitch” is some code in the SDS code that re-seeds the integrated encoder’s position every 10s while not rotating

1 Like

Sorry to double post - but yes, the Mk4i angle motors are upside down compared to the Mk3 motor, and the rotation needs to be inverted. The SDS code upstream doesn’t have proper support for the Mk4i modules yet - but it should be a one line change in the angle motor config

Edit: Additionally the gear ratios for the Mk4 is different than the Mk4i https://github.com/SwerveDriveSpecialties/swerve-lib/pull/9

1 Like

Thank you so much for the info. I’ll give this a shot tomorrow!

We made the changes and the twitching seems to be better.

However, we are having issue with the wheels resetting to different “forward” positions.

For reference, on our MK3 chassis the “Current Angle”, “Target Angle” and “Absolute Encoder Angle” readouts on Shuffleboard are always the same (or close).

On our new MK4I chassis, the values are not the same. “Current Angle” and “Target Angle” are the same, but “Absolute Encoder Angle” is a different value.

This is the only thing we’ve noticed that is different even when running the same exact code on both robots.

Any ideas?

Welp, we were editing a copy of the swerve-lib that wasn’t actually being deployed to the robot. Once we discovered this we started over from a fresh MK4I template and made sure we were editing the swerve-lib that was being deployed and now we have a driving chassis. :grin:

1 Like