-
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-869] Allow for servo to turn more than 180 #1624
Conversation
@@ -193,7 +190,7 @@ func newGPIOServo(ctx context.Context, deps registry.Dependencies, cfg config.Co | |||
var _ = servo.LocalServo(&servoGPIO{}) | |||
|
|||
// Given minUs, maxUs, deg and frequency attempt to calculate the corresponding duty cycle pct. | |||
func mapDegToDutyCylePct(minUs, maxUs uint, deg float64, frequency uint) float64 { | |||
func mapDegToDutyCylePct(minUs, maxUs uint, minDeg, maxDeg, deg float64, frequency uint) float64 { |
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 these also be functions on the servo object and use the stored servo variables? Would it be less/more boiler plate? Otherwise looks good to me.
Let's test with a few servos in office when you're back. |
} | ||
if config.MaxDeg != nil && *config.MaxDeg > maxDeg { | ||
return nil, viamutils.NewConfigValidationError(path, errors.Errorf("max_angle_deg cannot be higher than %f", maxDeg)) | ||
if config.MinDeg != nil && *config.MinDeg < 0 { |
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 used to be a corresponding check for MaxDeg, but it's now gone. Shouldn't it still be here, modified in a similar way to the MinDeg check?
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.
we don't enforce an upper limit for maxDeg since it's dependent on the hardware. in theory we should also ignore the test minDeg and let a user set a negative minimum deg
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.
...so why not do that, too? (i.e., why not get rid of this check and allow a negative minimum value?)
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!
Does this count as a breaking change? I'm inclined to say no, but I want a second opinion on that. |
It's only semantically breaking in the slightest way and only specific to go; you'd have to assume you are expecting errors to happen above 180 and you may be testing/working against that. I think that's an okay breaking change to make. API wise, it's not in proto as @npmenard mentioned and widening an integral type is also not breaking. |
|
This PR slightly change the gpio servo model to support servo that rotates more than 180 degrees. I needed to change the types in the servo interface because we use to encode servo position in an uint8. Note that this doesn't affect API since the degree value passed in protobuf messages is a uint32