public class IterativeRobot extends RobotBase
The IterativeRobot class is intended to be subclassed by a user creating a robot program.
This class is intended to implement the "old style" default code, by providing the following functions which are called by the main loop, startCompetition(), at the appropriate times:
robotInit() -- provide for initialization at robot power-on
init() functions -- each of the following functions is called once when the appropriate mode is entered: - DisabledInit() -- called only when first disabled - AutonomousInit() -- called each and every time autonomous is entered from another mode - TeleopInit() -- called each and every time teleop is entered from another mode - TestInit() -- called each and every time test mode is entered from anothermode
Periodic() functions -- each of these functions is called iteratively at the appropriate periodic rate (aka the "slow loop"). The period of the iterative robot is synced to the driver station control packets, giving a periodic frequency of about 50Hz (50 times per second). - disabledPeriodic() - autonomousPeriodic() - teleopPeriodic() - testPeriodoc()
m_ds, MAIN_THREAD_ID, ROBOT_TASK_PRIORITY
Constructor and Description |
---|
IterativeRobot()
Constructor for RobotIterativeBase.
|
Modifier and Type | Method and Description |
---|---|
void |
autonomousInit()
Initialization code for autonomous mode should go here.
|
void |
autonomousPeriodic()
Periodic code for autonomous mode should go here.
|
void |
disabledInit()
Initialization code for disabled mode should go here.
|
void |
disabledPeriodic()
Periodic code for disabled mode should go here.
|
void |
robotInit()
Robot-wide initialization code should go here.
|
void |
robotPeriodic()
Periodic code for all robot modes should go here.
|
void |
startCompetition()
Provide an alternate "main loop" via startCompetition().
|
void |
teleopInit()
Initialization code for teleop mode should go here.
|
void |
teleopPeriodic()
Periodic code for teleop mode should go here.
|
void |
testInit()
Initialization code for test mode should go here.
|
void |
testPeriodic()
Periodic code for test mode should go here.
|
free, getBooleanProperty, initializeHardwareConfiguration, isAutonomous, isDisabled, isEnabled, isNewDataAvailable, isOperatorControl, isReal, isSimulation, isTest, main
public IterativeRobot()
The constructor initializes the instance variables for the robot to indicate the status of initialization for disabled, autonomous, and teleop code.
public void startCompetition()
startCompetition
in class RobotBase
public void robotInit()
Users should override this method for default Robot-wide initialization which will be called when the robot is first powered on. It will be called exactly one time.
Warning: the Driver Station "Robot Code" light and FMS "Robot Ready" indicators will be off until RobotInit() exits. Code in RobotInit() that waits for enable will cause the robot to never indicate that the code is ready, causing the robot to be bypassed in a match.
public void disabledInit()
Users should override this method for initialization code which will be called each time the robot enters disabled mode.
public void autonomousInit()
Users should override this method for initialization code which will be called each time the robot enters autonomous mode.
public void teleopInit()
Users should override this method for initialization code which will be called each time the robot enters teleop mode.
public void testInit()
Users should override this method for initialization code which will be called each time the robot enters test mode.
public void robotPeriodic()
This function is called each time a new packet is received from the driver station.
Packets are received approximately every 20ms. Fixed loop timing is not guaranteed due to network timing variability and the function may not be called at all if the Driver Station is disconnected. For most use cases the variable timing will not be an issue. If your code does require guaranteed fixed periodic timing, consider using Notifier or PIDController instead.
public void disabledPeriodic()
Users should override this method for code which will be called each time a new packet is received from the driver station and the robot is in disabled mode.
Packets are received approximately every 20ms. Fixed loop timing is not guaranteed due to network timing variability and the function may not be called at all if the Driver Station is disconnected. For most use cases the variable timing will not be an issue. If your code does require guaranteed fixed periodic timing, consider using Notifier or PIDController instead.
public void autonomousPeriodic()
Users should override this method for code which will be called each time a new packet is received from the driver station and the robot is in autonomous mode.
Packets are received approximately every 20ms. Fixed loop timing is not guaranteed due to network timing variability and the function may not be called at all if the Driver Station is disconnected. For most use cases the variable timing will not be an issue. If your code does require guaranteed fixed periodic timing, consider using Notifier or PIDController instead.
public void teleopPeriodic()
Users should override this method for code which will be called each time a new packet is received from the driver station and the robot is in teleop mode.
Packets are received approximately every 20ms. Fixed loop timing is not guaranteed due to network timing variability and the function may not be called at all if the Driver Station is disconnected. For most use cases the variable timing will not be an issue. If your code does require guaranteed fixed periodic timing, consider using Notifier or PIDController instead.
public void testPeriodic()
Users should override this method for code which will be called each time a new packet is received from the driver station and the robot is in test mode.
Packets are received approximately every 20ms. Fixed loop timing is not guaranteed due to network timing variability and the function may not be called at all if the Driver Station is disconnected. For most use cases the variable timing will not be an issue. If your code does require guaranteed fixed periodic timing, consider using Notifier or PIDController instead.