mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Remove SampleRobot (#1658)
SampleRobot provides no benefits over RobotBase to advanced teams and TimedRobot is recommended for everyone else. A skeleton template for RobotBase was added.
This commit is contained in:
committed by
Peter Johnson
parent
62be0392b6
commit
73ec940786
@@ -0,0 +1,66 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
#include <hal/DriverStation.h>
|
||||
|
||||
#include <frc/DriverStation.h>
|
||||
#include <frc/livewindow/LiveWindow.h>
|
||||
#include <frc/shuffleboard/Shuffleboard.h>
|
||||
#include <networktables/NetworkTable.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
|
||||
void Robot::Disabled() {}
|
||||
|
||||
void Robot::Autonomous() {}
|
||||
|
||||
void Robot::Teleop() {}
|
||||
|
||||
void Robot::Test() {}
|
||||
|
||||
void Robot::StartCompetition() {
|
||||
auto& lw = *frc::LiveWindow::GetInstance();
|
||||
|
||||
RobotInit();
|
||||
|
||||
// Tell the DS that the robot is ready to be enabled
|
||||
HAL_ObserveUserProgramStarting();
|
||||
|
||||
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);
|
||||
frc::Shuffleboard::EnableActuatorWidgets();
|
||||
m_ds.InTest(true);
|
||||
Test();
|
||||
m_ds.InTest(false);
|
||||
while (IsTest() && IsEnabled()) m_ds.WaitForData();
|
||||
lw.SetEnabled(false);
|
||||
frc::Shuffleboard::DisableActuatorWidgets();
|
||||
} else {
|
||||
m_ds.InOperatorControl(true);
|
||||
Teleop();
|
||||
m_ds.InOperatorControl(false);
|
||||
while (IsOperatorControl() && IsEnabled()) m_ds.WaitForData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc/RobotBase.h>
|
||||
|
||||
class Robot : public frc::RobotBase {
|
||||
public:
|
||||
void RobotInit();
|
||||
void Disabled();
|
||||
void Autonomous();
|
||||
void Teleop();
|
||||
void Test();
|
||||
|
||||
void StartCompetition() override;
|
||||
};
|
||||
Reference in New Issue
Block a user