You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Make motor rotation sensor reset optional #389
Is your feature request related to a problem? Please describe.
When building robots with gears, the absolute angle feature cannot really be used. Instead, you usually have to run some initialization routine to reset the mechanism, to make your own "absolute" zero point.
It would be nice if you needed to run this only once after boot, instead of every time a program starts.
Describe the solution you'd like
When you initialize a motor, we implicitly call reset_angle(), so that it resets to the angle of the absolute marker. We could make this optional. Then the angle offset would be unchanged between programs.
Proposed API: Add a reset_angle keyword argument to the Motor class init, and let it default to True so it is fully backwards compatible.
I've been using this in practice for some time, and it's really useful. I think it's worth committing.
A second potential benefit is that you can diagnose problems in a new REPL or something like port view, if we ever have that feature.
In the long run, we should be able to cut the implementation size a bit by not having to pass the argument all the way down, but we can look at this when we overhaul the way we deal with ports in general.
Activity
pbio/servo: Make angle reset optional.
pybricks.common.Motor: Make angle reset optional.
pbio/servo: Make angle reset optional.
laurensvalk commentedon Jul 13, 2021
I've been using this in practice for some time, and it's really useful. I think it's worth committing.
A second potential benefit is that you can diagnose problems in a new REPL or something like port view, if we ever have that feature.
In the long run, we should be able to cut the implementation size a bit by not having to pass the argument all the way down, but we can look at this when we overhaul the way we deal with ports in general.
laurensvalk commentedon Jul 16, 2021
Already implemented via pybricks/pybricks-micropython@4d6d172, so closing.
pybricks.pupdevices.Motor: Add reset_angle kwarg.