Run wpiformat on merged repo (#1021)

This commit is contained in:
Tyler Veness
2018-05-13 17:09:56 -07:00
committed by Peter Johnson
parent 0babbf317c
commit 6729a7d6b1
481 changed files with 9581 additions and 6828 deletions

View File

@@ -10,8 +10,8 @@
#include "../Robot.h"
ExampleCommand::ExampleCommand() {
// Use Requires() here to declare subsystem dependencies
Requires(&Robot::m_subsystem);
// Use Requires() here to declare subsystem dependencies
Requires(&Robot::m_subsystem);
}
// Called just before this Command runs the first time
@@ -21,9 +21,7 @@ void ExampleCommand::Initialize() {}
void ExampleCommand::Execute() {}
// Make this return true when this Command no longer needs to run execute()
bool ExampleCommand::IsFinished() {
return false;
}
bool ExampleCommand::IsFinished() { return false; }
// Called once after isFinished returns true
void ExampleCommand::End() {}

View File

@@ -10,11 +10,11 @@
#include <Commands/Command.h>
class ExampleCommand : public frc::Command {
public:
ExampleCommand();
void Initialize() override;
void Execute() override;
bool IsFinished() override;
void End() override;
void Interrupted() override;
public:
ExampleCommand();
void Initialize() override;
void Execute() override;
bool IsFinished() override;
void End() override;
void Interrupted() override;
};

View File

@@ -10,8 +10,8 @@
#include "../Robot.h"
MyAutoCommand::MyAutoCommand() {
// Use Requires() here to declare subsystem dependencies
Requires(&Robot::m_subsystem);
// Use Requires() here to declare subsystem dependencies
Requires(&Robot::m_subsystem);
}
// Called just before this Command runs the first time
@@ -21,9 +21,7 @@ void MyAutoCommand::Initialize() {}
void MyAutoCommand::Execute() {}
// Make this return true when this Command no longer needs to run execute()
bool MyAutoCommand::IsFinished() {
return false;
}
bool MyAutoCommand::IsFinished() { return false; }
// Called once after isFinished returns true
void MyAutoCommand::End() {}

View File

@@ -10,11 +10,11 @@
#include <Commands/Command.h>
class MyAutoCommand : public frc::Command {
public:
MyAutoCommand();
void Initialize() override;
void Execute() override;
bool IsFinished() override;
void End() override;
void Interrupted() override;
public:
MyAutoCommand();
void Initialize() override;
void Execute() override;
bool IsFinished() override;
void End() override;
void Interrupted() override;
};

View File

@@ -10,5 +10,5 @@
#include <WPILib.h>
OI::OI() {
// Process operator interface input here.
// Process operator interface input here.
}

View File

@@ -8,6 +8,6 @@
#pragma once
class OI {
public:
OI();
public:
OI();
};

View File

@@ -14,9 +14,9 @@ ExampleSubsystem Robot::m_subsystem;
OI Robot::m_oi;
void Robot::RobotInit() {
m_chooser.AddDefault("Default Auto", &m_defaultAuto);
m_chooser.AddObject("My Auto", &m_myAuto);
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
m_chooser.AddDefault("Default Auto", &m_defaultAuto);
m_chooser.AddObject("My Auto", &m_myAuto);
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
}
/**
@@ -26,9 +26,7 @@ void Robot::RobotInit() {
*/
void Robot::DisabledInit() {}
void Robot::DisabledPeriodic() {
frc::Scheduler::GetInstance()->Run();
}
void Robot::DisabledPeriodic() { frc::Scheduler::GetInstance()->Run(); }
/**
* This autonomous (along with the chooser code above) shows how to select
@@ -42,39 +40,35 @@ void Robot::DisabledPeriodic() {
* the if-else structure below with additional strings & commands.
*/
void Robot::AutonomousInit() {
// std::string autoSelected = frc::SmartDashboard::GetString(
// "Auto Selector", "Default");
// if (autoSelected == "My Auto") {
// m_autonomousCommand = &m_myAuto;
// } else {
// m_autonomousCommand = &m_defaultAuto;
// }
// std::string autoSelected = frc::SmartDashboard::GetString(
// "Auto Selector", "Default");
// if (autoSelected == "My Auto") {
// m_autonomousCommand = &m_myAuto;
// } else {
// m_autonomousCommand = &m_defaultAuto;
// }
m_autonomousCommand = m_chooser.GetSelected();
m_autonomousCommand = m_chooser.GetSelected();
if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Start();
}
if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Start();
}
}
void Robot::AutonomousPeriodic() {
frc::Scheduler::GetInstance()->Run();
}
void Robot::AutonomousPeriodic() { frc::Scheduler::GetInstance()->Run(); }
void Robot::TeleopInit() {
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Cancel();
m_autonomousCommand = nullptr;
}
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Cancel();
m_autonomousCommand = nullptr;
}
}
void Robot::TeleopPeriodic() {
frc::Scheduler::GetInstance()->Run();
}
void Robot::TeleopPeriodic() { frc::Scheduler::GetInstance()->Run(); }
void Robot::TestPeriodic() {}

