Skip to content
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

[Feature] Make motor rotation sensor reset optional #389

Closed
laurensvalk opened this issue Jul 12, 2021 · 2 comments
Closed

[Feature] Make motor rotation sensor reset optional #389

laurensvalk opened this issue Jul 12, 2021 · 2 comments
Labels
enhancement New feature or request topic: motors Issues involving motors

Comments

@laurensvalk
Copy link
Member

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.

@laurensvalk laurensvalk added enhancement New feature or request topic: motors Issues involving motors labels Jul 12, 2021
laurensvalk added a commit to pybricks/pybricks-micropython that referenced this issue Jul 13, 2021
This allows the encoder offset to be preserved between consecutive scripts. It may also be useful to preserve values for  system uses like port view.

pybricks/support#389
laurensvalk added a commit to pybricks/pybricks-micropython that referenced this issue Jul 13, 2021
This adds a reset_angle=True keyword argument to the Motor class initialization.

Setting it to false allows the encoder offset to be preserved between consecutive scripts. This way, you'd need to reset robot mechanisms only once instead of every time you run a program.

pybricks/support#389
laurensvalk added a commit to pybricks/pybricks-micropython that referenced this issue Jul 13, 2021
This adds a `reset_angle=True` keyword argument to the Motor class
initializer. Setting it to false allows the encoder angle to be
preserved between consecutive scripts.

This way, you'd need to reset robot mechanisms only once instead of
every time you run a program.

pybricks/support#389
@laurensvalk
Copy link
Member Author

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
Copy link
Member Author

Already implemented via pybricks/pybricks-micropython@4d6d172, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic: motors Issues involving motors
Projects
None yet
Development

No branches or pull requests

1 participant