|
YAMS
Yet Another Mechanism System
|
#include <SmartMotorControllerCommandRegistry.hpp>
Static Public Member Functions | |
| static void | AddCommand (const std::string &cmdName, wpi::cmd::SubsystemBase *subsystem, std::function< void()> callback) |
| static void | AddCommand (const std::string &cmdName, wpi::cmd::SubsystemBase *subsystem, std::function< void()> callback, std::function< void()> onEnd) |
| static wpi::cmd::Command * | GetCommand (const std::string &cmdName, wpi::cmd::SubsystemBase *subsystem) |
| static bool | CommandExists (const std::string &cmdName, wpi::cmd::SubsystemBase *subsystem) |
| static void | RemoveCommands (wpi::cmd::SubsystemBase *subsystem) |
| static void | Clear () |
Registry that aggregates per-subsystem commands from multiple SmartMotorControllers.
When multiple SmartMotorControllers belong to the same subsystem (e.g. a dual-motor arm), each one registers its live-tuning callback here. The registry creates a single combined command per subsystem that runs all registered callbacks on every periodic loop.
The published SmartDashboard path is: Mechanisms/Commands/SubsystemName%/CommandName%
|
static |
Register a callback for a command on a subsystem.
If no command with this name exists for the subsystem yet, a new one is created and published to SmartDashboard. If one already exists, the callback is appended to it.
| cmdName | Display name for the command (e.g. "Live Tuning"). |
| subsystem | Subsystem that owns the command (used for requirement and naming). |
| callback | Runnable invoked each loop while the command is running. |
|
static |
Register a callback for a command on a subsystem, with a callback run when the command ends.
| cmdName | Display name for the command (e.g. "Live Tuning"). |
| subsystem | Subsystem that owns the command (used for requirement and naming). |
| callback | Runnable invoked each loop while the command is running. |
| onEnd | Runnable invoked when the command ends. |
|
static |
Destroy all registered commands and callbacks, and unpublish them from the Tuning tunables.
Must be called before program exit while WPILib's SendableRegistry is still alive, otherwise the CommandPtr destructors will attempt to lock an already-destroyed mutex and crash (SIGSEGV/exit 139).
|
static |
Check whether a command with the given name already exists for a subsystem.
| cmdName | Command name. |
| subsystem | Subsystem. |
|
static |
Get a registered command, such as the "Live Tuning" command, to schedule it from code.
| cmdName | Command name. |
| subsystem | Subsystem the command was registered for. |
|
static |
Remove all commands registered for a specific subsystem instance, and unpublish them from the Tuning tunables.
Call this when a subsystem is being torn down (e.g. between tests) so that a new instance with the same name can register without triggering the conflict check.
| subsystem | Subsystem whose commands should be removed. |