-
Notifications
You must be signed in to change notification settings - Fork 111
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
[RSDK-746] Return the power percent when checking if a motor is powered #1492
Conversation
This PR is larger than I'd prefer, but I didn't see an obvious way to split it up into smaller pieces. Next time, what should I do differently? |
👀 Running |
components/motor/collectors.go
Outdated
@@ -58,7 +58,7 @@ func newIsPoweredCollector(resource interface{}, params data.CollectorParams) (d | |||
} | |||
|
|||
cFunc := data.CaptureFunc(func(ctx context.Context, _ map[string]*anypb.Any) (interface{}, error) { | |||
v, err := motor.IsPowered(ctx, nil) | |||
v, _, err := motor.IsPowered(ctx, nil) |
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.
Are we not collecting the powerPct in the collector?
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 plead ignorance! What's a collector? I didn't understand what this file was for, so made the minimum change that wouldn't affect any behavior.
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.
Well, I've taken a stab at updating the collector to track the new value, too. LMK if I should have done something different.
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.
LGTM! just left two comments most important IMO is whether or not we need to collect the powerPct in the collector
|
I'm a little nervous that there are so many different implementations of this feature across different motors, and maybe there was a simpler or more consistent thing to do. The general idea here is that the
Motor
interface'sIsPowered
now returns the power level in addition to a boolean and a possible error. This is then used to populate the newpowerPct
field in theIsPoweredResponse
protobuf.The changes to go.mod and go.sum are intended to pick up viamrobotics/api#70.
Most of the motors didn't have an obvious way to get the power percent, so I started storing that in the relevant structs, updating that on a
SetPower
call, and returning whatever had been set.Despite all the tests passing, I have low confidence that I've done this right. What if I forgot to update the stored percent in a certain place? What if I updated it but a subsequent error means it's not actually set in the hardware? What if this PR is so big that everyone's eyes glaze over before they reach the end and we all miss an important bug?
What can I do to gain confidence that this change was done correctly?