Skip to content

65 refactor drivecoordinator and add drive to climb state#70

Draft
avidraccoon wants to merge 105 commits intomainfrom
65-refactor-drivecoordinator-and-add-drive-to-climb-state
Draft

65 refactor drivecoordinator and add drive to climb state#70
avidraccoon wants to merge 105 commits intomainfrom
65-refactor-drivecoordinator-and-add-drive-to-climb-state

Conversation

@avidraccoon
Copy link
Contributor

@avidraccoon avidraccoon commented Feb 20, 2026

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

  • Added a new auto_generator directory 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]
  • Introduced a comprehensive set of classes in AutoAction.ts to represent auto actions, targets, profiles, gains, and related types for serialization and execution.

Auto Serialization and Output

  • The system now generates a single Autos.json file in src/main/deploy containing serialized auto routines, such as the "Random Auto" sequence for testing.

Field and Drive Constants Updates

  • Updated DriveConstants.json files to include defaultAutoPilotHeadingGains, providing default PID gains for autopilot heading control in both competition and test drivebase configurations. [1] [2]
  • Added climb locations to BlueFieldLocations.json and RedFieldLocations.json, specifying translation and rotation for left and right climb positions. [1] [2]

Vision and Controller Configuration

  • Adjusted vision gain constants in VisionConstants.json for the test drivebase, increasing the standard deviation factors.
  • Added a sample vision configuration file (vision-sample.json) and updated controller bindings in controllers-xbox.json to include a new test command. [1] [2]

Miscellaneous

  • Added .gitignore entries for node_modules and dist to the auto_generator directory.

Theta Back and others added 30 commits February 11, 2026 21:34
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
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +88 to +101
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;
}
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +531 to +533
if (Optional.class.isAssignableFrom(rawClass)) {
return "Partial<" + resolveType(args[0]) + ">";
}
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
…on; refactor auto commands to use new chaining method
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +172 to +173
// drive.setDriveGains(JsonConstants.driveConstants.driveGains);
// drive.setSteerGains(JsonConstants.driveConstants.steerGains);
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
if (field.isTypeScriptOptional) {
defaultValue = "undefined";
}
;
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty statement (lone semicolon) after the assignment on line 277. This semicolon on line 278 serves no purpose and should be removed.

Copilot uses AI. Check for mistakes.
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.
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +27
"radians": 0.0
},
"translation": {
"x": 0.0,
"y": 0.0
}
},
"rightClimbLocation": {
"rotation": {
"radians": 0.0
},
"translation": {
"x": 0.0,
"y": 0.0
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"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

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious as to where these numbers came from. They seem like they're at least on the right side of the field.

Comment on lines +21 to +28
"rightClimbLocation": {
"rotation": {
"radians": 0.0
},
"translation": {
"x": 15.0,
"y": 3.9
}
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +63 to +67
/**
* The active command is always has the periodic run currently before it checks if it is finished.
*
* @return
*/
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
if (command_pointers.length !== 1) {
throw new Error("Pointer stack is not empty after auto command");
}
var endPointer = getPointer();
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
var endPointer = getPointer();
const endPointer = getPointer();

Copilot uses AI. Check for mistakes.
if (currentCommand != null && currentCommand.isFinished()) {
currentCommand.end(false);
currentCommand = null;
defaultCommand.initialize();
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
ensureUnitsFile();
if (hasImportedUnits) return;
hasImportedUnits = true;
// TODO: add import statement to the output for the units file if it hasn't been added already
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@aidnem
Copy link
Contributor

aidnem commented Feb 25, 2026

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.

Copy link
Contributor

@aidnem aidnem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we publish an auto chooser here?

@aidnem
Copy link
Contributor

aidnem commented Feb 27, 2026

@avidraccoon what's the status of this? Can we work on getting this merged soon?

@godmar
Copy link
Contributor

godmar commented Mar 1, 2026

@avidraccoon could you work on @aidnem comments. I'd also like to review this when it's close getting merged.

avidraccoon and others added 15 commits March 2, 2026 08:28
…in AutoAction and JSON representations; adjust related constants in field location files
…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
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.

Refactor DriveCoordinator and add drive to climb state

4 participants