Now you can download a copy of these docs so you can use them offline! Download now
SimpleRobot.cpp
00001 /*----------------------------------------------------------------------------*/ 00002 /* Copyright (c) FIRST 2008. All Rights Reserved. */ 00003 /* Open Source Software - may be modified and shared by FRC teams. The code */ 00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ 00005 /*----------------------------------------------------------------------------*/ 00006 00007 #include "SimpleRobot.h" 00008 00009 #include "DriverStation.h" 00010 #include "Timer.h" 00011 00012 SimpleRobot::SimpleRobot() 00013 : m_robotMainOverridden (true) 00014 { 00015 m_watchdog.SetEnabled(false); 00016 } 00017 00024 void SimpleRobot::RobotInit() 00025 { 00026 printf("Default %s() method... Override me!\n", __FUNCTION__); 00027 } 00028 00034 void SimpleRobot::Disabled() 00035 { 00036 printf("Default %s() method... Override me!\n", __FUNCTION__); 00037 } 00038 00044 void SimpleRobot::Autonomous() 00045 { 00046 printf("Default %s() method... Override me!\n", __FUNCTION__); 00047 } 00048 00054 void SimpleRobot::OperatorControl() 00055 { 00056 printf("Default %s() method... Override me!\n", __FUNCTION__); 00057 } 00058 00070 void SimpleRobot::RobotMain() 00071 { 00072 m_robotMainOverridden = false; 00073 } 00074 00083 void SimpleRobot::StartCompetition() 00084 { 00085 RobotMain(); 00086 00087 if (!m_robotMainOverridden) 00088 { 00089 // first and one-time initialization 00090 RobotInit(); 00091 00092 while (true) 00093 { 00094 if (IsDisabled()) 00095 { 00096 m_ds->InDisabled(true); 00097 Disabled(); 00098 m_ds->InDisabled(false); 00099 while (IsDisabled()) m_ds->WaitForData(); 00100 } 00101 else if (IsAutonomous()) 00102 { 00103 m_ds->InAutonomous(true); 00104 Autonomous(); 00105 m_ds->InAutonomous(false); 00106 while (IsAutonomous() && IsEnabled()) m_ds->WaitForData(); 00107 } 00108 else 00109 { 00110 m_ds->InOperatorControl(true); 00111 OperatorControl(); 00112 m_ds->InOperatorControl(false); 00113 while (IsOperatorControl() && IsEnabled()) m_ds->WaitForData(); 00114 } 00115 } 00116 } 00117 }
Generated on Thu Jan 12 2012 22:35:24 for WPILibC++ by
1.7.1