Package com.lightningrobotics.common
Class LightningRobot
- java.lang.Object
-
- edu.wpi.first.wpilibj.RobotBase
-
- edu.wpi.first.wpilibj.IterativeRobotBase
-
- edu.wpi.first.wpilibj.TimedRobot
-
- com.lightningrobotics.common.LightningRobot
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class LightningRobot extends edu.wpi.first.wpilibj.TimedRobot
Base robot class, provideslogging
,fault monitoring
, and loops with varying periodsbackground
,low
, andmedium
priority loops. UsesAutonomous
to configure autonomous commands. Also includes self-testing support withSystemTestCommand
.
-
-
Field Summary
Fields Modifier and Type Field Description DataLogger
dataLogger
-
Constructor Summary
Constructors Constructor Description LightningRobot(LightningContainer container)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
autonomousInit()
The default implementation handles getting the selected command from Shuffleboard.void
disabledInit()
The default implementation configures the default commands in the event they have been disabled bytestInit()
.void
disabledPeriodic()
Nothing should happen here.LightningContainer
getContainer()
Getter for the configured robot container.protected void
robotBackgroundPeriodic()
A slower loop, running once every 10 seconds Note as currently implemented it still needs to complete in our loop time or it delay higher priority opterations.void
robotInit()
This function is run when the robot is first started up and should be used for any initialization code.protected void
robotLowPriorityPeriodic()
A slow loop, running once a second Note as currently implemented it still needs to complete in our loop time or it delay higher priority opterations.protected void
robotMediumPriorityPeriodic()
A loop, running 10 times a second Note as currently implemented it still needs to complete in our loop time or it delay higher priority opterations.void
robotPeriodic()
This function is called every robot packet, no matter the mode.void
teleopInit()
The default implementation handles canceling the autonomous command.void
testInit()
The default implementation cancles all commands and releases the default commands from the subsystems, and schedules aSystemTestCommand
.void
testPeriodic()
-
Methods inherited from class edu.wpi.first.wpilibj.TimedRobot
addPeriodic, addPeriodic, endCompetition, finalize, startCompetition
-
Methods inherited from class edu.wpi.first.wpilibj.IterativeRobotBase
autonomousExit, autonomousPeriodic, disabledExit, getPeriod, loopFunc, setNetworkTablesFlushEnabled, simulationInit, simulationPeriodic, teleopExit, teleopPeriodic, testExit
-
Methods inherited from class edu.wpi.first.wpilibj.RobotBase
close, getBooleanProperty, getMainThreadId, getRuntimeType, isAutonomous, isAutonomousEnabled, isDisabled, isEnabled, isNewDataAvailable, isOperatorControl, isOperatorControlEnabled, isReal, isSimulation, isTeleop, isTeleopEnabled, isTest, startRobot, suppressExitWarning
-
-
-
-
Field Detail
-
dataLogger
public DataLogger dataLogger
-
-
Constructor Detail
-
LightningRobot
public LightningRobot(LightningContainer container)
-
-
Method Detail
-
getContainer
public LightningContainer getContainer()
Getter for the configured robot container.- Returns:
- the
LightningContainer
for the robot.
-
disabledPeriodic
public void disabledPeriodic()
Nothing should happen here.- Overrides:
disabledPeriodic
in classedu.wpi.first.wpilibj.IterativeRobotBase
-
robotInit
public void robotInit()
This function is run when the robot is first started up and should be used for any initialization code. If you override it, be sure to call super.robotInit- Overrides:
robotInit
in classedu.wpi.first.wpilibj.IterativeRobotBase
-
robotPeriodic
public void robotPeriodic()
This function is called every robot packet, no matter the mode. Use this for items like diagnostics that you want ran during disabled, autonomous, teleoperated and test.This runs after the mode specific periodic functions, but before LiveWindow and Shuffleboard integrated updating. If you override this method, be sure to call super.robotPeriod() as it drives our lower priority loops, datalogging, fault monitoring, etc.
- Overrides:
robotPeriodic
in classedu.wpi.first.wpilibj.IterativeRobotBase
-
robotBackgroundPeriodic
protected void robotBackgroundPeriodic()
A slower loop, running once every 10 seconds Note as currently implemented it still needs to complete in our loop time or it delay higher priority opterations. If you have a low priority, long running operation, consider creating a background thread.
-
robotLowPriorityPeriodic
protected void robotLowPriorityPeriodic()
A slow loop, running once a second Note as currently implemented it still needs to complete in our loop time or it delay higher priority opterations. If you have a low priority, long running operation, consider creating a background thread.
-
robotMediumPriorityPeriodic
protected void robotMediumPriorityPeriodic()
A loop, running 10 times a second Note as currently implemented it still needs to complete in our loop time or it delay higher priority opterations. If you have a low priority, long running operation, consider creating a background thread.
-
autonomousInit
public void autonomousInit()
The default implementation handles getting the selected command from Shuffleboard. If you override this method, be sure to callsuper.autonomousInit()
or the selected registered command will not be executed.- Overrides:
autonomousInit
in classedu.wpi.first.wpilibj.IterativeRobotBase
-
teleopInit
public void teleopInit()
The default implementation handles canceling the autonomous command. If you override this method, be sure to callsuper.teleopInit()
or the autonomous command will not be canceled when teleop starts. Alternatively, if you want the autonomous command to finish running into teleop, you may override this method w/o callingsuper.teleopInit()
- Overrides:
teleopInit
in classedu.wpi.first.wpilibj.IterativeRobotBase
-
testInit
public void testInit()
The default implementation cancles all commands and releases the default commands from the subsystems, and schedules aSystemTestCommand
. It is reccomended that you avoid overriding this method.- Overrides:
testInit
in classedu.wpi.first.wpilibj.IterativeRobotBase
-
testPeriodic
public void testPeriodic()
- Overrides:
testPeriodic
in classedu.wpi.first.wpilibj.IterativeRobotBase
-
disabledInit
public void disabledInit()
The default implementation configures the default commands in the event they have been disabled bytestInit()
.- Overrides:
disabledInit
in classedu.wpi.first.wpilibj.IterativeRobotBase
-
-