Skip to content

Conversation

zachwaffle4
Copy link

this is also trivial to implement but for situations where we want to be unit-safe it would be nice to not have to define an interpolator and inverse interpolator every time we want an interpolator map with a measure

@zachwaffle4 zachwaffle4 requested a review from a team as a code owner August 15, 2025 09:08
@github-actions github-actions bot added component: wpimath Math library 2027 2027 target labels Aug 15, 2025
@calcmogul calcmogul changed the title [math] add interpolators for measures [wpimath] add interpolators for measures Aug 15, 2025
@calcmogul calcmogul changed the title [wpimath] add interpolators for measures [wpimath] Add interpolators for measures Aug 15, 2025
Comment on lines 57 to 63
table.put(Units.Inches.of(Units.Meters.of(125.0).in(Units.Inches)), Units.Meters.of(450.0));
table.put(Units.Meters.of(200.0), Units.Feet.of(Units.Meters.of(510.0).in(Units.Feet)));
table.put(
Units.Centimeters.of(Units.Meters.of(268.0).in(Units.Centimeters)),
Units.Meters.of(525.0));
table.put(
Units.Inches.of(Units.Meters.of(312.0).in(Units.Inches)),
Units.Feet.of(Units.Meters.of(550.0).in(Units.Feet)));
table.put(Units.Meters.of(326.0), Units.Meters.of(650.0));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why doesn't this just use Units.Meters.of()?

Copy link
Author

Choose a reason for hiding this comment

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

to confirm it works properly if it is constructed with different units

Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't feel like a super clear way to do that, but I guess it works. Maybe just add a comment to explain it?

@zachwaffle4 zachwaffle4 requested review from a team and PeterJohnson as code owners September 24, 2025 00:42
@github-actions github-actions bot added component: ntcore NetworkTables library component: wpiutil WPI utility library component: wpilibj WPILib Java component: wpilibc WPILib C++ component: hal Hardware Abstraction Layer component: command-based WPILib Command Based Library component: glass Glass app and backend component: wpinet WPI networking library component: examples component: wpiunits Java units library component: epilogue Annotation-based logging library labels Sep 24, 2025
…eeMapTest (and then delete InterpolatingMeasuresTreeMapTest)

Signed-off-by: Zach Harel <[email protected]>
… of star import for consistency

Signed-off-by: Zach Harel <[email protected]>
…ods in Interpolator and InverseInterpolator

Signed-off-by: Zach Harel <[email protected]>
…Util and update tests accordingly

Signed-off-by: Zach Harel <[email protected]>
@github-actions github-actions bot removed component: ntcore NetworkTables library component: wpiutil WPI utility library component: wpilibj WPILib Java component: wpilibc WPILib C++ component: hal Hardware Abstraction Layer component: command-based WPILib Command Based Library component: glass Glass app and backend component: wpinet WPI networking library component: examples component: wpiunits Java units library component: epilogue Annotation-based logging library labels Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2027 2027 target component: wpimath Math library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants