Robot-code migration onto ExcaLib v2 (stacked on #47) - #48
Robot-code migration onto ExcaLib v2 (stacked on #47)#48YehudaRothstein wants to merge 27 commits into
Conversation
…state machine Drum + belt become VelocityMechanisms (onboard 1 kHz velocity loops, verified configs, DogLog telemetry, sim models). Two-state machine (IDLE/TRANSPORT) replaces the polled enum field; shooter-ready gating preserved. v1 gains/setpoints ported in legacy units (documented conversion) for behavior parity; VOLTAGE mode until the FOC SysId session. Robot loop now refreshes SignalHub before the scheduler and polls FaultReporter; Telemetry.init on boot. Public API (setStateCommand/atPositionTrigger/manualTransport) kept — Superstructure untouched in this commit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Four-bar becomes a PositionalMechanism (leader/follower Krakens, MotionMagic bounded at v1's 1.5 rad/s, arm-cosine kG, v1 1.5 V output clamp preserved via peak-voltage config, device-side soft limits) and the roller a RollerMechanism. OPEN/CLOSE/PUMP state machine replaces the polled enum; PUMP keeps the v1 oscillation (1.6 rad <-> 0 rad at 0.5 s, roller at 0.8 duty). Position still seeded from the v1 stow constant; fusing the existing CANcoder is a flagged follow-up (needs on-robot offset calibration). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…hine Turret and hood become PositionalMechanisms (turret: continuous-wrap goals inside -5.4..1.5 rad with v1's trapezoid profile; hood: plain position loop with trench-aware dynamic max), flywheel a two-Kraken VelocityMechanism. All v1 competition logic preserved verbatim: interpolation maps, 3-iteration shot lead, radial-velocity compensation, EMA-filtered readiness, BallCounter, LED blink, TurretOffsetGetter feed for vision. Ratios derived from v1 conversion factors (documented); gains ported V/rad -> V/rot in VOLTAGE mode (FOC after SysId). Deltas called out: symmetric hood kS 0.3125 (was +0.375/-0.25), turret-aligned now compares to the commanded goal. Superstructure adapted to the new coast/manual-shooting API. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ister auto commands Superstructure now extends excalib2's Superstructure<RobotState>: each goal fans out to the intake/shooter/transport state machines in one onEnter, replacing the ParallelCommandGroup-of-InstantCommands. Trigger wiring preserved 1:1 (including the stubbed zone triggers, kept stubbed on purpose); dead ledStateFor and 15 copy-paste NT getters replaced by DogLog lines. Also re-enables RobotContainer.registerCommands() (audit P-04: autos referenced idle/shoot/intake named commands that were never registered and silently no-op'd). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…RE swerve + MT2) Hand-authored Tuner-style constants in SwerveConfig, derived from v1 values (drive 5.27:1, steer 26.09:1, 2 in wheels, FusedCANcoder with device-burned offsets, v1 gains converted to per-rotation volts). RobotContainer drives via DriveCommands.fieldCentric (deadband now rescaled); Superstructure decoupled from the drivetrain type (takes pose/speeds suppliers). Vision moves from MT1-in-periodic to the MegaTag2 path: turret-corrected orientation feed, turret-frame -> robot-frame pose transform (v1 turretToRobot math), TurretOffsetGetter isFast rejection gate, distance/tag-count std-dev scaling. PathPlanner AutoBuilder wired with wheel-force feedforwards. FaultReporter skips fault scans in sim (signals not modeled -> console spam). ⚠ Needs on-robot verification before competition: module inversions, CANcoder offsets, coupling ratio (set 0), drive/steer gain re-tune. Old ExcaLib v1 remains in-tree and compiling (removal only after approval). Verified: build green; simulateJava boots clean (no exceptions, no loop overruns). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Migrates the robot implementation (frc.robot) onto ExcaLib v2 (frc.excalib2) archetypes (mechanisms + state machines), including the superstructure goal machine and CTRE swerve/vision integration, while keeping ExcaLib v1 in-tree and compiling for reference.
Changes:
- Rebuilt Intake / Shooter / Transport as ExcaLib v2
PositionalMechanism/VelocityMechanism/RollerMechanism+StateMachine-driven subsystems, with tuning data and key targeting logic preserved. - Introduced a hand-authored CTRE swerve
SwerveConfigand added turret-mounted Limelight MegaTag2 pose transformation support. - Updated robot lifecycle to initialize v2 telemetry and refresh/optimize Phoenix status signals ahead of command execution; re-enabled PathPlanner named-command registration.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/frc/robot/SwerveConfig.java | New CTRE swerve constants + Limelight MT2 wiring + turret-pose→robot-pose transform hook. |
| src/main/java/frc/robot/superstructure/Superstructure.java | Refactors superstructure into v2 goal machine that fans out subsystem state requests. |
| src/main/java/frc/robot/subsystems/transport/TransportConstants.java | Ports transport tuning into v2 gains/budgets + adds sim models and legacy-unit derivations. |
| src/main/java/frc/robot/subsystems/transport/Transport.java | Rebuilds transport as two v2 VelocityMechanisms controlled by a 2-state machine with shooter-ready gating. |
| src/main/java/frc/robot/subsystems/shooter/ShooterConstants.java | Ports shooter ratios/gains/constraints into v2 units, adds budgets + sim models. |
| src/main/java/frc/robot/subsystems/shooter/Shooter.java | Rebuilds shooter as v2 mechanisms + state machine; preserves interpolation maps and lead/compensation math; adds DogLog telemetry. |
| src/main/java/frc/robot/subsystems/intake/IntakeConstants.java | Ports intake geometry/gains/motion/budgets + sim models; documents v1→v2 derivations. |
| src/main/java/frc/robot/subsystems/intake/Intake.java | Rebuilds intake as v2 four-bar + roller mechanisms with OPEN/CLOSE/PUMP state machine. |
| src/main/java/frc/robot/RobotContainer.java | Switches to v2 swerve, restores named-command registration, updates teleop drive command wiring. |
| src/main/java/frc/robot/Robot.java | Initializes v2 telemetry, optimizes signals at boot, refreshes signals + polls faults before commands. |
| src/main/java/frc/excalib2/telemetry/FaultReporter.java | Skips fault polling in simulation to avoid stale-CAN spam. |
| src/main/java/frc/excalib2/swerve/SwerveSubsystem.java | Adds camera-pose→robot-pose transform support for non-chassis-mounted cameras. |
| src/main/java/frc/excalib2/mechanisms/VelocityMechanism.java | Selects between MotionMagicVelocity vs plain velocity closed-loop based on config motion constraints. |
| src/main/java/frc/excalib2/mechanisms/PositionalMechanism.java | Adds plain position closed-loop path when no motion constraints are configured. |
| src/main/java/frc/excalib2/device/ExcaTalonFX.java | Adds plain position/velocity control requests alongside MotionMagic-based requests. |
| README.md | Updates repo layout documentation to reflect ExcaLib v2 structure and migration state. |
| CLAUDE.md | Updates contributor/agent guide to reflect v2 architecture, control conventions, loop order, and tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .rotorToMechanismRatio(FLYWHEEL_ROTOR_PER_MECHANISM) | ||
| .gains(FLYWHEEL_GAINS, FLYWHEEL_SIM_GAINS) | ||
| .currentBudget(FLYWHEEL_BUDGET) | ||
| .tolerance(Radians.of(FLYWHEEL_TOLERANCE_RPS)) // rot/s tolerance |
| @@ -93,12 +93,14 @@ private void configureBindings() { | |||
| // ); | |||
|
|
|||
| swerve.setDefaultCommand( | |||
…in v2 Part 1 — API style (team preference: constructors + instance methods, no static factories): - Robot code uses new Gains / MotionConstraints / CurrentBudget / MechanismConfig, direct StateMachine construction, and simRotationalModel/simArmModel config methods - SwerveConfig becomes pure public constants; RobotContainer constructs SwerveSubsystem directly and wires vision + AutoBuilder itself Part 2 — v1 parity (nothing lost from the old library): - SwerveSubsystem covers every v1 Swerve capability: robot-centric + heading-locked drive (turnToAngle), pathfindToPose / pathfindThenFollowPath (missing-file Alert kept), pathfind with driver override, reset heading/pose, coast, pose/heading/speeds getters, sawTagRecently trigger, Field2d, drivetrain SysId (translation/steer) - New utils: AllianceFlip.AllianceTranslation/AlliancePose, LedStrip (WPILib LEDPattern), LoopTimer, CAN-bus health in FaultReporter - Robot code switched off v1 utils (AllianceUtils/LEDs/ PerformanceMetricsTracker/LoggablePS5Controller/CANHealthMonitor); flywheel LED blink binding moved to RobotContainer via a new shooter.flywheelSpinning trigger; per-loop RT-priority-99 call dropped (audit P-15); orphaned LedState deleted - StateMachine schedules whileIn commands via CommandScheduler (Command.schedule() deprecated in 2026) - docs/V1_TO_V2_MAPPING.md: every v1 class -> ported / replaced / dropped Verified: build green, 9/9 tests, sim boots with no exceptions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Self-contained HTML handbook covering the whole workflow: environment setup, project layout, the mental model, the five building-block value objects, a step-by-step first subsystem, every mechanism archetype with all config options, state machines, superstructure, swerve + vision + auto, telemetry/tuning/SysId, simulation, the robot loop, deploy, troubleshooting, checklists, and full config/API reference appendices. Features: sticky scrollspy nav, light/dark toggle, syntax-highlighted copy-paste code blocks, callout boxes, step lists, checklists, reading progress bar, print + mobile styles. No external dependencies. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Prescriptive, linear recipe book: one recipe per mechanism (arm/pivot/ hood, turret, elevator, flywheel, roller) and per subsystem, each as 'make these files -> paste this -> change these numbers -> call these functions'. Includes the exact state-machine build sequence, a complete worked subsystem, superstructure fan-out, swerve, and button/auto binding. Every archetype has a REQUIRED/OPTIONAL function table. Same interactive shell as the handbook (nav, dark mode, copy buttons). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…enced devs) Decision-driven reference: each MechanismConfig field is posed as a question with branches that map straight to the exact call (feedback source, control mode, motion profile, gains, gravity type, current budget, limits/wrap, sim model). Conceptual and visual — inline SVG diagrams for the layer stack, setpoint data flow, archetype decision tree, motion-profile shapes (trapezoid vs Expo), gain-composition sum, current-limit split, state-transition graph, superstructure fan-out, and the loop timeline. Plus an archetype capability matrix and a 'decisions -> finished config' annotated example. Dark theme default. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Full Hebrew translation of the prose; all code, API names, and diagram labels stay English. Layout is direction-aware via CSS logical properties (border-inline, inset-inline, text-align:start) so it works in both RTL and LTR, with a direction toggle. Code blocks and inline identifiers are forced LTR + bidi-isolated so things like .fusedCANcoder(...) never scramble inside Hebrew text. Diagram labels kept English with Hebrew captions to avoid SVG bidi issues. Dark default. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…y line In-depth annotated walkthrough of the actual migrated Intake.java: every config line, the follower/opposed reasoning, VOLTAGE-vs-FOC, the two speed clamps, arm-cosine gravity, boot seeding, the state machine (whileIn vs onEnter, run() requirements, transitionFromAny), the pump command, the public API's two request styles, and the mandatory periodic(). Plus a subsystem-map diagram, a 'what the library did for you' table, and a v1-vs-v2 contrast. Reasoning callouts throughout. Dark default, same interactive shell. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Single self-contained HTML manual merging and superseding the earlier handbook/cookbook/decision-map/anatomy drafts, with full depth: - 39 sections covering EVERY library class: CANDeviceId, ControlMode, Gains, MotionConstraints, CurrentBudget, Motor, DeviceConfigs, SignalHub, MechanismConfig (every field: signature, default, Phoenix mapping, failure mode), Mechanism base, Positional/Linear/Velocity/ Roller archetypes, MechanismSim, StateMachine (exact semantics), Superstructure, SwerveSubsystem (every command), LimelightMegaTag2, DriveToPose, Autos, Telemetry/DogLog, TunableNumber, FaultReporter, LoopTimer, AllianceFlip, Zones, LedStrip - §21: the real Intake dissected line by line with reasoning (per-line config table, whileIn-vs-onEnter, run() requirements, boot seed, pump composition, API audiences, the invisible work, v1 contrast) - Workflows: environment setup, repo/commands, boot & loop order, simulation, SysId->FOC tuning procedure, deploy & bring-up, troubleshooting matrix, checklists, glossary - Dual-audience: BASICS/DEEP badges; decision blocks mapping physical questions to exact calls; SVG diagrams (layers, dataflow, profiles, gain composition, state graph, fan-out, loop timeline); sidebar search (/), scrollspy, dark default, copy buttons API tables verified against the actual source (grep of all public methods), not from memory. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
EXCALIB_MANUAL.html is now the one canonical doc. Folded in the last pieces the drafts had that it lacked (archetype decision tree + capability matrix at the top of Part V; 'where the numbers come from' table in §13.15), then removed the superseded drafts: handbook, cookbook, decision map (EN), subsystem anatomy — all fully contained in the manual. The Hebrew decision-map edition is kept as a separate language deliverable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rent) path §35 rewritten: what quasistatic/dynamic measure; the exact SysIdRoutine the library builds (config, SignalLogger state channel, why the device is the data logger, requirements); binding snippets for mechanisms and the swerve; run-session and hoot-analysis procedures; §35.5 the FOC path — why voltage results can't be reused, the volts-as-amps idiom, the new sysIdQuasistaticTorque/DynamicTorque routines and forceAmps, analyzer channel mapping, the two-edit FOC switch, and the note that Expo kV/kA stay volt-referenced. §14 API table updated with the torque routines. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… approved The robot has run entirely on frc.excalib2 since the migration; v1 was kept in-tree only until removal was approved. It now is. - Delete the whole frc.excalib package (53 files: motor wrappers, mechanisms, swerve, slam/aurora, imu, math, utilities, commands). - Constants.java: drop the dead SwerveConstants inner class (replaced by SwerveConfig) and all v1 imports; drop now-unused imports. - Robot.java: drop PeriodicScheduler.run() and TalonFXMotor.refreshAll() (nothing registered on either anymore — all motors are excalib2 Motor managed by SignalHub). - Remove the vestigial .gitmodules (v1 was tracked in-repo, not a real submodule) and the stale MOTOR_LIBRARY_CHANGES.md (v1-era report). Verified: ./gradlew build green (compile + unit tests); simulateJava boots clean with no exceptions. No frc.excalib references remain in src. Monologue remains (separate vendordep, not part of this approval). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
v1 is gone: architecture notes now describe a single library; README tree drops the excalib/ line and fixes stale entries (Motor not ExcaTalonFX, drive commands on SwerveSubsystem, LinearExtension/LoopTimer/ LedStrip); manual §2 marks frc/excalib as removed; mapping doc flips the 'still on v1' section to a done status. Monologue noted as the last independent cleanup. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mechanism fields widened to public final (Intake fourBar/roller, Shooter flywheel/hood/turret, Transport drum/transport) and Superstructure.transport exposed, so a characterization harness can reach them. RobotContainer.configureTestBindings(), gated to DriverStation Test mode via RobotModeTriggers.test() so nothing fires in teleop/auto: - L1: coast the whole robot (swerve + intake four-bar + turret) for zeroing - D-pad: SysId (quasistatic/dynamic, fwd/rev) on a one-line-selectable 'mechanism under test' — swap to the torque variants for FOC characterization - triangle/cross: intake OPEN/CLOSE direction+range check - circle: low fixed-speed flywheel spin (direction/readiness check) Teleop and autonomous wiring untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Removes the last legacy logging dependency: - Robot: drop Monologue.setupMonologue() and updateAll() - RobotContainer: drop 'implements Logged' + the @nt getter (its value wasn't load-bearing; live tuning is TunableNumber now) - BallCounter: drop 'implements Logged' + @Log.NT (the count is already logged to DogLog by the Shooter as Shooter/BallCount) - build.gradle: remove the com.github.shueja:Monologue vendordep Verified: build green; simulateJava boots clean and the WPILib DataLog is writing (logs/FRC_*.wpilog) alongside DogLog's NT/DataLog output and Phoenix SignalLogger. No monologue references remain anywhere. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- docs/BRINGUP_TESTPLAN.html: on-robot first-run walk-through, ordered by risk. Pre-power (Tuner X), deploy & clean boot, proving DogLog + the .wpilog data log, the Test-mode harness, the per-mechanism recipe with exact DogLog keys and pass/fail, rollers/current-spike, the careful swerve-on-blocks section, vision, superstructure goals, auto dry-run, the SysId->FOC session, an if-it-fails matrix, and a key cheat-sheet. - CLAUDE.md / V1_TO_V2_MAPPING.md: Monologue retired (DogLog is the sole telemetry system); corrected the robot-loop description. - Manual doc index links the bring-up plan. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
What this is
Stacked on #47. Every subsystem, the superstructure, and the drivetrain rebuilt on the ExcaLib v2 archetypes — the proof that the template layer works. This is a refactor onto a better foundation, not a behavior change: all tuning data (interpolation maps, setpoints, tolerances, current limits) is ported verbatim with the v1→v2 unit derivations documented inline. The old library remains in-tree and compiling (removal only after explicit approval).
Migration map
VelocityMechanism(onboard 1 kHz loops) + IDLE/TRANSPORT machine; shooter-ready gating preservedPositionalMechanism(MotionMagic @ v1's 1.5 rad/s + 1.5 V clamp, arm-cosine kG, device soft limits) +RollerMechanism; OPEN/CLOSE/PUMP machine (PUMP oscillation preserved)PositionalMechanism(turret continuous-wrap in −5.4..1.5 rad; hood trench-aware max), flywheelVelocityMechanism; maps, 3-iteration shot lead, radial-velocity comp, BallCounter, LEDs, shooterReady — verbatimSuperstructure<RobotState>goal machine, one fan-out; trigger wiring ported 1:1 (zone stubs kept stubbed)SwerveDrivetrainvia hand-authoredSwerveConfig; MegaTag2 with turret-corrected orientation + turret→robot pose transform + isFast gate🟥 Behavior deltas — read before driving
SwerveConfigJavadoc.registerCommands()was commented out on main — audit P-04): autos will now actually intake/shoot. Verify auto behavior is desired before fielding.Testing evidence
./gradlew buildgreen at every commit.simulateJavaboots clean: robot program starts, DogLog + SignalLogger live, no exceptions, no loop overruns over a 60 s soak (the only console error is v1's pre-existing "DS alliance empty" report, present on main too).Follow-ups
MAX_SPEED_MPS/MAX_OMEGAfrom the v1 test values (2 m/s / 1.5 rad/s) once the drivetrain is verified.🤖 Generated with Claude Code
Update: API style pass + full v1 feature parity
Two follow-up requests applied on this branch:
newand configured with instance methods —new Gains(kP,kI,kD,kS,kV,kA),new MotionConstraints(...)(3-arg = trapezoidal, 2-arg = Expo),new CurrentBudget(stator, supply),new MechanismConfig(name, id),new StateMachine<>(name, initial)(no builder — declarations chain on the instance, initial state fires on first tick), and drive commands live onSwerveSubsystem(swerve.fieldCentricDriveCommand(...)) instead of aDriveCommandshelper class.docs/V1_TO_V2_MAPPING.mdfor the complete v1-class → v2 table. Highlights:SwerveSubsystemnow has every v1Swervecapability (heading-locked drive, pathfind-to-pose / then-follow-path / with-driver-override, reset heading/pose, coast,sawTagRecently, Field2d, drivetrain SysId); newLedStrip(WPILibLEDPattern),LoopTimer, alliance pose types onAllianceFlip, CAN-bus health inFaultReporter. Robot code no longer uses any v1 utilities (only Monologue +PeriodicSchedulerremain until v1 deletion).Re-verified after the changes: build green, 9/9 unit tests, sim boots with no exceptions.
Update: ExcaLib v1 removed ✅ (approved)
With the migration proven, the old library was deleted:
frc.excalibpackage removed (53 files: motor wrappers, mechanisms, swerve, slam/aurora, imu, math, utilities).Constants.java: deadSwerveConstantsinner class dropped (replaced bySwerveConfig); v1 + now-unused imports removed.Robot.java:PeriodicScheduler.run()andTalonFXMotor.refreshAll()dropped — nothing registered on either (all motors are excalib2MotorviaSignalHub)..gitmodulesand staleMOTOR_LIBRARY_CHANGES.mdremoved.Verified:
./gradlew buildgreen (compile + unit tests);simulateJavaboots clean with no exceptions; zerofrc.excalibreferences remain insrc. Only follow-up: retiring Monologue in favor of DogLog (separate vendordep, tracked independently).