Skip to content

magicbot: Add tunable setter #133

Open
@auscompgeek

Description

@auscompgeek

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:
        ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions