2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/SampleRobot.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2018-10-29 12:49:17 -07:00
|
|
|
#include <hal/DriverStation.h>
|
|
|
|
|
#include <hal/FRCUsageReporting.h>
|
|
|
|
|
#include <hal/HALBase.h>
|
2017-12-07 23:34:29 -08:00
|
|
|
#include <networktables/NetworkTable.h>
|
2018-04-29 23:33:19 -07:00
|
|
|
#include <wpi/raw_ostream.h>
|
2017-08-27 00:11:52 -07:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/DriverStation.h"
|
|
|
|
|
#include "frc/Timer.h"
|
|
|
|
|
#include "frc/livewindow/LiveWindow.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2017-07-01 01:12:28 -04:00
|
|
|
void SampleRobot::StartCompetition() {
|
|
|
|
|
LiveWindow* lw = LiveWindow::GetInstance();
|
|
|
|
|
|
|
|
|
|
RobotInit();
|
|
|
|
|
|
|
|
|
|
// Tell the DS that the robot is ready to be enabled
|
|
|
|
|
HAL_ObserveUserProgramStarting();
|
|
|
|
|
|
|
|
|
|
RobotMain();
|
|
|
|
|
|
|
|
|
|
if (!m_robotMainOverridden) {
|
|
|
|
|
while (true) {
|
|
|
|
|
if (IsDisabled()) {
|
|
|
|
|
m_ds.InDisabled(true);
|
|
|
|
|
Disabled();
|
|
|
|
|
m_ds.InDisabled(false);
|
|
|
|
|
while (IsDisabled()) m_ds.WaitForData();
|
|
|
|
|
} else if (IsAutonomous()) {
|
|
|
|
|
m_ds.InAutonomous(true);
|
|
|
|
|
Autonomous();
|
|
|
|
|
m_ds.InAutonomous(false);
|
|
|
|
|
while (IsAutonomous() && IsEnabled()) m_ds.WaitForData();
|
|
|
|
|
} else if (IsTest()) {
|
|
|
|
|
lw->SetEnabled(true);
|
|
|
|
|
m_ds.InTest(true);
|
|
|
|
|
Test();
|
|
|
|
|
m_ds.InTest(false);
|
|
|
|
|
while (IsTest() && IsEnabled()) m_ds.WaitForData();
|
|
|
|
|
lw->SetEnabled(false);
|
|
|
|
|
} else {
|
|
|
|
|
m_ds.InOperatorControl(true);
|
|
|
|
|
OperatorControl();
|
|
|
|
|
m_ds.InOperatorControl(false);
|
|
|
|
|
while (IsOperatorControl() && IsEnabled()) m_ds.WaitForData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
void SampleRobot::RobotInit() {
|
2019-01-25 00:45:05 -06:00
|
|
|
wpi::outs() << "Default " << __FUNCTION__ << "() method... Override me!\n";
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
void SampleRobot::Disabled() {
|
2019-01-25 00:45:05 -06:00
|
|
|
wpi::outs() << "Default " << __FUNCTION__ << "() method... Override me!\n";
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
void SampleRobot::Autonomous() {
|
2019-01-25 00:45:05 -06:00
|
|
|
wpi::outs() << "Default " << __FUNCTION__ << "() method... Override me!\n";
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
void SampleRobot::OperatorControl() {
|
2019-01-25 00:45:05 -06:00
|
|
|
wpi::outs() << "Default " << __FUNCTION__ << "() method... Override me!\n";
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
void SampleRobot::Test() {
|
2019-01-25 00:45:05 -06:00
|
|
|
wpi::outs() << "Default " << __FUNCTION__ << "() method... Override me!\n";
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
void SampleRobot::RobotMain() { m_robotMainOverridden = false; }
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2017-07-08 10:50:56 -04:00
|
|
|
SampleRobot::SampleRobot() {
|
|
|
|
|
HAL_Report(HALUsageReporting::kResourceType_Framework,
|
|
|
|
|
HALUsageReporting::kFramework_Simple);
|
|
|
|
|
}
|