Package org.chsrobotics.lib.util
Class SRobot
java.lang.Object
org.chsrobotics.lib.util.SRobot
"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();.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum of possible DriverStation robot control states. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final doubleReturns the time, in each seconds, nominally taken by each robot loop cycle.static final SRobot.RobotStateReturns the current state of the robot.static final booleanisReal()Returns whether the robot exists in a real or simulated environment.voidperiodic(SRobot.RobotState state) Override this method and put your own logic here!final voidstart()Call this method to start robot code execution.voidOverride this method and put your own logic here!
-
Constructor Details
-
SRobot
public SRobot()
-
-
Method Details
-
start
public final void start()Call this method to start robot code execution. -
stateTransition
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
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
Returns the current state of the robot.- Returns:
- The current Driver Station control mode.
-