-
Notifications
You must be signed in to change notification settings - Fork 4
/
RhsRobotBase.h
54 lines (40 loc) · 1.43 KB
/
RhsRobotBase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/** Base class from which we derive our main robot class.
*
* The RhsRobotBase class is an extension to RobotBase and provides basic robot functionality.
*/
#ifndef RHS_ROBOT_BASE_H
#define RHS_ROBOT_BASE_H
#include <unistd.h>
//Robot
#include "RobotMessage.h"
//WPILib
#include <WPILib.h> //For the RobotBase class
typedef enum eRobotOpMode
{
ROBOT_STATE_DISABLED,
ROBOT_STATE_AUTONOMOUS,
ROBOT_STATE_TELEOPERATED,
ROBOT_STATE_TEST,
ROBOT_STATE_UNKNOWN
} RobotOpMode;
class RhsRobotBase : public RobotBase
{
public:
RhsRobotBase(); //Constructor
virtual ~RhsRobotBase(); //Destructor
RobotOpMode GetCurrentRobotState(); //Returns the current robot state
RobotOpMode GetPreviousRobotState(); //Returns the previous robot state
bool HasStateChanged(); //Returns if the robot state has just changed
int GetLoop(); //Returns the loop number
protected:
RobotMessage robotMessage; //Message to be written and sent to components
virtual void Init() = 0; //Abstract function: initializes the robot
virtual void OnStateChange() = 0; //Abstract function: handles state changes
virtual void Run() = 0; //Abstract function: robot logic
private:
RobotOpMode currentRobotState; //Current robot state
RobotOpMode previousRobotState; //Previous robot state
int loop; //Loop counter
void StartCompetition(); //Robot's main function
};
#endif //RHS_ROBOT_BASE_H