Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Daniel1464
Copy link

Resolves #6285.

@Daniel1464 Daniel1464 requested a review from a team as a code owner October 7, 2024 00:52
@Daniel1464
Copy link
Author

/format

Comment on lines +64 to +66
* The value is recorded in volts by default;
* to change this, specify your target unit as a generic bound.
*
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* 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.

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

@spacey-sooty spacey-sooty Oct 28, 2024

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.

(which could be done already via implicit conversions)

I don't think this is true? See #6315 and #6314

Copy link
Contributor

@KangarooKoala KangarooKoala Oct 28, 2024

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)

I don't think this is true? See #6315 and #6314

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.

Copy link
Member

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

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say yes

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.

SysID MotorLog Overloads or Reworks
4 participants