View File

@@ -17,24 +17,24 @@
#include "Subsystems/ExampleSubsystem.h"
class Robot : public frc::TimedRobot {
public:
static ExampleSubsystem m_subsystem;
static OI m_oi;
public:
static ExampleSubsystem m_subsystem;
static OI m_oi;
void RobotInit() override;
void DisabledInit() override;
void DisabledPeriodic() override;
void AutonomousInit() override;
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
void RobotInit() override;
void DisabledInit() override;
void DisabledPeriodic() override;
void AutonomousInit() override;
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
private:
// Have it null by default so that if testing teleop it
// doesn't have undefined behavior and potentially crash.
frc::Command* m_autonomousCommand = nullptr;
ExampleCommand m_defaultAuto;
MyAutoCommand m_myAuto;
frc::SendableChooser<frc::Command*> m_chooser;
private:
// Have it null by default so that if testing teleop it
// doesn't have undefined behavior and potentially crash.
frc::Command* m_autonomousCommand = nullptr;
ExampleCommand m_defaultAuto;
MyAutoCommand m_myAuto;
frc::SendableChooser<frc::Command*> m_chooser;
};

View File

@@ -9,12 +9,11 @@
#include "../RobotMap.h"
ExampleSubsystem::ExampleSubsystem()
: frc::Subsystem("ExampleSubsystem") {}
ExampleSubsystem::ExampleSubsystem() : frc::Subsystem("ExampleSubsystem") {}
void ExampleSubsystem::InitDefaultCommand() {
// Set the default command for a subsystem here.
// SetDefaultCommand(new MySpecialCommand());
// Set the default command for a subsystem here.
// SetDefaultCommand(new MySpecialCommand());
}
// Put methods for controlling this subsystem

View File

@@ -10,11 +10,11 @@
#include <Commands/Subsystem.h>
class ExampleSubsystem : public frc::Subsystem {
public:
ExampleSubsystem();
void InitDefaultCommand() override;
public:
ExampleSubsystem();
void InitDefaultCommand() override;
private:
// It's desirable that everything possible under private except
// for methods that implement subsystem capabilities
private:
// It's desirable that everything possible under private except
// for methods that implement subsystem capabilities
};

View File

@@ -12,9 +12,9 @@
#include <SmartDashboard/SmartDashboard.h>
void Robot::RobotInit() {
m_chooser.AddDefault(kAutoNameDefault, kAutoNameDefault);
m_chooser.AddObject(kAutoNameCustom, kAutoNameCustom);
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
m_chooser.AddDefault(kAutoNameDefault, kAutoNameDefault);
m_chooser.AddObject(kAutoNameCustom, kAutoNameCustom);
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
}
/**
@@ -29,24 +29,24 @@ void Robot::RobotInit() {
* make sure to add them to the chooser code above as well.
*/
void Robot::AutonomousInit() {
m_autoSelected = m_chooser.GetSelected();
// m_autoSelected = SmartDashboard::GetString(
// "Auto Selector", kAutoNameDefault);
std::cout << "Auto selected: " << m_autoSelected << std::endl;
m_autoSelected = m_chooser.GetSelected();
// m_autoSelected = SmartDashboard::GetString(
// "Auto Selector", kAutoNameDefault);
std::cout << "Auto selected: " << m_autoSelected << std::endl;
if (m_autoSelected == kAutoNameCustom) {
// Custom Auto goes here
} else {
// Default Auto goes here
}
if (m_autoSelected == kAutoNameCustom) {
// Custom Auto goes here
} else {
// Default Auto goes here
}
}
void Robot::AutonomousPeriodic() {
if (m_autoSelected == kAutoNameCustom) {
// Custom Auto goes here
} else {
// Default Auto goes here
}
if (m_autoSelected == kAutoNameCustom) {
// Custom Auto goes here
} else {
// Default Auto goes here
}
}
void Robot::TeleopInit() {}

