WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
RobotBase.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <cstdio>
11 #include <iostream>
12 
13 #include "Base.h"
14 #include "HAL/HAL.h"
15 
16 namespace frc {
17 
18 class DriverStation;
19 
20 #define START_ROBOT_CLASS(_ClassName_) \
21  int main() { \
22  if (!HAL_Initialize(0)) { \
23  std::cerr << "FATAL ERROR: HAL could not be initialized" << std::endl; \
24  return -1; \
25  } \
26  HAL_Report(HALUsageReporting::kResourceType_Language, \
27  HALUsageReporting::kLanguage_CPlusPlus); \
28  static _ClassName_ robot; \
29  std::printf("\n********** Robot program starting **********\n"); \
30  robot.StartCompetition(); \
31  }
32 
42 class RobotBase {
43  public:
44  bool IsEnabled() const;
45  bool IsDisabled() const;
46  bool IsAutonomous() const;
47  bool IsOperatorControl() const;
48  bool IsTest() const;
49  bool IsNewDataAvailable() const;
50  virtual void StartCompetition() = 0;
51 
52  protected:
53  RobotBase();
54  virtual ~RobotBase() = default;
55 
56  RobotBase(const RobotBase&) = delete;
57  RobotBase& operator=(const RobotBase&) = delete;
58 
59  DriverStation& m_ds;
60 };
61 
62 } // namespace frc
bool IsEnabled() const
Determine if the Robot is currently enabled.
Definition: RobotBase.cpp:54
bool IsAutonomous() const
Determine if the robot is currently in Autonomous mode.
Definition: RobotBase.cpp:67
bool IsDisabled() const
Determine if the Robot is currently disabled.
Definition: RobotBase.cpp:60
Provide access to the network communication data to / from the Driver Station.
Definition: DriverStation.h:28
bool IsNewDataAvailable() const
Indicates if new data is available from the driver station.
Definition: RobotBase.cpp:88
bool IsOperatorControl() const
Determine if the robot is currently in Operator Control mode.
Definition: RobotBase.cpp:74
Implement a Robot Program framework.
Definition: RobotBase.h:42
bool IsTest() const
Determine if the robot is currently in Test mode.
Definition: RobotBase.cpp:81
RobotBase()
Constructor for a generic robot program.
Definition: RobotBase.cpp:34