WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
IterativeRobot Class Reference

IterativeRobot implements a specific type of Robot Program framework, extending the RobotBase class. More...

#include <IterativeRobot.h>

Inheritance diagram for IterativeRobot:
RobotBase

Public Member Functions

virtual void StartCompetition ()
 Provide an alternate "main loop" via StartCompetition(). More...
 
virtual void RobotInit ()
 Robot-wide initialization code should go here. More...
 
virtual void DisabledInit ()
 Initialization code for disabled mode should go here. More...
 
virtual void AutonomousInit ()
 Initialization code for autonomous mode should go here. More...
 
virtual void TeleopInit ()
 Initialization code for teleop mode should go here. More...
 
virtual void TestInit ()
 Initialization code for test mode should go here. More...
 
virtual void DisabledPeriodic ()
 Periodic code for disabled mode should go here. More...
 
virtual void AutonomousPeriodic ()
 Periodic code for autonomous mode should go here. More...
 
virtual void TeleopPeriodic ()
 Periodic code for teleop mode should go here. More...
 
virtual void TestPeriodic ()
 Periodic code for test mode should go here. More...
 
- Public Member Functions inherited from RobotBase
bool IsEnabled () const
 Determine if the Robot is currently enabled. More...
 
bool IsDisabled () const
 Determine if the Robot is currently disabled. More...
 
bool IsAutonomous () const
 Determine if the robot is currently in Autonomous mode. More...
 
bool IsOperatorControl () const
 Determine if the robot is currently in Operator Control mode. More...
 
bool IsTest () const
 Determine if the robot is currently in Test mode. More...
 
bool IsNewDataAvailable () const
 Indicates if new data is available from the driver station. More...
 

Static Public Attributes

static constexpr double kDefaultPeriod = 0.0
 

Additional Inherited Members

- Static Public Member Functions inherited from RobotBase
static RobotBasegetInstance ()
 
static void setInstance (RobotBase *robot)
 
static void startRobotTask (FUNCPTR factory)
 
static void robotTask (FUNCPTR factory, Task *task)
 
static void robotSetup (RobotBase *robot)
 
- Protected Member Functions inherited from RobotBase
 RobotBase ()
 Constructor for a generic robot program. More...
 
virtual ~RobotBase ()
 Free the resources for a RobotBase class. More...
 
 RobotBase (const RobotBase &)=delete
 
RobotBaseoperator= (const RobotBase &)=delete
 
- Protected Attributes inherited from RobotBase
Taskm_task = nullptr
 
DriverStationm_ds
 

Detailed Description

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:

  • 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 is entered from another mode

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).

Member Function Documentation

void IterativeRobot::AutonomousInit ( )
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.

void IterativeRobot::AutonomousPeriodic ( )
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.

void IterativeRobot::DisabledInit ( )
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.

void IterativeRobot::DisabledPeriodic ( )
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.

void IterativeRobot::RobotInit ( )
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 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.

void IterativeRobot::StartCompetition ( )
virtual

Provide an alternate "main loop" via StartCompetition().

This specific StartCompetition() implements "main loop" behaviour synced with the DS packets

Implements RobotBase.

void IterativeRobot::TeleopInit ( )
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.

void IterativeRobot::TeleopPeriodic ( )
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.

void IterativeRobot::TestInit ( )
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.

void IterativeRobot::TestPeriodic ( )
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.


The documentation for this class was generated from the following files: