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

Servo enhancements #419

Open
lurch opened this Issue Aug 31, 2016 · 4 comments

Comments

Projects
None yet
4 participants
@lurch
Contributor

lurch commented Aug 31, 2016

After much discussion (in #248 ), a minimal-version of a Servo class was added in release v1.3.0 of GpioZero.

However it doesn't include everything that people had been asking for, so this is a new 'clean' issue for people to discuss adding things they might want... (see #248 for possible inspiration).

@lurch lurch referenced this issue Aug 31, 2016

Closed

Add Servo #248

@lurch

This comment has been minimized.

Show comment
Hide comment
@lurch

lurch Sep 19, 2016

Contributor

I bought a (cheap) continuous-rotation servo recently, and as I suspected, a centre-value keeps it still, negative values determine the speed in one direction, and positive values determine the speed in the opposite direction. Each output-value results in a fixed speed, with larger values giving bigger speeds. So perhaps a ContinuousRotationServo class should have an API similar to Motor? Unlike with a motor you can't reverse the rotation-direction of a servo by swapping wires over (#380), so it'll also need an invert_direction or active_high init-parameter.

Contributor

lurch commented Sep 19, 2016

I bought a (cheap) continuous-rotation servo recently, and as I suspected, a centre-value keeps it still, negative values determine the speed in one direction, and positive values determine the speed in the opposite direction. Each output-value results in a fixed speed, with larger values giving bigger speeds. So perhaps a ContinuousRotationServo class should have an API similar to Motor? Unlike with a motor you can't reverse the rotation-direction of a servo by swapping wires over (#380), so it'll also need an invert_direction or active_high init-parameter.

@waveform80

This comment has been minimized.

Show comment
Hide comment
@waveform80

waveform80 Sep 26, 2016

Member

... Unlike with a motor you can't reverse the rotation-direction of a servo by swapping wires over (#380), so it'll also need an invert_direction or active_high init-parameter.

Interesting. In AngularServo I noted some servos go clockwise with greater pulse widths while some go counter-clockwise. To enable both to be represented by the same angle measurements, I permitted min_angle to be greater than max_angle in the constructor. Example:

>>> clockwise_servo = Servo(21, min_angle=-45, max_angle=45)
>>> counter_clockwise_servo = Servo(20, min_angle=45, max_angle=-45)
>>> clockwise_servo.angle = 30
>>> counter_clockwise_servo.angle = 30

At this point both servos should be pointing to the same angle. If (and this is another big question) we have some sub-class of Servo for continuous-rotation servos that permits a certain rpm to be specified, we could pull the same trick of allowing min and max to be inverted. Not sure how intuitive this stuff is though (or if my current design for AngularServo is intuitive either ... but then "min" and "max" are pretty vague concepts in the context of angular position, unlike rotational speed which is more clear cut).

Member

waveform80 commented Sep 26, 2016

... Unlike with a motor you can't reverse the rotation-direction of a servo by swapping wires over (#380), so it'll also need an invert_direction or active_high init-parameter.

Interesting. In AngularServo I noted some servos go clockwise with greater pulse widths while some go counter-clockwise. To enable both to be represented by the same angle measurements, I permitted min_angle to be greater than max_angle in the constructor. Example:

>>> clockwise_servo = Servo(21, min_angle=-45, max_angle=45)
>>> counter_clockwise_servo = Servo(20, min_angle=45, max_angle=-45)
>>> clockwise_servo.angle = 30
>>> counter_clockwise_servo.angle = 30

At this point both servos should be pointing to the same angle. If (and this is another big question) we have some sub-class of Servo for continuous-rotation servos that permits a certain rpm to be specified, we could pull the same trick of allowing min and max to be inverted. Not sure how intuitive this stuff is though (or if my current design for AngularServo is intuitive either ... but then "min" and "max" are pretty vague concepts in the context of angular position, unlike rotational speed which is more clear cut).

@lurch

This comment has been minimized.

Show comment
Hide comment
@lurch

lurch Sep 26, 2016

Contributor

Sorry, the invert_direction comment was only targeted at a possible ContinuousRotationServo class, as I was imagining it'd have forward(speed) and backward(speed) (and stop()) methods, like Motor does. (Which, if my MotorMixin idea ever comes to fruition, would allow a Robot to be constructed from two ContinuousRotationServos)

P.S. I guess you meant AngularServo instead of Servo in your example code above?

Contributor

lurch commented Sep 26, 2016

Sorry, the invert_direction comment was only targeted at a possible ContinuousRotationServo class, as I was imagining it'd have forward(speed) and backward(speed) (and stop()) methods, like Motor does. (Which, if my MotorMixin idea ever comes to fruition, would allow a Robot to be constructed from two ContinuousRotationServos)

P.S. I guess you meant AngularServo instead of Servo in your example code above?

@ivansager

This comment has been minimized.

Show comment
Hide comment
@ivansager

ivansager Mar 8, 2017

A ContinuousRotationServo class would help a great deal!

ivansager commented Mar 8, 2017

A ContinuousRotationServo class would help a great deal!

@bennuttall bennuttall removed the RFC label Feb 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment