Control Manager¶
ControlManager was created to reduce the amount of boiler plate when
creating multiple “control modes” for a robot. Essentially, each driver wants
their own set of controls. For MagicRobot is is very easy, as each
controlmanager mode can be a component that then has variables injected.
However, adding all the control modes to the dashboard with a nice chooser,
detecting and handling changes can lead to a lot of boilerplate.
ControlManager allows us to reduce boilerplate by subclassing
ControlInterface and then initializing ControlManager
with the control interfaces, and it creates the chooser.
For even more code reducing magic, see decorator.with_ctrl_manager()
which when used with MagicRobot, completely removes all boilerplate
by managing the creation of a ControlManager and dispatching event
calls.
-
class
marsutils.controlmanager.ControlInterface[source]¶ Bases:
objectControlInterfaceis the base class that all interfaces must subclass to be used withControlManager.You must define a
_DISPLAY_NAME. This value will be displayed in the dashboard chooser. Optionally, you can define a_SORTvalue. The larger the value, the higher priority it will be given in the chooser.
-
class
marsutils.controlmanager.ControlManager(*interfaces, dashboard_key: Optional[str] = 'Control Mode')[source]¶ This class manages creating a dashboard chooser and the periodic calling of a series of “control interface” components.
Each control interface must subclass
ControlInterfaceand define_DISPLAY_NAME.Once this has been initalized with the list of interfaces, you must manually call every event function you want your components to recive, like “teleopPeridic” and “teleopInit” and they will be forwarded to the active interface
You can optionally define a
_SORTvalue for your interfaces. The larger the value, the higher priority it will be given in the chooser.If
dashboard_keyis None, then the control chooser will not be added automatically, use this if you are using the Shuffleboard API or want a different root path. The control chooser can be accessed fromcontrol_chooser