After turning the swerve robot the wheel orientation gets messed up. Every time, the orientation is different. What we think is that the navX reads the encoder values once when the robot gets enabled but it never reads them again. Is there a way to get the navX to constantly read the encoder values in the code?Is there a way to view what the navX reads? Thanks in advance!
Wheel orientation is determined by the absolute encoder, this normally happens if you dont glue your magnet in
Alternatly, at least with the spark max and through bore encoder there is a function called,
“turnEncoder.setZeroOffset(angularOffset);”
If you run this you override the baked zero with some new value.
I assume some other hardware configs have similar methods to mess this up.
We have double checked and all of our magnets are glued in do you know of any other reasons why this might be happening?
With the Rev Max Swerve (I don’t think that’s the case here, that uses the through bore for hex, no magnets) there is a calibration jig and you can reset the zero if you goof it up by accident by placing that around the wheel and swerve module locking it in place to the right location while you re-zero the absolute encoder.
@SuperAwesomeSoup can we have some more info about the rest of the hardware used in that swerve module?
Your navX gyro does not “read” encoder values. It does not read anything. It produces an output that lets you code know the rotational position of your drive chassis.
It’s pretty hard to guess what’s wrong without seeing your code. Knowing where your swerve code comes from might help somewhat.
Did you calibrate the forward position of each swerve module wheel and store those rotational “offsets” into your code?
Do you have the correct correspondence between the actual location of the swerve modules on your robot and what the code thinks the location is? In other words, are the CAN IDs of the motors and encoder for the front left module entered correctly into the code where the code is expecting the values for the front left module? Same for the other three modules.
One footgun I’ve come across is properly declaring your offsets:
double offset;
offset = 36;
Is different from:
double offset;
offset = 36.0;
Be sure to throw in your decimals.
Also, can we see your code?
How did you check?
A good way to do it is have a sharpie line on the top of the magnet pointing in a cardinal direction relative to the robot. If this moves at all your magnets are not glued correctly.
Thank you all so much. Your advice did help a lot for understanding how swerve works. Turns out it was a gear ratio issue.