Skip to content

Conversation

@AdamEXu
Copy link

@AdamEXu 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'
Copy link
Collaborator

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

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

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;
Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
import org.pwrup.util.Vec2;

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

Copilot AI Jan 15, 2026

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

Copilot uses AI. Check for mistakes.
Comment on lines 3 to 7
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;
Copy link

Copilot AI Jan 15, 2026

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.

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

Copilot uses AI. Check for mistakes.
Comment on lines 14 to 15
import edu.wpi.first.wpilibj2.command.Command;

Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
import edu.wpi.first.wpilibj2.command.Command;

Copilot uses AI. Check for mistakes.
Comment on lines 297 to 301
return currentSetpoint += maxRamp;
} else if (setpoint - currentSetpoint < -maxRamp) {
return currentSetpoint -= maxRamp;
}
return currentSetpoint = setpoint;
Copy link

Copilot AI Jan 15, 2026

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.

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

Copilot uses AI. Check for mistakes.
in += 1;
}
return in;
// return ((in + 0.5) % 1) - 0.5;
Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
// return ((in + 0.5) % 1) - 0.5;

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +41
* 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() {
Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
* 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() {

Copilot uses AI. Check for mistakes.
str(getattr(pi, "port", 22)),
f"ubuntu@{pi.address}",
f"sudo mkdir -p {remote_target_dir}",
f"mkdir -p {remote_target_dir}",
Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
f"mkdir -p {remote_target_dir}",
f"sudo mkdir -p {remote_target_dir}",

Copilot uses AI. Check for mistakes.
)
if decoded is None:
raise ValueError(
f"Failed to decode JPEG image (format={proto_image.format}, bytes={len(proto_image.image)})"
Copy link

Copilot AI Jan 15, 2026

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.

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

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

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;
Copy link
Collaborator

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

Copy link
Collaborator

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

@AdamEXu
Copy link
Author

AdamEXu commented Jan 15, 2026

@copilot explain changes godbrigero made after my initial commit

Copy link

Copilot AI commented Jan 15, 2026

@AdamEXu I've opened a new pull request, #2, to work on those changes. Once the pull request is ready, I'll request review from you.

@godbrigero godbrigero merged commit 010c43d into main Jan 15, 2026
@godbrigero godbrigero deleted the adam/util-migration branch January 15, 2026 00:56
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.

3 participants