Skip to content

Remove use of mutable measures - #677

Open
stephenjust wants to merge 2 commits into
mainfrom
remove-mut-measure
Open

Remove use of mutable measures#677
stephenjust wants to merge 2 commits into
mainfrom
remove-mut-measure

Conversation

@stephenjust

Copy link
Copy Markdown
Contributor

WPILib 2027 removes the concept of mutable measures, so now is a good time to clean these up.

WPILib 2027 removes the concept of mutable measures, so now is a good time to clean these up.
Copilot AI review requested due to automatic review settings July 30, 2026 03:11
@stephenjust
stephenjust requested a review from a team as a code owner July 30, 2026 03:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates SeriouslyCommonLib to stop relying on WPILib “mutable measure” types (e.g., MutAngle, MutableMeasure) in preparation for their removal in WPILib 2027, shifting code to use immutable Measure instances and Units.*.zero() helpers.

Changes:

  • Replaced Mut* measure fields/usages with immutable Measure types (e.g., Angle, AngularVelocity, Distance, Voltage) across subsystems, mocks, and configs.
  • Simplified MeasureProperty and its subclasses to remove the mutable-measure generic parameter and replace in-place mutation with assignment.
  • Standardized several “zero” initializations to Units.*.zero().

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/java/xbot/common/subsystems/pose/BasePoseSubsystem.java Replaces MutAngle heading tracking with immutable Angle assignments.
src/main/java/xbot/common/properties/MeasureProperty.java Removes MutableMeasure usage and updates value tracking/log refresh to use immutable measures.
src/main/java/xbot/common/properties/TimeProperty.java Updates property type to match new MeasureProperty generics (no mutable measure type).
src/main/java/xbot/common/properties/DistanceProperty.java Updates property type to match new MeasureProperty generics (no mutable measure type).
src/main/java/xbot/common/properties/AngularVelocityProperty.java Updates property type to match new MeasureProperty generics (no mutable measure type).
src/main/java/xbot/common/properties/AngleProperty.java Updates property type to match new MeasureProperty generics (no mutable measure type).
src/main/java/xbot/common/injection/electrical_contract/SparkMaxMotorControllerOutputConfig.java Switches RPM initialization to RPM.zero().
src/main/java/xbot/common/controls/sensors/wpi_adapters/LaserCANWpiAdapter.java Switches distance fallback initialization to Meters.zero().
src/main/java/xbot/common/controls/sensors/mock_adapters/MockCANCoder.java Replaces mutable measure fields with immutable Angle/AngularVelocity assignments.
src/main/java/xbot/common/controls/actuators/XCANMotorController.java Uses Volts.zero() in limit checks for consistency with immutable measures.
src/main/java/xbot/common/controls/actuators/mock_adapters/MockCANMotorController.java Replaces mutable voltage/current/position/velocity state with immutable measure assignments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/xbot/common/properties/MeasureProperty.java

@aschokking aschokking left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The reason we moved to these was to address memory pressure from creating tons and tons of immutable objects along the way. Do we maybe need to do something like mutable ourselves with internal doubles more? Or maybe the memory pressure won't be a thing on the newer hardware?

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