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

magicbot: Add tunable setter #133

Open
auscompgeek opened this issue Feb 24, 2019 · 0 comments
Open

magicbot: Add tunable setter #133

auscompgeek opened this issue Feb 24, 2019 · 0 comments
Labels
enhancement magicbot magicbot package

Comments

@auscompgeek
Copy link
Member

Slightly inspired by a planned feature in Oblarg's Oblog.

Idea: Add a convenient way of calling a setter over NT to magicbot.

Strawman:

  • A new decorator is added which is intended for methods of components (or the robot object).
  • Upon initialisation, magicbot will attach the method as an update listener on the relevant NT key. The key will be named according to the method name.
  • The method will only receive the value that was set to the key. No flags; KISS.
  • Similarly to the feedback decorator, a set_ prefix will be stripped from the name used for NT keys.
  • This should cooperate with both tunable and feedback.
  • An example of anticipated usage could be tuning PID loops on-the-fly on a SPARK MAX.

Usage would look like this:

class Component:
    @configurable
    def set_p(self, value) -> None:
        ...

An alternative interface may involve decorating with a method on a tunable:

class Component:
    p = tunable(1)

    @p.setter
    def set_p(self, value: float) -> None:
        ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement magicbot magicbot package
Projects
None yet
Development

No branches or pull requests

1 participant