Class SmartMotorControllerCommandRegistry

java.lang.Object
yams.commands2.telemetry.SmartMotorControllerCommandRegistry

public class SmartMotorControllerCommandRegistry extends Object
Registry for WPILib Command instances associated with a SmartMotorController. Mechanisms register setpoint commands here so the scheduler can manage them.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addCommand(String cmdName, org.wpilib.command2.Subsystem subsystem, Runnable callback)
    Add a command to the registry.
    static void
    addCommand(String cmdName, org.wpilib.command2.Subsystem subsystem, Runnable callback, Runnable onEnd)
    Add a command to the registry, with a Runnable run when the shared command ends.
    static boolean
    commandExists(String cmdName, org.wpilib.command2.Subsystem subsystem)
    Check if a command exists.
    static Optional<org.wpilib.command2.Command>
    getCommand(String cmdName, org.wpilib.command2.Subsystem subsystem)
    Get a registered command, such as the "Live Tuning" command, to schedule it from code.
    static void
    removeCommands(org.wpilib.command2.Subsystem subsystem)
    Remove all commands registered for the given subsystem instance.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • addCommand

      public static void addCommand(String cmdName, org.wpilib.command2.Subsystem subsystem, Runnable callback)
      Add a command to the registry.
      Parameters:
      cmdName - Command name to publish to NetworkTables.
      subsystem - Subsystem to create the command for.
      callback - Runnable to be added to the shared command.
      Throws:
      IllegalStateException - if a different Subsystem instance with the same name has already registered a command under cmdName.
    • addCommand

      public static void addCommand(String cmdName, org.wpilib.command2.Subsystem subsystem, Runnable callback, Runnable onEnd)
      Add a command to the registry, with a Runnable run when the shared command ends.
      Parameters:
      cmdName - Command name to publish to NetworkTables.
      subsystem - Subsystem to create the command for.
      callback - Runnable to be added to the shared command.
      onEnd - Runnable run when the shared command ends.
      Throws:
      IllegalStateException - if a different Subsystem instance with the same name has already registered a command under cmdName.
    • getCommand

      public static Optional<org.wpilib.command2.Command> getCommand(String cmdName, org.wpilib.command2.Subsystem subsystem)
      Get a registered command, such as the "Live Tuning" command, to schedule it from code.
      Parameters:
      cmdName - Command name.
      subsystem - Subsystem the command was registered for.
      Returns:
      The command, or empty if none is registered under cmdName.
    • commandExists

      public static boolean commandExists(String cmdName, org.wpilib.command2.Subsystem subsystem)
      Check if a command exists.
      Parameters:
      cmdName - Command name.
      subsystem - Subsystem.
      Returns:
      True if command exists.
    • removeCommands

      public static void removeCommands(org.wpilib.command2.Subsystem subsystem)
      Remove all commands registered for the given subsystem instance.

      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.

      Parameters:
      subsystem - Subsystem whose commands should be removed.