blob: 82a2e65db977ee9c1e3cb204b2c05f91ee4a483d [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -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#include "RobotBase.h"
9
10#include "RobotState.h"
11#include "SmartDashboard/SmartDashboard.h"
12#include "Utility.h"
13
14using namespace frc;
15
16/**
17 * Constructor for a generic robot program.
18 *
19 * User code should be placed in the constuctor that runs before the Autonomous
20 * or Operator Control period starts. The constructor will run to completion
21 * before Autonomous is entered.
22 *
23 * This must be used to ensure that the communications code starts. In the
24 * future it would be nice to put this code into it's own task that loads on
25 * boot so ensure that it runs.
26 */
27RobotBase::RobotBase() : m_ds(DriverStation::GetInstance()) {
28 RobotState::SetImplementation(DriverStation::GetInstance());
29 SmartDashboard::init();
30 time_sub = MainNode::Subscribe("~/time", &wpilib::internal::time_callback);
31}
32
33/**
34 * Determine if the Robot is currently enabled.
35 *
36 * @return True if the Robot is currently enabled by the field controls.
37 */
38bool RobotBase::IsEnabled() const { return m_ds.IsEnabled(); }
39
40/**
41 * Determine if the Robot is currently disabled.
42 *
43 * @return True if the Robot is currently disabled by the field controls.
44 */
45bool RobotBase::IsDisabled() const { return m_ds.IsDisabled(); }
46
47/**
48 * Determine if the robot is currently in Autnomous mode.
49 *
50 * @return True if the robot is currently operating Autonomously as determined
51 * by the field controls.
52 */
53bool RobotBase::IsAutonomous() const { return m_ds.IsAutonomous(); }
54
55/**
56 * Determine if the robot is currently in Operator Control mode.
57 *
58 * @return True if the robot is currently operating in Tele-Op mode as
59 * determined by the field controls.
60 */
61bool RobotBase::IsOperatorControl() const { return m_ds.IsOperatorControl(); }
62
63/**
64 * Determine if the robot is currently in Test mode.
65 *
66 * @return True if the robot is currently running tests as determined by the
67 * field controls.
68 */
69bool RobotBase::IsTest() const { return m_ds.IsTest(); }