-
Notifications
You must be signed in to change notification settings - Fork 0
Add reusable libraries from 2025 codebase #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
AdamEXu
commented
Jan 15, 2026
- Add CustomMath utility (trajectory, angles, matrices, deadband)
- Add AlignmentPoints framework for field-relative positioning
- Add PigeonGyro and AHRSGyro hardware abstractions
- Update vendordeps to 2026 versions (Phoenix6, REVLib, AdvantageKit)
- Add EJML dependency for matrix operations
- Add CustomMath utility (trajectory, angles, matrices, deadband) - Add AlignmentPoints framework for field-relative positioning - Add PigeonGyro and AHRSGyro hardware abstractions - Update vendordeps to 2026 versions (Phoenix6, REVLib, AdvantageKit) - Add EJML dependency for matrix operations
build.gradle
Outdated
| implementation "com.google.protobuf:protobuf-java:3.22.2" | ||
|
|
||
| // Math utilities for CustomMath matrix operations | ||
| implementation 'org.ejml:ejml-all:0.41' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed in the codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds reusable utility libraries and hardware abstractions from a 2025 codebase, and updates vendor dependencies to 2026 versions.
Changes:
- Add CustomMath utility library with trajectory generation, angle operations, matrix transformations, and deadband functions
- Add AlignmentPoints framework for managing field-relative positioning with alliance mirroring
- Add PigeonGyro and AHRSGyro hardware abstraction classes
- Update vendordeps (Phoenix6 26.1.0, REVLib 2026.0.0, Phoenix5 5.36.0, AdvantageKit 26.0.0)
- Add EJML 0.41 dependency for matrix operations
- Clean up Python code: remove unused function, improve type safety, and refactor deployment logic
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| vendordeps/REVLib.json | New REVLib 2026.0.0 with additional backend driver dependencies |
| vendordeps/REVLib-2025.0.2.json | Removed old 2025.0.2 version |
| vendordeps/Phoenix6-26.1.0.json | New Phoenix6 26.1.0 with updated sim artifacts |
| vendordeps/Phoenix6-25.2.2.json | Removed old 25.2.2 version |
| vendordeps/Phoenix5-5.36.0.json | Updated to 5.36.0 for 2026 season |
| vendordeps/Phoenix5-5.35.1.json | Removed old 5.35.1 version |
| vendordeps/AdvantageKit.json | Updated to version 26.0.0 |
| src/main/java/frc/robot/util/CustomMath.java | New math utility library with trajectory, angle, and matrix operations |
| src/main/java/frc/robot/util/AlignmentPoints.java | New field positioning framework with alliance mirroring |
| src/main/java/frc/robot/hardware/PigeonGyro.java | Hardware abstraction for CTRE Pigeon2 gyro |
| src/main/java/frc/robot/hardware/AHRSGyro.java | Hardware abstraction for NavX AHRS gyro |
| src/main/java/frc/robot/RobotContainer.java | Added controller declarations and imports |
| src/backend/python/common/debug/logger.py | Removed unused stats_for_nerds_akit function |
| src/backend/python/common/camera/image_utils.py | Improved type safety with MatLike cast and error handling |
| src/backend/python/common/camera/abstract_camera.py | Removed unnecessary type conversion logic |
| src/backend/deployment/util.py | Refactored deployment: removed sudo from mkdir, moved cleanup to correct location, fixed Rust binary path |
| build.gradle | Added EJML 0.41 dependency for matrix operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import java.util.stream.Collectors; | ||
|
|
||
| import org.ejml.simple.SimpleMatrix; | ||
| import org.pwrup.util.Vec2; |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import org.pwrup.util.Vec2 is present but the Vec2 class is never used in this file. This will cause a compilation error if the dependency is not available. Remove this unused import.
| import org.pwrup.util.Vec2; |
| import edu.wpi.first.math.trajectory.Trajectory; | ||
| import edu.wpi.first.math.trajectory.TrajectoryConfig; | ||
| import edu.wpi.first.math.trajectory.TrajectoryGenerator; | ||
| import proto.pathfind.Pathfind.PathfindResult; |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import proto.pathfind.Pathfind.PathfindResult is used in method signatures but this proto file may not exist in the codebase yet. This will cause a compilation error. Either ensure this proto file exists or remove methods that depend on it (lines 24-28, 30-47).
| import java.util.function.Supplier; | ||
|
|
||
| import edu.wpi.first.math.geometry.Pose2d; | ||
| import edu.wpi.first.wpilibj2.command.Command; | ||
| import edu.wpi.first.wpilibj2.command.InstantCommand; |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The imports Supplier, Pose2d, and InstantCommand are not used anywhere in the visible code. Remove these unused imports to keep the code clean.
| import java.util.function.Supplier; | |
| import edu.wpi.first.math.geometry.Pose2d; | |
| import edu.wpi.first.wpilibj2.command.Command; | |
| import edu.wpi.first.wpilibj2.command.InstantCommand; | |
| import edu.wpi.first.wpilibj2.command.Command; |
| import edu.wpi.first.wpilibj2.command.Command; | ||
|
|
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Command import appears twice (lines 6 and 14). Remove the duplicate import on line 14.
| import edu.wpi.first.wpilibj2.command.Command; |
| return currentSetpoint += maxRamp; | ||
| } else if (setpoint - currentSetpoint < -maxRamp) { | ||
| return currentSetpoint -= maxRamp; | ||
| } | ||
| return currentSetpoint = setpoint; |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using assignment within return statements (lines 297, 299, 301) is confusing and modifies the parameter which has no effect since Java passes primitives by value. These assignments to currentSetpoint parameter are misleading. Change to: return currentSetpoint + maxRamp, return currentSetpoint - maxRamp, and return setpoint.
| return currentSetpoint += maxRamp; | |
| } else if (setpoint - currentSetpoint < -maxRamp) { | |
| return currentSetpoint -= maxRamp; | |
| } | |
| return currentSetpoint = setpoint; | |
| return currentSetpoint + maxRamp; | |
| } else if (setpoint - currentSetpoint < -maxRamp) { | |
| return currentSetpoint - maxRamp; | |
| } | |
| return setpoint; |
| in += 1; | ||
| } | ||
| return in; | ||
| // return ((in + 0.5) % 1) - 0.5; |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commented-out code on line 103 should be removed. If this is an alternative implementation, document why the current implementation is preferred or remove it entirely.
| // return ((in + 0.5) % 1) - 0.5; |
| * Set the default CAN ID used by GetInstance(). | ||
| * Call this before the first call to GetInstance(). | ||
| */ | ||
| public static void setDefaultCanId(int canId) { | ||
| defaultCanId = canId; | ||
| } | ||
|
|
||
| public static PigeonGyro GetInstance() { |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method name GetInstance() does not follow Java naming conventions. It should be getInstance() with a lowercase 'g'. Same issue exists in AHRSGyro.java line 42.
| * Set the default CAN ID used by GetInstance(). | |
| * Call this before the first call to GetInstance(). | |
| */ | |
| public static void setDefaultCanId(int canId) { | |
| defaultCanId = canId; | |
| } | |
| public static PigeonGyro GetInstance() { | |
| * Set the default CAN ID used by getInstance(). | |
| * Call this before the first call to getInstance(). | |
| */ | |
| public static void setDefaultCanId(int canId) { | |
| defaultCanId = canId; | |
| } | |
| public static PigeonGyro getInstance() { |
| str(getattr(pi, "port", 22)), | ||
| f"ubuntu@{pi.address}", | ||
| f"sudo mkdir -p {remote_target_dir}", | ||
| f"mkdir -p {remote_target_dir}", |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed sudo from the mkdir command. This could cause permission errors if the user doesn't have write access to the parent directory. Ensure the ubuntu user has appropriate permissions or consider keeping sudo for directory creation.
| f"mkdir -p {remote_target_dir}", | |
| f"sudo mkdir -p {remote_target_dir}", |
| ) | ||
| if decoded is None: | ||
| raise ValueError( | ||
| f"Failed to decode JPEG image (format={proto_image.format}, bytes={len(proto_image.image)})" |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message on lines 68-70 references proto_image.format which is an enum. Consider using proto_image.format.name or a more descriptive format representation for better debugging.
| f"Failed to decode JPEG image (format={proto_image.format}, bytes={len(proto_image.image)})" | |
| f"Failed to decode JPEG image (format={ImageFormat.Name(proto_image.format)}, bytes={len(proto_image.image)})" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong. the /deployment folder should not be replaced from the base command-robot-base
| final FlightModule m_flightModule = new FlightModule( | ||
| m_leftFlightStick, | ||
| m_rightFlightStick); | ||
| private Boolean isNonFieldRelative = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed only used for a specific application of swerve drive being non field relative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not strictly needed. I'd start with a clean slate ngl. jst remove the functions that aren't used anywhere in the base codebase
|
@copilot explain changes godbrigero made after my initial commit |