mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
Add format script which invokes clang-format on the C++ source code (#41)
On Windows machines, clang-format.exe must be in the PATH environment variable.
This commit is contained in:
committed by
Peter Johnson
parent
68690643d2
commit
e14e45da76
@@ -7,30 +7,37 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Timer.h"
|
||||
#include "RobotBase.h"
|
||||
#include "Timer.h"
|
||||
|
||||
/**
|
||||
* IterativeRobot implements a specific type of Robot Program framework, extending the RobotBase class.
|
||||
* 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.
|
||||
* 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:
|
||||
* 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
|
||||
* - 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).
|
||||
* 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).
|
||||
* - DisabledPeriodic()
|
||||
* - AutonomousPeriodic()
|
||||
* - TeleopPeriodic()
|
||||
@@ -38,44 +45,43 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class IterativeRobot : public RobotBase
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* The default period for the periodic function calls (seconds)
|
||||
* Setting the period to 0.0 will cause the periodic functions to follow
|
||||
* the Driver Station packet rate of about 50Hz.
|
||||
*/
|
||||
static const double kDefaultPeriod;
|
||||
class IterativeRobot : public RobotBase {
|
||||
public:
|
||||
/*
|
||||
* The default period for the periodic function calls (seconds).
|
||||
* Setting the period to 0.0 will cause the periodic functions to follow
|
||||
* the Driver Station packet rate of about 50Hz.
|
||||
*/
|
||||
static const double kDefaultPeriod;
|
||||
|
||||
virtual void StartCompetition();
|
||||
virtual void StartCompetition();
|
||||
|
||||
virtual void RobotInit();
|
||||
virtual void DisabledInit();
|
||||
virtual void AutonomousInit();
|
||||
virtual void TeleopInit();
|
||||
virtual void TestInit();
|
||||
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();
|
||||
virtual void DisabledPeriodic();
|
||||
virtual void AutonomousPeriodic();
|
||||
virtual void TeleopPeriodic();
|
||||
virtual void TestPeriodic();
|
||||
|
||||
void SetPeriod(double period);
|
||||
double GetPeriod();
|
||||
double GetLoopsPerSec();
|
||||
void SetPeriod(double period);
|
||||
double GetPeriod();
|
||||
double GetLoopsPerSec();
|
||||
|
||||
protected:
|
||||
virtual ~IterativeRobot() = default;
|
||||
IterativeRobot() = default;
|
||||
protected:
|
||||
virtual ~IterativeRobot() = default;
|
||||
IterativeRobot() = default;
|
||||
|
||||
private:
|
||||
bool NextPeriodReady();
|
||||
private:
|
||||
bool NextPeriodReady();
|
||||
|
||||
bool m_disabledInitialized = false;
|
||||
bool m_autonomousInitialized = false;
|
||||
bool m_teleopInitialized = false;
|
||||
bool m_testInitialized = false;
|
||||
double m_period = kDefaultPeriod;
|
||||
Timer m_mainLoopTimer;
|
||||
bool m_disabledInitialized = false;
|
||||
bool m_autonomousInitialized = false;
|
||||
bool m_teleopInitialized = false;
|
||||
bool m_testInitialized = false;
|
||||
double m_period = kDefaultPeriod;
|
||||
Timer m_mainLoopTimer;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user