Now you can download a copy of these docs so you can use them offline! Download now
SimpleRobot.cpp
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
5 /*----------------------------------------------------------------------------*/
6 
7 #include "SimpleRobot.h"
8 
9 #include "DriverStation.h"
10 #include "NetworkCommunication/UsageReporting.h"
11 #include "Timer.h"
12 #include "SmartDashboard/SmartDashboard.h"
13 #include "LiveWindow/LiveWindow.h"
14 #include "networktables/NetworkTable.h"
15 
16 SimpleRobot::SimpleRobot()
17  : m_robotMainOverridden (true)
18 {
19  m_watchdog.SetEnabled(false);
20 }
21 
29 {
30  printf("Default %s() method... Override me!\n", __FUNCTION__);
31 }
32 
39 {
40  printf("Default %s() method... Override me!\n", __FUNCTION__);
41 }
42 
50 {
51  printf("Default %s() method... Override me!\n", __FUNCTION__);
52 }
53 
61 {
62  printf("Default %s() method... Override me!\n", __FUNCTION__);
63 }
64 
71 {
72  printf("Default %s() method... Override me!\n", __FUNCTION__);
73 }
74 
87 {
88  m_robotMainOverridden = false;
89 }
90 
100 {
102 
103  nUsageReporting::report(nUsageReporting::kResourceType_Framework, nUsageReporting::kFramework_Simple);
104 
105  SmartDashboard::init();
106  NetworkTable::GetTable("LiveWindow")->GetSubTable("~STATUS~")->PutBoolean("LW Enabled", false);
107 
108  RobotMain();
109 
110  if (!m_robotMainOverridden)
111  {
112  // first and one-time initialization
113 
114  lw->SetEnabled(false);
115 
116  RobotInit();
117 
118  while (true)
119  {
120  if (IsDisabled())
121  {
122  m_ds->InDisabled(true);
123  Disabled();
124  m_ds->InDisabled(false);
125  while (IsDisabled()) m_ds->WaitForData();
126  }
127  else if (IsAutonomous())
128  {
129  m_ds->InAutonomous(true);
130  Autonomous();
131  m_ds->InAutonomous(false);
132  while (IsAutonomous() && IsEnabled()) m_ds->WaitForData();
133  }
134  else if (IsTest())
135  {
136  lw->SetEnabled(true);
137  m_ds->InTest(true);
138  Test();
139  m_ds->InTest(false);
140  while (IsTest() && IsEnabled()) m_ds->WaitForData();
141  lw->SetEnabled(false);
142  }
143  else
144  {
145  m_ds->InOperatorControl(true);
146  OperatorControl();
147  m_ds->InOperatorControl(false);
148  while (IsOperatorControl() && IsEnabled()) m_ds->WaitForData();
149  }
150  }
151  }
152 }
NetworkTable * GetSubTable(std::string key)
bool IsOperatorControl()
Definition: RobotBase.cpp:115
bool IsAutonomous()
Definition: RobotBase.cpp:106
void SetEnabled(bool enabled)
Definition: LiveWindow.cpp:38
static NetworkTable * GetTable(std::string key)
void PutBoolean(std::string key, bool value)
bool IsEnabled()
Definition: RobotBase.cpp:88
bool IsTest()
Definition: RobotBase.cpp:124
virtual void Disabled()
Definition: SimpleRobot.cpp:38
virtual void Test()
Definition: SimpleRobot.cpp:70
void InOperatorControl(bool entering)
Definition: DriverStation.h:91
static LiveWindow * GetInstance()
Definition: LiveWindow.cpp:13
bool IsDisabled()
Definition: RobotBase.cpp:97
virtual void Autonomous()
Definition: SimpleRobot.cpp:49
void InDisabled(bool entering)
Definition: DriverStation.h:83
virtual void RobotInit()
Definition: SimpleRobot.cpp:28
void InTest(bool entering)
Definition: DriverStation.h:95
virtual void OperatorControl()
Definition: SimpleRobot.cpp:60
void InAutonomous(bool entering)
Definition: DriverStation.h:87
void StartCompetition()
Definition: SimpleRobot.cpp:99
virtual void RobotMain()
Definition: SimpleRobot.cpp:86

Generated on Sat Apr 26 2014 12:26:45 for WPILibC++ by doxygen 1.8.6