YAGSL CANcoder errors

Hello. We are currently trying to get a YAGSL drive base setup and after setting all of the offsets and ids, we tried running it and got so many errors it was crashing driver station. They all seem to stem from the CANcoders but I’ve never seen this error before and doesn’t appear when using our old code. Any insight or things we can check would be much appreciated.

For reference we are using neos for drive and steer, cancoders for encoding, and a NavX in the mxp port on the Rio.

Warning at edu.wpi.first.wpilibj.Tracer.lambda$printEpochs$0(Tracer.java:62): SwerveSubsystem.periodic(): 0.010417s
buttons.run(): 0.030007s
CANCoder 10 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 10 magnetic field is less than ideal.
CANCoder 10 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 10 reading was faulty.
SmartDashboard.updateValues(): 0.000507s
disabledInit(): 0.000588s
robotPeriodic(): 0.130090s
LiveWindow.updateValues(): 0.000089s
Shuffleboard.update(): 0.000920s
disabledPeriodic(): 0.000589s
Warning at edu.wpi.first.wpilibj.Tracer.lambda$printEpochs$0(Tracer.java:62): SmartDashboard.updateValues(): 0.000507s
disabledInit(): 0.000588s
robotPeriodic(): 0.130090s
LiveWindow.updateValues(): 0.000089s
Shuffleboard.update(): 0.000920s
disabledPeriodic(): 0.000589s
Loop time of 0.02s overrun
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:387): Loop time of 0.02s overrun
CANCoder 12 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 12 magnetic field is less than ideal.
CANCoder 12 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 12 reading was faulty.
CANCoder 13 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 13 magnetic field is less than ideal.
CANCoder 13 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 13 reading was faulty.
CANCoder 11 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 11 magnetic field is less than ideal.
CANCoder 11 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 11 reading was faulty.
Loop time of 0.02s overrun
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:387): Loop time of 0.02s overrun
CANCoder 10 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 10 magnetic field is less than ideal.
CANCoder 10 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 10 reading was faulty.
CTR: CAN frame not received/too-stale.
CTR: CAN frame not received/too-stale.
CANCoder 12 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 12 magnetic field is less than ideal.
CANCoder 12 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 12 reading was faulty.
CANCoder 13 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 13 magnetic field is less than ideal.
CANCoder 13 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 13 reading was faulty.
CANCoder 11 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 11 magnetic field is less than ideal.
CANCoder 11 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 11 reading was faulty.
CANCoder 10 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 10 magnetic field is less than ideal.
CANCoder 10 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 10 reading was faulty.
CANCoder 12 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 12 magnetic field is less than ideal.
CANCoder 12 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 12 reading was faulty.
CANCoder 13 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 13 magnetic field is less than ideal.
CANCoder 13 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 13 reading was faulty.
CANCoder 11 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 11 magnetic field is less than ideal.
CANCoder 11 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 11 reading was faulty.
CANCoder 10 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 10 magnetic field is less than ideal.
CANCoder 10 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 10 reading was faulty.
CANCoder 12 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 12 magnetic field is less than ideal.
CANCoder 12 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 12 reading was faulty.
CANCoder 13 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 13 magnetic field is less than ideal.
CANCoder 13 reading was faulty.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:98): CANCoder 13 reading was faulty.
CANCoder 11 magnetic field is less than ideal.
Warning at swervelib.encoders.CANCoderSwerve.getAbsolutePosition(CANCoderSwerve.java:92): CANCoder 11 magnetic field is less than ideal.

So just to confirm, your CanCoders are on those CanIDs connected to the Rio?

Could you also share your old code?

Yeah all the CANCoder IDs should be correct. Brought them all over from the constants file from old.

Old Code

What color is the light on the CanCoders?

Those are technically not errors, they are just warnings. It looks like your CANCoders are either too close or too far from the magnet. We took off the upper portion of the housing and held the CANCoder to see when the light turned green. Some of them needed a piece of tape or two to push down on the board to ensure the proper distance. It is still fine to run them like this, its just not quite the best case scenario.

1 Like

The LED state must be red, as the field cannot be trusted when this error is spewed.

If my memory serves me right they were all solid green.

The lights are all green without messing with magnet positioning. However, if this is just warnings, would it be safe to just suppress them or set a config to not be as picky.

Also, I’m not sure if this is the reason or not but it felt like due to the high volume of warnings coming out of every console, it was causing DS to freeze up and/or have extreme delays when navigating menus. That plus the comms status was a 50/50 red green split paired with a red on the RIO board.

After I initially posted this thread, I decided to test out some other drive base I was working on and the same errors and symptoms were happening. This time it was a template made based on our old code linked above. GitHub - tlsd-robotics/SwerveBase-346.

I wonder since it happened on two completely different swerve lib programs, but had the exact same problem on both. Could it that something was updated, or there are mismatched versions of stuff. Won’t be able to check or update versions till next Monday so I won’t be able to check anything until then.

Are you sure the lights are green and it’s throwing the warning? That doesn’t seem to be possible

I’ve been known to break stuff in impossible ways. I can confirm with 100% certainty that at least 2 of the CANCoders were solid green since I could see them clearly from where I sat at the laptop. The other two I am pretty confident in them being green, but that would be like 70% certainty.

My only guess is that the IDs are wrong or something because I don’t know how it could be green and invalid

Just for curiosity sake, if you have a spare CANCoder can you replace one of the CANCoder’s 10-13 with it and see if the new CANCoder shows an error. If so it may be the on the CAN bus.

When I get back into the shop for next weeks meet I’ll see if we got any spares.

Though it doesn’t seem to be a hardware problem due to last years code still working just fine. Just anything new I try to put onto it. I say anything, but I was only able to test the two the two other programs I’ve linked so far.

YAGSL has extra safety’s built into it like this one to make sure your performance is as expected, if you want to disable this you can move that conditional one lower and return angle and it should work like the others you say you have tested. I wouldn’t recommend it. Another thing you should do is open up tuner x and perform a status check on it to see if tuner x has anymore info.

Great suggestion on using Tuner X. Keep forgetting about all the tools available.

And depending on what happens, I may just disable that single check about mag field and see if it works. Not a fan of getting rid of safety features, but if it gets it to work, might just have to.

Did you make any progress here? We’re trying to get yagsl going today with Sparkmax/cancoder/navx and seeing errors very similar to yours. Code is GitHub - e-moser/Robot at SwerveDev .

All 4 encoder LED are rapid green blink, which means “Magnet in range (between 45mT – 75mT).”.

I just found this thread that suggested current version of YAGSL needs Phoenix V5 firmware on the cancoders. We set that back (we had 6) and errors are gone.

1 Like

Great find. We haven’t been in the shop since I originally posted this thread but this sounds like the issue. If what they said is true, then it may be upgraded to v6 by the time we can get back to work, if not, first thing I’m doing is jumping down to v5 and hoping for the best.

Thanks for sharing this info,