Skip to content

Fault logger perf, CANivore stats, vision fixes, defense mode - #22

Open
cherriae wants to merge 2 commits into
mainfrom
fix/faults-vision-defense
Open

cherriae wants to merge 2 commits into
mainfrom
fix/faults-vision-defense

Conversation

@cherriae

@cherriae cherriae commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

  • FaultLogger is fast enough to run again (refs FaultLogger update() method takes too long. #20).
    • Fault signals are cached when registered, then refreshed with one refreshAll per CAN bus instead of about 59 separate refreshes.
    • Console, DogLog and NT output fire only when the active-fault set changes. DogLog faults also clear now.
    • Polling is turned back on at 1 s (addPeriodic(FaultLogger::update, 1) had been commented out).
  • CANivore bus stats (closes Make a method for canivore kernel logging. #19). FaultLogger.register(CANBus) logs utilization, bus-off, TX-full, REC and TEC under CANBus/<name>/, and raises an ERROR when the bus status is not OK. Swerve registers the swerve CANivore.
  • Vision fixes.
    • PhotonLib 2026 reports every visible tag as "used". We filter the used tags in place (the bug was found by 340), which avoids vendoring their 1134-line estimator.
    • Trig solve is the single-tag fallback, and it only chooses between the two PnP poses.
    • Heading is fed at each result's timestamp.
    • Results that use tags missing from our layout are skipped instead of throwing.
    • 4481's camera rotation-error logging is added under Vision/Camera Rotation Error/.
  • Defense mode.
    • Driver POV-up toggles it: drive stator 120 A, supply 60 A, 4.5 m/s, 2.5π rad/s.
    • Normal limits are cached at boot and restored on exit or disable.
    • Unreachable motors are skipped, so a toggle can't stall the loop.
  • Filtered chassis speeds. New getFilteredChassisSpeeds() (5-sample moving average). getChassisSpeeds() stays raw because driveTo seeds from it.

Behaviour changes to know

  • FaultLogger.report() output (console, DogLog, NT) now appears at the next update() poll, up to 1 s later. Characterization results like "Chassis MOI" print late.
  • Each fault prints once per occurrence instead of every poll.
  • New fault: CANBus (<bus>)- Fault Signals Not Received means a device or bus isn't sending its fault frames. It names the bus, not the device.
  • Every disable re-applies the drive current limits. CTREUtil logs 4 "Action Successful" INFO lines.
  • defenseSlipCurrent (120 A) currently equals the untuned frontSlipCurrent placeholder, so until that's tuned defense only raises the rear modules' stator limit.
  • calculateMotorMaxSpeedAndTorque reads the live stator limit, so don't run it enabled while defense is on.

Testing

  • ./gradlew build passes: 30 tests, 1 skipped (RobotTest, already @Disabled), 0 failures. New tests are FaultLoggerTest (5), SwerveDefenseModeTest, and VisionPoseEstimatorTest.multiTagIgnoresUnknownTag.
  • A cross-bus mutation check confirms devicesOnTwoBusesPoll fails if signals are refreshed across buses.
  • A ~55 s simulateJava run had no exceptions, and each fault printed once.
  • On desktop, FaultLogger.update() went from ~364 µs to ~64 µs over 13 sim devices. That figure is rough: tests disable DogLog and the console, and a desktop isn't a roboRIO.

Needs real-robot verification

  • Read Timing/FaultLogger/update() on the roboRIO. FaultLogger update() method takes too long. #20 should close only after this.
  • Check whether a "Fault Signals Not Received" fault flashes at boot, before fault frames arrive.
  • Toggle defense (POV-up), then disable, and confirm Defense Mode returns to false and the limits are restored.
  • Confirm single-tag poses are picked correctly; trig position is now used instead of gyro heading.
  • Tune defenseSlipCurrent above the tuned front and rear slip currents.

#2 (CameraServer noise in vision tests) is unchanged. It is an upstream PhotonCameraSim listener race, and tests still pass.

🤖 Generated with Claude Code

cherriae and others added 2 commits November 12, 2026 19:43
FaultLogger (#20): cache CTRE fault signals at register time and refresh
them with one refreshAll per CAN bus instead of ~59 single refreshes.
Console, DogLog and NT output now fire only when the active fault set
changes (DogLog faults also clear now). A failed per-bus refresh reports
a "Fault Signals Not Received" fault. clear() republishes NT. Fault
polling is re-enabled at 1 s.

CANivore stats (#19): FaultLogger.register(CANBus) logs bus utilization,
bus-off, TX-full, REC and TEC, and faults when the bus status is not OK.
Swerve registers the swerve CANivore.

Vision: PhotonLib 2026 reports every visible tag as used; filter the used
tags in place (fix found by 340). Fall back from multi-tag to trig solve,
which now only disambiguates between the two PnP poses. Feed heading at
each result's timestamp, skip results using tags missing from our layout,
and log camera rotation error (from 4481).

Swerve: driver POV-up toggles defense mode (higher drive stator/supply
limits and driver speeds), with normal limits cached at boot and restored
on exit/disable; unreachable motors are skipped so a toggle can't stall
the loop. Add getFilteredChassisSpeeds() (5-sample moving average);
getChassisSpeeds() stays raw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make a method for canivore kernel logging.

1 participant