SwerveDriveSpecialties / Do-not-use-swerve-lib-2022-unmaintained

31 stars 77 forks source link

Feature request: Stagger slow CAN update intervals #15

Closed randomstring closed 2 years ago

randomstring commented 2 years ago

We see the CAN utilization spike to near 100% on intervals of 100ms and 500ms using CANcoders and Falcon 500s. This is on the RoboRIO CAN bus. I suspect this is because the slow status updates are set to 100ms and 250ms. An easy solution would be to stagger the update intervals so they were not all identical.

Ideally making the update intervals primes close to 100 and 250 respectively. Failing that you could just randomize the update interval in a range of 95-105 and 245-255 respectively. Or be systematic by adding the canid to the interval.

I've got a branch to test randomized update intervals, I'll test it next week after competition.

This is probably a non-issue for the new CAN FD bus, however this is an easy fix.

democat3457 commented 2 years ago

interesting

democat3457 commented 2 years ago

also i will say that the CANcoders are updating at 10ms, not 250ms (250ms is the timeout), but the falcons do have 250ms periods

randomstring commented 2 years ago

After reading the known issues for WPILib and the DriverStation, it looks like the CAN utilization spikes are just a reporting anomaly. I respectfully withdraw this feature request.

https://docs.wpilib.org/en/stable/docs/yearly-overview/known-issues.html#can-bus-utilization-is-noisy

Issue: CAN bus utilization as reported live by the DS or as shown in the DS log has significant variation or “spikes” in the data. This is due to the RoboRIO occasionally counting CAN packets in the incorrect time period, so one period will have a much lower utilization than reality and the next a much higher utilization than reality.