FRC2706 / 2023-2706-Fall-Poseidon

Reprogramming Poseidon from scratch in the offseason.
Other
2 stars 0 forks source link

Implement error tracking #11

Open ErikCald opened 1 year ago

ErikCald commented 1 year ago

Part of the api of CANSparkMax let's us ask it for any fault codes it is experiencing. It would awesome to periodically ask the sparks for any fault codes and log them. It would also be incredibly helpful to present any faults and which device is causing them to the pit crew. That would greatly reduce the chance of something going wrong during a match because it can be found in the pits and solved.

For example, they could see that SparkMax number 4, the arm sparkmax, is reporting a sensor fault which means the encoder is unplugged.

The best tool to display stuff to pit crew would probably be [shuffleboard], where you can store a layout of networktable values to show. (https://docs.wpilib.org/en/stable/docs/software/dashboards/shuffleboard/index.html).

This idea can also extend to other devices like the CANCoder, PCM, PDP, and probably others.

ErikCald commented 1 year ago

There are multiple ways to go about doing this, here is one potential way:

Other related ideas:

ErikCald commented 11 months ago

Options for interface: Shuffle board or web dev with Frc Web Components (https://github.com/frc-web-components/frc-web-components)

ErikCald commented 11 months ago

I think this works FaultID.fromId(m_driveMotor.getFaults());

This is from last year

// Add CommandScheduler to shuffleboard so we can display what commands are scheduled
    ShuffleboardTab basicDebuggingTab = Shuffleboard.getTab("BasicDebugging");
    basicDebuggingTab
      .add("CommandScheduler", CommandScheduler.getInstance())
      .withPosition(3, 0)
      .withSize(3, 6);

https://docs.wpilib.org/en/stable/docs/software/dashboards/shuffleboard/layouts-with-code/index.html

ErikCald commented 11 months ago

Oh apparently it's a bit more complicated than asking the spark for faults. I found this code that is checking each bit in the short from getFaults()

https://github.com/frcmi/Robot2023/blob/ce8f851f4cd1489022d8e99a2f93ca8b0c925ca8/src/main/java/frc/robot/SparkMaxUtils.java#L73