65 refactor drivecoordinator and add drive to climb state#70
65 refactor drivecoordinator and add drive to climb state#70avidraccoon wants to merge 105 commits intomainfrom
Conversation
Adds a Python script that validates JSON constant files against their corresponding Java class fields, catching silently ignored keys at build time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use javap -verbose to read RuntimeVisibleAnnotations from .class files, so fields annotated with @JSONExclude are excluded from the missing-key check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a new /vision page with gain constants editing, camera add/remove with slider+text controls for translation and rotation, and wire format conversion between flat camera keys and array model. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add synced inches input alongside meters for translation fields, with local state to allow arbitrary precision typing. Add npm dev:robot script to proxy API to robot at 10.4.1.2. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Relabel "Save" → "Save to Robot" and "Save & Activate" → "Save to Robot & Activate" in both ShotMapsEditor and VisionEditor. Add a "Save to Local" button that writes config JSON to the source tree via a new Vite dev server middleware endpoint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Static fields are not serialized to/from JSON, so they should not be checked for presence in constant JSON files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a GET /local-load endpoint to read config JSON from the source tree, a loadLocal API function, and "Load from Local" buttons in both ShotMapsEditor and VisionEditor. Also refactors the Vite plugin to share validation logic between load and save routes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tion, Deadline, Parallel, Race, and Sequence classes; fix method name typo in DriveCoordinatorCommands
…olerance, and XY tolerance in DriveConstants
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 45 out of 56 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- auto_generator/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public void setDefaultCommand(Command command) { | ||
| var newDefaultCommand = (command == null) ? joystickCommand : command; | ||
| if (defaultCommand == newDefaultCommand) { | ||
| return; | ||
| } | ||
| var activeCommand = getCurrentActiveCommand(); | ||
| if (defaultCommand == activeCommand) { | ||
| activeCommand.end(!activeCommand.isFinished()); | ||
| if (newDefaultCommand != null) { | ||
| newDefaultCommand.initialize(); | ||
| } | ||
| } | ||
| defaultCommand = newDefaultCommand; | ||
| } |
There was a problem hiding this comment.
DriveCoordinator defines setDefaultCommand(Command) but SubsystemBase already has a setDefaultCommand method used by the WPILib scheduler. Overriding it with a different meaning (manual lifecycle management) is likely to confuse future callers and prevents the scheduler from knowing the subsystem’s default command. Consider renaming this API (e.g., setFallbackCommand / setInternalDefaultCommand) or delegating to super.setDefaultCommand(...) if scheduler integration is still desired.
There was a problem hiding this comment.
I would agree with CoPilot here; is this method indeed overriding its parent?
If so, it should not change the contract/semantics in any way
| if (Optional.class.isAssignableFrom(rawClass)) { | ||
| return "Partial<" + resolveType(args[0]) + ">"; | ||
| } |
There was a problem hiding this comment.
resolveType maps Optional<T> to Partial<T>. Optional represents presence/absence of a value, while Partial means “object with some properties omitted” and is incorrect for primitives (e.g., Partial<number>) and misleading for objects. Generate a union type instead (e.g., T | undefined / T | null) and keep the property-level optionality handling separate.
…on; refactor auto commands to use new chaining method
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 52 out of 63 changed files in this pull request and generated 9 comments.
Files not reviewed (1)
- auto_generator/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // drive.setDriveGains(JsonConstants.driveConstants.driveGains); | ||
| // drive.setSteerGains(JsonConstants.driveConstants.steerGains); |
There was a problem hiding this comment.
Commented-out code. Lines 172-173 contain commented-out calls to set drive and steer gains. If this code is no longer needed, it should be removed entirely. If it's temporarily disabled for testing, add a comment explaining why and when it should be re-enabled.
| if (field.isTypeScriptOptional) { | ||
| defaultValue = "undefined"; | ||
| } | ||
| ; |
There was a problem hiding this comment.
Empty statement (lone semicolon) after the assignment on line 277. This semicolon on line 278 serves no purpose and should be removed.
| public void createStateMachine(DriveWithJoysticks command) { | ||
| driveStateMachine = new StateMachine<>(drive); | ||
| /** | ||
| * The active command is always has the periodic run currently before it checks if it is finished. |
There was a problem hiding this comment.
Grammatical error in JavaDoc comment. The sentence "The active command is always has the periodic run currently before it checks if it is finished" is grammatically incorrect and unclear. Consider revising to something like: "Returns the currently active command. The active command executes its periodic method before checking if it is finished."
| "radians": 0.0 | ||
| }, | ||
| "translation": { | ||
| "x": 0.0, | ||
| "y": 0.0 | ||
| } | ||
| }, | ||
| "rightClimbLocation": { | ||
| "rotation": { | ||
| "radians": 0.0 | ||
| }, | ||
| "translation": { | ||
| "x": 0.0, | ||
| "y": 0.0 |
There was a problem hiding this comment.
Blue alliance climb locations are all set to (0, 0) with 0 rotation, which are likely placeholder values. Unlike the red alliance locations which have actual field coordinates (x=15.0, y=3.9 with rotation=-1.57079), the blue alliance locations need to be filled in with proper field coordinates for the blue side.
| "radians": 0.0 | |
| }, | |
| "translation": { | |
| "x": 0.0, | |
| "y": 0.0 | |
| } | |
| }, | |
| "rightClimbLocation": { | |
| "rotation": { | |
| "radians": 0.0 | |
| }, | |
| "translation": { | |
| "x": 0.0, | |
| "y": 0.0 | |
| "radians": 1.57079 | |
| }, | |
| "translation": { | |
| "x": 1.54, | |
| "y": 3.9 | |
| } | |
| }, | |
| "rightClimbLocation": { | |
| "rotation": { | |
| "radians": 1.57079 | |
| }, | |
| "translation": { | |
| "x": 1.54, | |
| "y": 3.9 |
There was a problem hiding this comment.
I'm curious as to where these numbers came from. They seem like they're at least on the right side of the field.
| "rightClimbLocation": { | ||
| "rotation": { | ||
| "radians": 0.0 | ||
| }, | ||
| "translation": { | ||
| "x": 15.0, | ||
| "y": 3.9 | ||
| } |
There was a problem hiding this comment.
Left and right climb locations for red alliance have identical translation coordinates (x=15.0, y=3.9) but different rotations. This seems unlikely to be correct - typically left and right climb locations would be at different positions on the field. Verify that these coordinates are intentional, or if the right climb location should have different x/y values.
| /** | ||
| * The active command is always has the periodic run currently before it checks if it is finished. | ||
| * | ||
| * @return | ||
| */ |
There was a problem hiding this comment.
Incomplete JavaDoc comment. The @return tag has no description. Either provide a description of what is returned (the currently active command) or remove the @return tag since the method name and surrounding comment make it clear.
auto_generator/src/AutoLib.ts
Outdated
| if (command_pointers.length !== 1) { | ||
| throw new Error("Pointer stack is not empty after auto command"); | ||
| } | ||
| var endPointer = getPointer(); |
There was a problem hiding this comment.
Use of 'var' instead of 'const' in TypeScript. Since 'endPointer' is not reassigned, it should be declared with 'const' for better immutability and modern TypeScript practices. The use of 'var' is discouraged in modern JavaScript/TypeScript due to its function-scoping behavior.
| var endPointer = getPointer(); | |
| const endPointer = getPointer(); |
| if (currentCommand != null && currentCommand.isFinished()) { | ||
| currentCommand.end(false); | ||
| currentCommand = null; | ||
| defaultCommand.initialize(); |
There was a problem hiding this comment.
Potential NullPointerException. When transitioning from a finished currentCommand to the defaultCommand, the code calls defaultCommand.initialize() without checking if defaultCommand is null. Although the constructor initializes defaultCommand to a non-null value, it's possible for external code to set it to null through setDefaultCommand. Add a null check before calling initialize() to prevent potential crashes.
| ensureUnitsFile(); | ||
| if (hasImportedUnits) return; | ||
| hasImportedUnits = true; | ||
| // TODO: add import statement to the output for the units file if it hasn't been added already |
There was a problem hiding this comment.
Outdated TODO comment. The TODO states "add import statement to the output for the units file if it hasn't been added already", but the code immediately following (lines 822-825) already implements this functionality by appending the import statement to the output. This TODO comment should be removed as the task is complete.
|
PSA for anyone else wondering why I requested an additional copilot review: if you use the VSCode GitHub extension to update the list of reviewers, it seems like it re-requests reviews from those whose check-boxes you leave checked, even if they were already on the list. |
aidnem
left a comment
There was a problem hiding this comment.
I didn't make it all the way through this but I have to go so I'll go ahead and leave the comments that I have so far.
| @@ -0,0 +1,71 @@ | |||
| export class Unit { | |||
There was a problem hiding this comment.
Do these need to be in the deploy folder? It's not a huge deal but we are technically sending these files to the robot whenever we deploy.
| "maxAcceptedDistanceMeters": 10, | ||
| "linearStdDevFactor": 0.0014, | ||
| "angularStdDevFactor": 0.001, | ||
| "linearStdDevFactor": 0.014, |
There was a problem hiding this comment.
We may want to examine whether our jitter is caused by std devs or by slightly incorrect camera offsets/field element locations before we commit this change. Do you remember if it made it noticeably better?
There was a problem hiding this comment.
I don't remember, but I do remember when there was less light the lower std devs were really inconsistent
| } | ||
|
|
||
| public static void loadAutos() { | ||
| autos = Optional.ofNullable(jsonHandler.getObject(new Autos(), AUTOS_PATH.toString())); |
There was a problem hiding this comment.
Should we publish an auto chooser here?
|
@avidraccoon what's the status of this? Can we work on getting this merged soon? |
|
@avidraccoon could you work on @aidnem comments. I'd also like to review this when it's close getting merged. |
…in AutoAction and JSON representations; adjust related constants in field location files
…ences in related classes
… AutoPilotAction using Optional
…ut; add Print action for console logging
…t command handling and chaining methods
…te' of https://github.com/team401/2026-Robot-Code into 65-refactor-drivecoordinator-and-add-drive-to-climb-state
…enhance serialization logic
…ess, and enhance serialization logic
…ce readability, and streamline command handling
…ve property and update target handling logic; introduce new Velocity unit type and related constants; update hood state machine diagram with new TargetExitPitchState
…g, support PerUnit naming, and improve measure name generation; clean up unused imports in ControllerSetup
This pull request introduces a new TypeScript-based auto-generation system for robot autonomous routines, including infrastructure for compiling, registering, and serializing auto actions, as well as updates to field and drive constants. The most important changes are grouped below:
Auto Generator System Implementation
auto_generatordirectory with TypeScript configuration (tsconfig.json), build scripts (compile_autos.mjs,run_autos.mjs), and supporting files for compiling and running auto routines. This includes a sample auto routine (newTestAuto.ts) and utility modules (AutoLib.ts,Shorthands.ts). [1] [2] [3] [4] [5] [6] [7]AutoAction.tsto represent auto actions, targets, profiles, gains, and related types for serialization and execution.Auto Serialization and Output
Autos.jsonfile insrc/main/deploycontaining serialized auto routines, such as the "Random Auto" sequence for testing.Field and Drive Constants Updates
DriveConstants.jsonfiles to includedefaultAutoPilotHeadingGains, providing default PID gains for autopilot heading control in both competition and test drivebase configurations. [1] [2]BlueFieldLocations.jsonandRedFieldLocations.json, specifying translation and rotation for left and right climb positions. [1] [2]Vision and Controller Configuration
VisionConstants.jsonfor the test drivebase, increasing the standard deviation factors.vision-sample.json) and updated controller bindings incontrollers-xbox.jsonto include a new test command. [1] [2]Miscellaneous
.gitignoreentries fornode_modulesanddistto theauto_generatordirectory.