-
Notifications
You must be signed in to change notification settings - Fork 611
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
Changed SysID methods to allow logging in custom units #7172
base: main
Are you sure you want to change the base?
Conversation
/format |
* The value is recorded in volts by default; | ||
* to change this, specify your target unit as a generic bound. | ||
* |
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 value is recorded in volts by default; | |
* to change this, specify your target unit as a generic bound. | |
* | |
* @tparam U The unit to log in. Defaults to volts. |
Specifying a target unit as a generic bound doesn't make sense- First, generic bound is a Java term, while in C++ the closest equivalent would be constraint. Second, a generic bound would be specified by the method, not something specified at the call site. Also, I think we require documentation for template parameters anyways, so there isn't as much of a need for a separate description.
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.
I think instead of using a generic it makes more sense to just change the unit in the function signature eg for lengths units::length_unit auto
which should alllow passing in any length
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.
Maybe? Remember that the goal isn't to be able to pass in any type (which could be done already via implicit conversions), it's to output in any type. Logging in whatever unit is passed in is possible, but I'm not sure if that'd necessarily be what users expect.
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.
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.
Logging in whatever unit is passed in is possible, but I'm not sure if that'd necessarily be what users expect.
Thats what I'd expect. It can be documented as well.
If that's the direction we want to go, then sure. (Just remember to change Java to match, which should be fairly trivial.)
(which could be done already via implicit conversions)
Yes, there are already implicit conversions. #6314 failed because you can't chain two implicit user-defined conversions in a row- There was an implicit user-defined conversion from units::degree_t
to units::radian_t
and another from units::radian_t
to Rotation2d
, but since at most one implicit user-defined conversion is allowed (see https://en.cppreference.com/w/cpp/language/implicit_conversion), the build failed when trying to do an implicit conversion from degrees to Rotation2d
. I'm not sure what #6315 is supposed to communicate.
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.
Instead of passing the desired unit as a template parameter, just have the user cast it themselves and use MotorLog& voltage(units::voltage_unit auto voltage) {
.
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.
Should the same be done for Java?
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.
I'd say yes
Resolves #6285.