Class RunnableCommand

java.lang.Object
edu.wpi.first.wpilibj2.command.CommandBase
org.chsrobotics.lib.commands.RunnableCommand
All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable, edu.wpi.first.wpilibj2.command.Command

public class RunnableCommand extends edu.wpi.first.wpilibj2.command.CommandBase
Simple class to call a method (with no parameters) in the command-based structure.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface edu.wpi.first.wpilibj2.command.Command

    edu.wpi.first.wpilibj2.command.Command.InterruptionBehavior
  • Field Summary

    Fields inherited from class edu.wpi.first.wpilibj2.command.CommandBase

    m_requirements
  • Constructor Summary

    Constructors
    Constructor
    Description
    RunnableCommand(Runnable init, edu.wpi.first.wpilibj2.command.Subsystem... toRequire)
    Constructs a RunnableCommand that instantly ends.
    RunnableCommand(Runnable init, Runnable end, double durationSeconds, edu.wpi.first.wpilibj2.command.Subsystem... toRequire)
    Constructs a RunnableCommand.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    end(boolean interrupted)
     
    void
     
    boolean
     
    boolean
     
    void
    setRunsWhileDisabled(boolean runsWhileDisabled)
    Sets whether this command should continue to run even while the robot is in a disabled state.

    Methods inherited from class edu.wpi.first.wpilibj2.command.CommandBase

    addRequirements, getName, getRequirements, getSubsystem, initSendable, setName, setSubsystem

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface edu.wpi.first.wpilibj2.command.Command

    alongWith, andThen, andThen, asProxy, beforeStarting, beforeStarting, cancel, deadlineWith, execute, finallyDo, getInterruptionBehavior, handleInterrupt, hasRequirement, ignoringDisable, isScheduled, perpetually, raceWith, repeatedly, schedule, unless, until, withInterrupt, withInterruptBehavior, withName, withTimeout
  • Constructor Details

    • RunnableCommand

      public RunnableCommand(Runnable init, Runnable end, double durationSeconds, edu.wpi.first.wpilibj2.command.Subsystem... toRequire)
      Constructs a RunnableCommand.
      Parameters:
      init - Method to call upon initialization of this command. If null, will not be called.
      end - Method to call upon end of this command. If null, will not be called.
      durationSeconds - Time this command should be active for; if less than zero, will not end; if zero, will end in the first command scheduler loop.
      toRequire - Any subsystems that need to be free for the given methods.
    • RunnableCommand

      public RunnableCommand(Runnable init, edu.wpi.first.wpilibj2.command.Subsystem... toRequire)
      Constructs a RunnableCommand that instantly ends.
      Parameters:
      init - The method to call upon initalization of this command. If null, will not be called.
      toRequire - Any subsystems that need to be free for the given method.
  • Method Details

    • setRunsWhileDisabled

      public void setRunsWhileDisabled(boolean runsWhileDisabled)
      Sets whether this command should continue to run even while the robot is in a disabled state.
      Parameters:
      runsWhileDisabled - True if this command should continue in the disabled state.
    • runsWhenDisabled

      public boolean runsWhenDisabled()
    • initialize

      public void initialize()
    • end

      public void end(boolean interrupted)
    • isFinished

      public boolean isFinished()