-
Notifications
You must be signed in to change notification settings - Fork 125
Change comment of percentage in BatteryState.msg #276
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
base: rolling
Are you sure you want to change the base?
Conversation
For the BatteryState percentage to be correctly named, it should be in the range of 0-100. The current naming is misleading, as it suggests the percentage is in the range of 0-1, which is not a percentage, but a fraction. Signed-off-by: Rasmus Larsson <[email protected]>
Seems to me that Jenkins is failing internally for the build, maybe just a retriggering is enough? I also assume a comment shouldn't cause that :) |
The existing name + comment could indeed be confusing if you just see "percentage," but mentioning "0 to 100" is not correct, and changing the name isn't really trivial at this point. You could modify the comment to make it clearer that it is a ratio between 0 and 1: -float32 percentage # Charge percentage on 0 to 1 range (If unmeasured NaN)
+float32 percentage # Charge percentage as a ratio between 0 and 1 (If unmeasured NaN) |
Yeah, that's a infrastructure flake. You can retrigger it with (well I think you can do it, not sure): @ros-pull-request-builder retest this please |
@@ -40,7 +40,7 @@ float32 current # Negative when discharging (A) (If unmeasured NaN) | |||
float32 charge # Current charge in Ah (If unmeasured NaN) | |||
float32 capacity # Capacity in Ah (last full capacity) (If unmeasured NaN) | |||
float32 design_capacity # Capacity in Ah (design capacity) (If unmeasured NaN) | |||
float32 percentage # Charge percentage on 0 to 1 range (If unmeasured NaN) | |||
float32 percentage # Charge percentage on 0 to 100 range (If unmeasured NaN) |
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.
Or something like this?
float32 percentage # Charge percentage on 0 to 100 range (If unmeasured NaN) | |
float32 percentage # Charge percentage as a normalized value in the range [0.0, 1.0] (If unmeasured NaN) |
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.
Yeah, that works for me!
The issue isn't really the comment at all. The issue is that the variable is called When users unaware of this comment reads code using this, like happened to me a few days ago, it might just look like this:
and just reading this, I would assume percentage is literally a percentage. Only reason I really started looking into it was cause I was reading the source code for another project and got thrown off by an unexpected added |
I dunno if I was clear about what I mean, I think the variable name is more important to be correct than the comments and documentation around it, with that in mind I only see a couple options:
|
You were 100% clear, but like I said changing the name is not trivial, and I personally think it's not worth the headache. On the other hand, changing the comment to make this more obvious is totally doable.
Changing what the field represents (i.e., changing the range from [0, 1] to [0, 100]) while keeping the same name is not possible, because there is no way to ensure that downstream users "updated" their use of it. If you get a value of 0.95, how do you know whether this is 95% or 0.95%?
I don't think we would ever do a clean change like that unless it was a critical issue. We'd do something like a tick-tock deprecation, but that doesn't work well with interfaces.
But again I personally don't think it's worth it. |
Hmm, this could be another improvement proposal for ROS2 project then? :)
I would think it's worth it, cause right now, I would think downstream users using 0-100 already, only due to the naming itself, though I guess as soon as they tested it with established packages they would realize somethings off and they would read the docs. But, agree to disagree, in the end it's up to you maintainers, so I will leave it to you to do as you like 😄 |
Do you still want to proceed with improving the comment? |
For the BatteryState percentage to be correctly named, it should be in the range of 0-100. The current naming is misleading, as it suggests the percentage is in the range of 0-1, which is not a percentage, but a fraction.
Another option would be to change the name to
ratio
orcharge_level
and keep the value range to be 0-1, but that would be a breaking change.