Class SRobot

java.lang.Object
org.chsrobotics.lib.util.SRobot

public class SRobot extends Object
"SpartanRobot"

Wrapper around TimedRobot which replaces ___Init() and ___Periodic() methods with single unified state transition and periodic methods, with robot state given as parameters.

To use, have your central robot class extend SRobot. Your main method should contain exactly one line, as follows (assuming the central robot class is named Robot).

new Robot.start();.

  • Constructor Details

    • SRobot

      public SRobot()
  • Method Details

    • start

      public final void start()
      Call this method to start robot code execution.
    • stateTransition

      public void stateTransition(SRobot.RobotState from, SRobot.RobotState to)
      Override this method and put your own logic here!

      Method called whenever the robot base goes from one driver station control mode to another.

      Parameters:
      from - The previous RobotState.
      to - The new RobotState.
    • periodic

      public void periodic(SRobot.RobotState state)
      Override this method and put your own logic here!

      Method called every loop of the robot base.

      Parameters:
      state - The current RobotState.
    • isReal

      public static final boolean isReal()
      Returns whether the robot exists in a real or simulated environment.
      Returns:
      Whether or not the robot physically exists.
    • getPeriodSeconds

      public static final double getPeriodSeconds()
      Returns the time, in each seconds, nominally taken by each robot loop cycle.
      Returns:
      The nominal length of each loop cycle.
    • getRobotState

      public static final SRobot.RobotState getRobotState()
      Returns the current state of the robot.
      Returns:
      The current Driver Station control mode.