#include <IterativeRobot.h>
Public Member Functions | |
virtual void | StartCompetition () |
virtual void | RobotInit () |
virtual void | DisabledInit () |
virtual void | AutonomousInit () |
virtual void | TeleopInit () |
virtual void | TestInit () |
virtual void | DisabledPeriodic () |
virtual void | AutonomousPeriodic () |
virtual void | TeleopPeriodic () |
virtual void | TestPeriodic () |
void | SetPeriod (double period) |
double | GetPeriod () |
double | GetLoopsPerSec () |
Public Member Functions inherited from RobotBase | |
bool | IsEnabled () |
bool | IsDisabled () |
bool | IsAutonomous () |
bool | IsOperatorControl () |
bool | IsTest () |
bool | IsSystemActive () |
bool | IsNewDataAvailable () |
Watchdog & | GetWatchdog () |
Static Public Attributes | |
static constexpr double | kDefaultPeriod = 0.0 |
Protected Member Functions | |
virtual | ~IterativeRobot () |
IterativeRobot () | |
Protected Member Functions inherited from RobotBase | |
virtual | ~RobotBase () |
RobotBase () | |
Additional Inherited Members | |
Static Public Member Functions inherited from RobotBase | |
static RobotBase & | getInstance () |
static void | setInstance (RobotBase *robot) |
static void | startRobotTask (FUNCPTR factory) |
static void | robotTask (FUNCPTR factory, Task *task) |
Static Protected Member Functions inherited from RobotBase | |
static void | WriteVersionString () |
Protected Attributes inherited from RobotBase | |
Task * | m_task |
Watchdog | m_watchdog |
DriverStation * | m_ds |
IterativeRobot implements a specific type of Robot Program framework, extending the RobotBase class.
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:
Periodic() functions – each of these functions is called iteratively at the appropriate periodic rate (aka the "slow loop"). The default period of the iterative robot is synced to the driver station control packets, giving a periodic frequency of about 50Hz (50 times per second).
Definition at line 41 of file IterativeRobot.h.
|
protectedvirtual |
Free the resources for a RobotIterativeBase class.
Definition at line 37 of file IterativeRobot.cpp.
|
protected |
Constructor for RobotIterativeBase
The constructor initializes the instance variables for the robot to indicate the status of initialization for disabled, autonomous, teleop, and test code.
Definition at line 24 of file IterativeRobot.cpp.
|
virtual |
Initialization code for autonomous mode should go here.
Users should override this method for initialization code which will be called each time the robot enters autonomous mode.
Definition at line 244 of file IterativeRobot.cpp.
|
virtual |
Periodic code for autonomous mode should go here.
Users should override this method for code which will be called periodically at a regular rate while the robot is in autonomous mode.
Definition at line 294 of file IterativeRobot.cpp.
|
virtual |
Initialization code for disabled mode should go here.
Users should override this method for initialization code which will be called each time the robot enters disabled mode.
Definition at line 233 of file IterativeRobot.cpp.
|
virtual |
Periodic code for disabled mode should go here.
Users should override this method for code which will be called periodically at a regular rate while the robot is in disabled mode.
Definition at line 277 of file IterativeRobot.cpp.
double IterativeRobot::GetLoopsPerSec | ( | ) |
Get the number of loops per second for the IterativeRobot
Definition at line 76 of file IterativeRobot.cpp.
double IterativeRobot::GetPeriod | ( | ) |
Get the period for the periodic functions. Returns 0.0 if configured to syncronize with DS control data packets.
Definition at line 67 of file IterativeRobot.cpp.
|
virtual |
Robot-wide initialization code should go here.
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 1 time.
Definition at line 222 of file IterativeRobot.cpp.
void IterativeRobot::SetPeriod | ( | double | period | ) |
Set the period for the periodic functions.
period | The period of the periodic function calls. 0.0 means sync to driver station control data. |
Definition at line 46 of file IterativeRobot.cpp.
|
virtual |
Provide an alternate "main loop" via StartCompetition().
This specific StartCompetition() implements "main loop" behavior like that of the FRC control system in 2008 and earlier, with a primary (slow) loop that is called periodically, and a "fast loop" (a.k.a. "spin loop") that is called as fast as possible with no delay between calls.
Implements RobotBase.
Definition at line 93 of file IterativeRobot.cpp.
|
virtual |
Initialization code for teleop mode should go here.
Users should override this method for initialization code which will be called each time the robot enters teleop mode.
Definition at line 255 of file IterativeRobot.cpp.
|
virtual |
Periodic code for teleop mode should go here.
Users should override this method for code which will be called periodically at a regular rate while the robot is in teleop mode.
Definition at line 311 of file IterativeRobot.cpp.
|
virtual |
Initialization code for test mode should go here.
Users should override this method for initialization code which will be called each time the robot enters test mode.
Definition at line 266 of file IterativeRobot.cpp.
|
virtual |
Periodic code for test mode should go here.
Users should override this method for code which will be called periodically at a regular rate while the robot is in test mode.
Definition at line 328 of file IterativeRobot.cpp.