blob: df915252fa5390af0d1026e487edef2d61f6d7f8 [file] [log] [blame]
Parker Schuhd3b7a8872018-02-19 16:42:27 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008-2017. 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#include <thread>
13
Austin Schuhf6b94632019-02-02 22:11:27 -080014#include "hal/HAL.h"
Parker Schuhd3b7a8872018-02-19 16:42:27 -080015#include "frc971/wpilib/ahal/Base.h"
16
17namespace frc {
18
19class DriverStation;
20
21#ifdef WPILIB2017
22#define START_ROBOT_CLASS(_ClassName_) \
23 int main() { \
24 if (!HAL_Initialize(0)) { \
25 std::cerr << "FATAL ERROR: HAL could not be initialized" << std::endl; \
26 return -1; \
27 } \
28 HAL_Report(HALUsageReporting::kResourceType_Language, \
29 HALUsageReporting::kLanguage_CPlusPlus); \
30 static _ClassName_ robot; \
31 std::printf("\n********** Robot program starting **********\n"); \
32 robot.StartCompetition(); \
33 }
34#else
35#define START_ROBOT_CLASS(_ClassName_) \
36 int main() { \
37 if (!HAL_Initialize(500, 0)) { \
38 std::cerr << "FATAL ERROR: HAL could not be initialized" << std::endl; \
39 return -1; \
40 } \
41 HAL_Report(HALUsageReporting::kResourceType_Language, \
42 HALUsageReporting::kLanguage_CPlusPlus); \
43 static _ClassName_ robot; \
44 std::printf("\n********** Robot program starting **********\n"); \
45 robot.StartCompetition(); \
46 }
47#endif
48
49/**
50 * Implement a Robot Program framework.
51 * The RobotBase class is intended to be subclassed by a user creating a robot
52 * program. Overridden Autonomous() and OperatorControl() methods are called at
53 * the appropriate time as the match proceeds. In the current implementation,
54 * the Autonomous code will run to completion before the OperatorControl code
55 * could start. In the future the Autonomous code might be spawned as a task,
56 * then killed at the end of the Autonomous period.
57 */
58class RobotBase {
59 public:
60 virtual void StartCompetition() = 0;
61
62 protected:
63 RobotBase();
64 virtual ~RobotBase() = default;
65
66 RobotBase(const RobotBase &) = delete;
67 RobotBase &operator=(const RobotBase &) = delete;
68
69 DriverStation &m_ds;
70};
71
72} // namespace frc