View File

@@ -13,17 +13,17 @@
#include <SmartDashboard/SendableChooser.h>
class Robot : public frc::IterativeRobot {
public:
void RobotInit() override;
void AutonomousInit() override;
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
public:
void RobotInit() override;
void AutonomousInit() override;
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
private:
frc::SendableChooser<std::string> m_chooser;
const std::string kAutoNameDefault = "Default";
const std::string kAutoNameCustom = "My Auto";
std::string m_autoSelected;
private:
frc::SendableChooser<std::string> m_chooser;
const std::string kAutoNameDefault = "Default";
const std::string kAutoNameCustom = "My Auto";
std::string m_autoSelected;
};

View File

@@ -13,15 +13,15 @@
#include <Timer.h>
Robot::Robot() {
// Note SmartDashboard is not initialized here, wait until
// RobotInit to make SmartDashboard calls
m_robotDrive.SetExpiration(0.1);
// Note SmartDashboard is not initialized here, wait until RobotInit() to make
// SmartDashboard calls
m_robotDrive.SetExpiration(0.1);
}
void Robot::RobotInit() {
m_chooser.AddDefault(kAutoNameDefault, kAutoNameDefault);
m_chooser.AddObject(kAutoNameCustom, kAutoNameCustom);
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
m_chooser.AddDefault(kAutoNameDefault, kAutoNameDefault);
m_chooser.AddObject(kAutoNameCustom, kAutoNameCustom);
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
}
/**
@@ -36,51 +36,50 @@ void Robot::RobotInit() {
* make sure to add them to the chooser code above as well.
*/
void Robot::Autonomous() {
std::string autoSelected = m_chooser.GetSelected();
// std::string autoSelected = frc::SmartDashboard::GetString(
// "Auto Selector", kAutoNameDefault);
std::cout << "Auto selected: " << autoSelected << std::endl;
std::string autoSelected = m_chooser.GetSelected();
// std::string autoSelected = frc::SmartDashboard::GetString(
// "Auto Selector", kAutoNameDefault);
std::cout << "Auto selected: " << autoSelected << std::endl;
// MotorSafety improves safety when motors are updated in loops
// but is disabled here because motor updates are not looped in
// this autonomous mode.
m_robotDrive.SetSafetyEnabled(false);
// MotorSafety improves safety when motors are updated in loops but is
// disabled here because motor updates are not looped in this autonomous mode.
m_robotDrive.SetSafetyEnabled(false);
if (autoSelected == kAutoNameCustom) {
// Custom Auto goes here
std::cout << "Running custom Autonomous" << std::endl;
if (autoSelected == kAutoNameCustom) {
// Custom Auto goes here
std::cout << "Running custom Autonomous" << std::endl;
// Spin at half speed for two seconds
m_robotDrive.ArcadeDrive(0.0, 0.5);
frc::Wait(2.0);
// Spin at half speed for two seconds
m_robotDrive.ArcadeDrive(0.0, 0.5);
frc::Wait(2.0);
// Stop robot
m_robotDrive.ArcadeDrive(0.0, 0.0);
} else {
// Default Auto goes here
std::cout << "Running default Autonomous" << std::endl;
// Stop robot
m_robotDrive.ArcadeDrive(0.0, 0.0);
} else {
// Default Auto goes here
std::cout << "Running default Autonomous" << std::endl;
// Drive forwards at half speed for two seconds
m_robotDrive.ArcadeDrive(-0.5, 0.0);
frc::Wait(2.0);
// Drive forwards at half speed for two seconds
m_robotDrive.ArcadeDrive(-0.5, 0.0);
frc::Wait(2.0);
// Stop robot
m_robotDrive.ArcadeDrive(0.0, 0.0);
}
// Stop robot
m_robotDrive.ArcadeDrive(0.0, 0.0);
}
}
/**
* Runs the motors with arcade steering.
*/
void Robot::OperatorControl() {
m_robotDrive.SetSafetyEnabled(true);
while (IsOperatorControl() && IsEnabled()) {
// Drive with arcade style (use right stick)
m_robotDrive.ArcadeDrive(-m_stick.GetY(), m_stick.GetX());
m_robotDrive.SetSafetyEnabled(true);
while (IsOperatorControl() && IsEnabled()) {
// Drive with arcade style (use right stick)
m_robotDrive.ArcadeDrive(-m_stick.GetY(), m_stick.GetX());
// The motors will be updated every 5ms
frc::Wait(0.005);
}
// The motors will be updated every 5ms
frc::Wait(0.005);
}
}
/**

View File

@@ -16,11 +16,10 @@
#include <Spark.h>
/**
* This is a demo program showing the use of the DifferentialDrive class.
* The SampleRobot class is the base of a robot application that will
* automatically call your Autonomous and OperatorControl methods at the right
* time as controlled by the switches on the driver station or the field
* controls.
* This is a demo program showing the use of the DifferentialDrive class. The
* SampleRobot class is the base of a robot application that will automatically
* call your Autonomous and OperatorControl methods at the right time as
* controlled by the switches on the driver station or the field controls.
*
* WARNING: While it may look like a good choice to use for your code if you're
* inexperienced, don't. Unless you know what you are doing, complex code will
@@ -28,23 +27,23 @@
* instead if you're new.
*/
class Robot : public frc::SampleRobot {
public:
Robot();
public:
Robot();
void RobotInit() override;
void Autonomous() override;
void OperatorControl() override;
void Test() override;
void RobotInit() override;
void Autonomous() override;
void OperatorControl() override;
void Test() override;
private:
// Robot drive system
frc::Spark m_leftMotor{0};
frc::Spark m_rightMotor{1};
frc::DifferentialDrive m_robotDrive{m_leftMotor, m_rightMotor};
private:
// Robot drive system
frc::Spark m_leftMotor{0};
frc::Spark m_rightMotor{1};
frc::DifferentialDrive m_robotDrive{m_leftMotor, m_rightMotor};
frc::Joystick m_stick{0};
frc::Joystick m_stick{0};
frc::SendableChooser<std::string> m_chooser;
const std::string kAutoNameDefault = "Default";
const std::string kAutoNameCustom = "My Auto";
frc::SendableChooser<std::string> m_chooser;
const std::string kAutoNameDefault = "Default";
const std::string kAutoNameCustom = "My Auto";
};

