Class SmartMotorControllerCommandRegistry

java.lang.Object
yams.commands3.telemetry.SmartMotorControllerCommandRegistry

public class SmartMotorControllerCommandRegistry extends Object
Registry for 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.command3.Mechanism mechanism, Runnable callback)
    Add a command to the registry.
    static void
    addCommand(String cmdName, org.wpilib.command3.Mechanism mechanism, 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.command3.Mechanism mechanism)
    Check if a command exists.
    static Optional<org.wpilib.command3.Command>
    getCommand(String cmdName, org.wpilib.command3.Mechanism mechanism)
    Get a registered command, such as the "Live Tuning" command, to schedule it from code.
    static void
    removeCommands(org.wpilib.command3.Mechanism mechanism)
    Remove all commands registered for the given mechanism 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.command3.Mechanism mechanism, Runnable callback)
      Add a command to the registry.
      Parameters:
      cmdName - Command name to publish to NetworkTables.
      mechanism - Mechanism to create the command for.
      callback - Runnable to be added to the shared command.
      Throws:
      IllegalStateException - if a different Mechanism instance with the same name has already registered a command under cmdName.
    • addCommand

      public static void addCommand(String cmdName, org.wpilib.command3.Mechanism mechanism, 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.
      mechanism - Mechanism 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 Mechanism instance with the same name has already registered a command under cmdName.
    • getCommand

      public static Optional<org.wpilib.command3.Command> getCommand(String cmdName, org.wpilib.command3.Mechanism mechanism)
      Get a registered command, such as the "Live Tuning" command, to schedule it from code.
      Parameters:
      cmdName - Command name.
      mechanism - Mechanism 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.command3.Mechanism mechanism)
      Check if a command exists.
      Parameters:
      cmdName - Command name.
      mechanism - Mechanism.
      Returns:
      True if command exists.
    • removeCommands

      public static void removeCommands(org.wpilib.command3.Mechanism mechanism)
      Remove all commands registered for the given mechanism instance.

      Call this when a mechanism 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:
      mechanism - Mechanism whose commands should be removed.