View File

@@ -12,9 +12,9 @@
#include <SmartDashboard/SmartDashboard.h>
void Robot::RobotInit() {
m_chooser.AddDefault(kAutoNameDefault, kAutoNameDefault);
m_chooser.AddObject(kAutoNameCustom, kAutoNameCustom);
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
m_chooser.AddDefault(kAutoNameDefault, kAutoNameDefault);
m_chooser.AddObject(kAutoNameCustom, kAutoNameCustom);
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
}
/**
@@ -29,24 +29,24 @@ void Robot::RobotInit() {
* make sure to add them to the chooser code above as well.
*/
void Robot::AutonomousInit() {
m_autoSelected = m_chooser.GetSelected();
// m_autoSelected = SmartDashboard::GetString("Auto Selector",
// kAutoNameDefault);
std::cout << "Auto selected: " << m_autoSelected << std::endl;
m_autoSelected = m_chooser.GetSelected();
// m_autoSelected = SmartDashboard::GetString("Auto Selector",
// kAutoNameDefault);
std::cout << "Auto selected: " << m_autoSelected << std::endl;
if (m_autoSelected == kAutoNameCustom) {
// Custom Auto goes here
} else {
// Default Auto goes here
}
if (m_autoSelected == kAutoNameCustom) {
// Custom Auto goes here
} else {
// Default Auto goes here
}
}
void Robot::AutonomousPeriodic() {
if (m_autoSelected == kAutoNameCustom) {
// Custom Auto goes here
} else {
// Default Auto goes here
}
if (m_autoSelected == kAutoNameCustom) {
// Custom Auto goes here
} else {
// Default Auto goes here
}
}
void Robot::TeleopInit() {}

View File

@@ -13,17 +13,17 @@
#include <TimedRobot.h>
class Robot : public frc::TimedRobot {
public:
void RobotInit() override;
void AutonomousInit() override;
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
public:
void RobotInit() override;
void AutonomousInit() override;
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
private:
frc::SendableChooser<std::string> m_chooser;
const std::string kAutoNameDefault = "Default";
const std::string kAutoNameCustom = "My Auto";
std::string m_autoSelected;
private:
frc::SendableChooser<std::string> m_chooser;
const std::string kAutoNameDefault = "Default";
const std::string kAutoNameCustom = "My Auto";
std::string m_autoSelected;
};