mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Add braces to C++ single-line loops and conditionals (NFC) (#2973)
This makes code easier to read and more consistent between C++ and Java. Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
@@ -52,5 +52,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -25,5 +25,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -30,5 +30,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,14 +17,18 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
* can use it to reset any subsystem information you want to clear when the
|
||||
* robot is disabled.
|
||||
*/
|
||||
void Robot::DisabledInit() { m_container.DisablePIDSubsystems(); }
|
||||
void Robot::DisabledInit() {
|
||||
m_container.DisablePIDSubsystems();
|
||||
}
|
||||
|
||||
void Robot::DisabledPeriodic() {}
|
||||
|
||||
@@ -64,5 +68,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -55,7 +55,9 @@ void RobotContainer::ConfigureButtonBindings() {
|
||||
.WhenReleased([this] { m_drive.SetMaxOutput(1); });
|
||||
}
|
||||
|
||||
void RobotContainer::DisablePIDSubsystems() { m_arm.Disable(); }
|
||||
void RobotContainer::DisablePIDSubsystems() {
|
||||
m_arm.Disable();
|
||||
}
|
||||
|
||||
frc2::Command* RobotContainer::GetAutonomousCommand() {
|
||||
// Runs the chosen command in autonomous
|
||||
|
||||
@@ -35,9 +35,13 @@ double DriveSubsystem::GetAverageEncoderDistance() {
|
||||
return (m_leftEncoder.GetDistance() + m_rightEncoder.GetDistance()) / 2.;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() { return m_leftEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() {
|
||||
return m_leftEncoder;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() { return m_rightEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() {
|
||||
return m_rightEncoder;
|
||||
}
|
||||
|
||||
void DriveSubsystem::SetMaxOutput(double maxOutput) {
|
||||
m_drive.SetMaxOutput(maxOutput);
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -35,9 +35,13 @@ double DriveSubsystem::GetAverageEncoderDistance() {
|
||||
return (m_leftEncoder.GetDistance() + m_rightEncoder.GetDistance()) / 2.0;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() { return m_leftEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() {
|
||||
return m_leftEncoder;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() { return m_rightEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() {
|
||||
return m_rightEncoder;
|
||||
}
|
||||
|
||||
void DriveSubsystem::SetMaxOutput(double maxOutput) {
|
||||
m_drive.SetMaxOutput(maxOutput);
|
||||
|
||||
@@ -101,5 +101,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -58,5 +58,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -35,5 +35,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -75,5 +75,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -45,5 +45,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -45,5 +45,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -37,5 +37,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -28,5 +28,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -48,5 +48,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -100,5 +100,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -61,5 +61,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -79,5 +79,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -35,9 +35,13 @@ double DriveSubsystem::GetAverageEncoderDistance() {
|
||||
return (m_leftEncoder.GetDistance() + m_rightEncoder.GetDistance()) / 2.0;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() { return m_leftEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() {
|
||||
return m_leftEncoder;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() { return m_rightEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() {
|
||||
return m_rightEncoder;
|
||||
}
|
||||
|
||||
void DriveSubsystem::SetMaxOutput(double maxOutput) {
|
||||
m_drive.SetMaxOutput(maxOutput);
|
||||
|
||||
@@ -26,10 +26,18 @@ void ShooterSubsystem::UseOutput(double output, double setpoint) {
|
||||
m_shooterFeedforward.Calculate(kShooterTargetRPS));
|
||||
}
|
||||
|
||||
bool ShooterSubsystem::AtSetpoint() { return m_controller.AtSetpoint(); }
|
||||
bool ShooterSubsystem::AtSetpoint() {
|
||||
return m_controller.AtSetpoint();
|
||||
}
|
||||
|
||||
double ShooterSubsystem::GetMeasurement() { return m_shooterEncoder.GetRate(); }
|
||||
double ShooterSubsystem::GetMeasurement() {
|
||||
return m_shooterEncoder.GetRate();
|
||||
}
|
||||
|
||||
void ShooterSubsystem::RunFeeder() { m_feederMotor.Set(kFeederSpeed); }
|
||||
void ShooterSubsystem::RunFeeder() {
|
||||
m_feederMotor.Set(kFeederSpeed);
|
||||
}
|
||||
|
||||
void ShooterSubsystem::StopFeeder() { m_feederMotor.Set(0); }
|
||||
void ShooterSubsystem::StopFeeder() {
|
||||
m_feederMotor.Set(0);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,10 +12,14 @@ CloseClaw::CloseClaw(Claw* claw) : m_claw(claw) {
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
void CloseClaw::Initialize() { m_claw->Close(); }
|
||||
void CloseClaw::Initialize() {
|
||||
m_claw->Close();
|
||||
}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
bool CloseClaw::IsFinished() { return m_claw->IsGripping(); }
|
||||
bool CloseClaw::IsFinished() {
|
||||
return m_claw->IsGripping();
|
||||
}
|
||||
|
||||
// Called once after isFinished returns true
|
||||
void CloseClaw::End(bool) {
|
||||
|
||||
@@ -25,4 +25,6 @@ void DriveStraight::Initialize() {
|
||||
frc2::PIDCommand::Initialize();
|
||||
}
|
||||
|
||||
bool DriveStraight::IsFinished() { return m_controller.AtSetpoint(); }
|
||||
bool DriveStraight::IsFinished() {
|
||||
return m_controller.AtSetpoint();
|
||||
}
|
||||
|
||||
@@ -19,4 +19,6 @@ void OpenClaw::Initialize() {
|
||||
}
|
||||
|
||||
// Called once after isFinished returns true
|
||||
void OpenClaw::End(bool) { m_claw->Stop(); }
|
||||
void OpenClaw::End(bool) {
|
||||
m_claw->Stop();
|
||||
}
|
||||
|
||||
@@ -25,4 +25,6 @@ void SetDistanceToBox::Initialize() {
|
||||
frc2::PIDCommand::Initialize();
|
||||
}
|
||||
|
||||
bool SetDistanceToBox::IsFinished() { return m_controller.AtSetpoint(); }
|
||||
bool SetDistanceToBox::IsFinished() {
|
||||
return m_controller.AtSetpoint();
|
||||
}
|
||||
|
||||
@@ -14,10 +14,16 @@ TankDrive::TankDrive(std::function<double()> left,
|
||||
}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
void TankDrive::Execute() { m_drivetrain->Drive(m_left(), m_right()); }
|
||||
void TankDrive::Execute() {
|
||||
m_drivetrain->Drive(m_left(), m_right());
|
||||
}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
bool TankDrive::IsFinished() { return false; }
|
||||
bool TankDrive::IsFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Called once after isFinished returns true
|
||||
void TankDrive::End(bool) { m_drivetrain->Drive(0, 0); }
|
||||
void TankDrive::End(bool) {
|
||||
m_drivetrain->Drive(0, 0);
|
||||
}
|
||||
|
||||
@@ -12,16 +12,26 @@ Claw::Claw() {
|
||||
AddChild("Motor", &m_motor);
|
||||
}
|
||||
|
||||
void Claw::Open() { m_motor.Set(-1); }
|
||||
void Claw::Open() {
|
||||
m_motor.Set(-1);
|
||||
}
|
||||
|
||||
void Claw::Close() { m_motor.Set(1); }
|
||||
void Claw::Close() {
|
||||
m_motor.Set(1);
|
||||
}
|
||||
|
||||
void Claw::Stop() { m_motor.Set(0); }
|
||||
void Claw::Stop() {
|
||||
m_motor.Set(0);
|
||||
}
|
||||
|
||||
bool Claw::IsGripping() { return m_contact.Get(); }
|
||||
bool Claw::IsGripping() {
|
||||
return m_contact.Get();
|
||||
}
|
||||
|
||||
void Claw::Log() {
|
||||
frc::SmartDashboard::PutBoolean("Claw switch", IsGripping());
|
||||
}
|
||||
|
||||
void Claw::Periodic() { Log(); }
|
||||
void Claw::Periodic() {
|
||||
Log();
|
||||
}
|
||||
|
||||
@@ -50,7 +50,9 @@ void DriveTrain::Drive(double left, double right) {
|
||||
m_robotDrive.TankDrive(left, right);
|
||||
}
|
||||
|
||||
double DriveTrain::GetHeading() { return m_gyro.GetAngle(); }
|
||||
double DriveTrain::GetHeading() {
|
||||
return m_gyro.GetAngle();
|
||||
}
|
||||
|
||||
void DriveTrain::Reset() {
|
||||
m_gyro.Reset();
|
||||
@@ -67,4 +69,6 @@ double DriveTrain::GetDistanceToObstacle() {
|
||||
return m_rangefinder.GetAverageVoltage();
|
||||
}
|
||||
|
||||
void DriveTrain::Periodic() { Log(); }
|
||||
void DriveTrain::Periodic() {
|
||||
Log();
|
||||
}
|
||||
|
||||
@@ -21,12 +21,18 @@ Elevator::Elevator()
|
||||
AddChild("Pot", &m_pot);
|
||||
}
|
||||
|
||||
void Elevator::Log() { frc::SmartDashboard::PutData("Wrist Pot", &m_pot); }
|
||||
void Elevator::Log() {
|
||||
frc::SmartDashboard::PutData("Wrist Pot", &m_pot);
|
||||
}
|
||||
|
||||
double Elevator::GetMeasurement() { return m_pot.Get(); }
|
||||
double Elevator::GetMeasurement() {
|
||||
return m_pot.Get();
|
||||
}
|
||||
|
||||
void Elevator::UseOutput(double output, double setpoint) {
|
||||
m_motor.Set(output);
|
||||
}
|
||||
|
||||
void Elevator::Periodic() { Log(); }
|
||||
void Elevator::Periodic() {
|
||||
Log();
|
||||
}
|
||||
|
||||
@@ -23,8 +23,14 @@ void Wrist::Log() {
|
||||
frc::SmartDashboard::PutNumber("Wrist Angle", GetMeasurement());
|
||||
}
|
||||
|
||||
double Wrist::GetMeasurement() { return m_pot.Get(); }
|
||||
double Wrist::GetMeasurement() {
|
||||
return m_pot.Get();
|
||||
}
|
||||
|
||||
void Wrist::UseOutput(double output, double setpoint) { m_motor.Set(output); }
|
||||
void Wrist::UseOutput(double output, double setpoint) {
|
||||
m_motor.Set(output);
|
||||
}
|
||||
|
||||
void Wrist::Periodic() { Log(); }
|
||||
void Wrist::Periodic() {
|
||||
Log();
|
||||
}
|
||||
|
||||
@@ -53,5 +53,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -53,5 +53,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -30,4 +30,6 @@ TurnToAngle::TurnToAngle(units::degree_t target, DriveSubsystem* drive)
|
||||
AddRequirements({drive});
|
||||
}
|
||||
|
||||
bool TurnToAngle::IsFinished() { return GetController().AtSetpoint(); }
|
||||
bool TurnToAngle::IsFinished() {
|
||||
return GetController().AtSetpoint();
|
||||
}
|
||||
|
||||
@@ -33,4 +33,6 @@ TurnToAngleProfiled::TurnToAngleProfiled(units::degree_t target,
|
||||
AddRequirements({drive});
|
||||
}
|
||||
|
||||
bool TurnToAngleProfiled::IsFinished() { return GetController().AtGoal(); }
|
||||
bool TurnToAngleProfiled::IsFinished() {
|
||||
return GetController().AtGoal();
|
||||
}
|
||||
|
||||
@@ -35,9 +35,13 @@ double DriveSubsystem::GetAverageEncoderDistance() {
|
||||
return (m_leftEncoder.GetDistance() + m_rightEncoder.GetDistance()) / 2.0;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() { return m_leftEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() {
|
||||
return m_leftEncoder;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() { return m_rightEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() {
|
||||
return m_rightEncoder;
|
||||
}
|
||||
|
||||
void DriveSubsystem::SetMaxOutput(double maxOutput) {
|
||||
m_drive.SetMaxOutput(maxOutput);
|
||||
|
||||
@@ -56,5 +56,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -35,9 +35,13 @@ double DriveSubsystem::GetAverageEncoderDistance() {
|
||||
return (m_leftEncoder.GetDistance() + m_rightEncoder.GetDistance()) / 2.0;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() { return m_leftEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() {
|
||||
return m_leftEncoder;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() { return m_rightEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() {
|
||||
return m_rightEncoder;
|
||||
}
|
||||
|
||||
void DriveSubsystem::SetMaxOutput(double maxOutput) {
|
||||
m_drive.SetMaxOutput(maxOutput);
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,9 +17,13 @@ void DriveDistance::Initialize() {
|
||||
m_drive->ArcadeDrive(m_speed, 0);
|
||||
}
|
||||
|
||||
void DriveDistance::Execute() { m_drive->ArcadeDrive(m_speed, 0); }
|
||||
void DriveDistance::Execute() {
|
||||
m_drive->ArcadeDrive(m_speed, 0);
|
||||
}
|
||||
|
||||
void DriveDistance::End(bool interrupted) { m_drive->ArcadeDrive(0, 0); }
|
||||
void DriveDistance::End(bool interrupted) {
|
||||
m_drive->ArcadeDrive(0, 0);
|
||||
}
|
||||
|
||||
bool DriveDistance::IsFinished() {
|
||||
return std::abs(m_drive->GetAverageEncoderDistance()) >= m_distance;
|
||||
|
||||
@@ -8,6 +8,10 @@ GrabHatch::GrabHatch(HatchSubsystem* subsystem) : m_hatch(subsystem) {
|
||||
AddRequirements({subsystem});
|
||||
}
|
||||
|
||||
void GrabHatch::Initialize() { m_hatch->GrabHatch(); }
|
||||
void GrabHatch::Initialize() {
|
||||
m_hatch->GrabHatch();
|
||||
}
|
||||
|
||||
bool GrabHatch::IsFinished() { return true; }
|
||||
bool GrabHatch::IsFinished() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
HalveDriveSpeed::HalveDriveSpeed(DriveSubsystem* subsystem)
|
||||
: m_drive(subsystem) {}
|
||||
|
||||
void HalveDriveSpeed::Initialize() { m_drive->SetMaxOutput(0.5); }
|
||||
void HalveDriveSpeed::Initialize() {
|
||||
m_drive->SetMaxOutput(0.5);
|
||||
}
|
||||
|
||||
void HalveDriveSpeed::End(bool interrupted) { m_drive->SetMaxOutput(1); }
|
||||
void HalveDriveSpeed::End(bool interrupted) {
|
||||
m_drive->SetMaxOutput(1);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ ReleaseHatch::ReleaseHatch(HatchSubsystem* subsystem) : m_hatch(subsystem) {
|
||||
AddRequirements({subsystem});
|
||||
}
|
||||
|
||||
void ReleaseHatch::Initialize() { m_hatch->ReleaseHatch(); }
|
||||
void ReleaseHatch::Initialize() {
|
||||
m_hatch->ReleaseHatch();
|
||||
}
|
||||
|
||||
bool ReleaseHatch::IsFinished() { return true; }
|
||||
bool ReleaseHatch::IsFinished() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,13 @@ double DriveSubsystem::GetAverageEncoderDistance() {
|
||||
return (m_leftEncoder.GetDistance() + m_rightEncoder.GetDistance()) / 2.0;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() { return m_leftEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() {
|
||||
return m_leftEncoder;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() { return m_rightEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() {
|
||||
return m_rightEncoder;
|
||||
}
|
||||
|
||||
void DriveSubsystem::SetMaxOutput(double maxOutput) {
|
||||
m_drive.SetMaxOutput(maxOutput);
|
||||
|
||||
@@ -28,5 +28,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -71,5 +71,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -54,5 +54,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -77,7 +77,9 @@ frc::Encoder& DriveSubsystem::GetFrontLeftEncoder() {
|
||||
return m_frontLeftEncoder;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetRearLeftEncoder() { return m_rearLeftEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetRearLeftEncoder() {
|
||||
return m_rearLeftEncoder;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetFrontRightEncoder() {
|
||||
return m_frontRightEncoder;
|
||||
@@ -103,11 +105,17 @@ units::degree_t DriveSubsystem::GetHeading() const {
|
||||
return m_gyro.GetRotation2d().Degrees();
|
||||
}
|
||||
|
||||
void DriveSubsystem::ZeroHeading() { m_gyro.Reset(); }
|
||||
void DriveSubsystem::ZeroHeading() {
|
||||
m_gyro.Reset();
|
||||
}
|
||||
|
||||
double DriveSubsystem::GetTurnRate() { return -m_gyro.GetRate(); }
|
||||
double DriveSubsystem::GetTurnRate() {
|
||||
return -m_gyro.GetRate();
|
||||
}
|
||||
|
||||
frc::Pose2d DriveSubsystem::GetPose() { return m_odometry.GetPose(); }
|
||||
frc::Pose2d DriveSubsystem::GetPose() {
|
||||
return m_odometry.GetPose();
|
||||
}
|
||||
|
||||
void DriveSubsystem::ResetOdometry(frc::Pose2d pose) {
|
||||
m_odometry.ResetPosition(pose, m_gyro.GetRotation2d());
|
||||
|
||||
@@ -46,5 +46,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -54,5 +54,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -24,5 +24,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -45,5 +45,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -35,4 +35,6 @@ OI::OI() {
|
||||
new SetCollectionSpeed(Collector::kReverse));
|
||||
}
|
||||
|
||||
frc::Joystick& OI::GetJoystick() { return m_joystick; }
|
||||
frc::Joystick& OI::GetJoystick() {
|
||||
return m_joystick;
|
||||
}
|
||||
|
||||
@@ -61,9 +61,13 @@ void Robot::TeleopPeriodic() {
|
||||
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
void Robot::DisabledInit() { shooter.Unlatch(); }
|
||||
void Robot::DisabledInit() {
|
||||
shooter.Unlatch();
|
||||
}
|
||||
|
||||
void Robot::DisabledPeriodic() { Log(); }
|
||||
void Robot::DisabledPeriodic() {
|
||||
Log();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log interesting values to the SmartDashboard.
|
||||
@@ -78,5 +82,7 @@ void Robot::Log() {
|
||||
}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
CheckForHotGoal::CheckForHotGoal(double time) { SetTimeout(time); }
|
||||
CheckForHotGoal::CheckForHotGoal(double time) {
|
||||
SetTimeout(time);
|
||||
}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
bool CheckForHotGoal::IsFinished() {
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
CloseClaw::CloseClaw() { Requires(&Robot::collector); }
|
||||
CloseClaw::CloseClaw() {
|
||||
Requires(&Robot::collector);
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
void CloseClaw::Initialize() { Robot::collector.Close(); }
|
||||
void CloseClaw::Initialize() {
|
||||
Robot::collector.Close();
|
||||
}
|
||||
|
||||
@@ -14,9 +14,13 @@ void DriveForward::init(double dist, double maxSpeed) {
|
||||
m_driveForwardSpeed = maxSpeed;
|
||||
}
|
||||
|
||||
DriveForward::DriveForward() { init(10, 0.5); }
|
||||
DriveForward::DriveForward() {
|
||||
init(10, 0.5);
|
||||
}
|
||||
|
||||
DriveForward::DriveForward(double dist) { init(dist, 0.5); }
|
||||
DriveForward::DriveForward(double dist) {
|
||||
init(dist, 0.5);
|
||||
}
|
||||
|
||||
DriveForward::DriveForward(double dist, double maxSpeed) {
|
||||
init(dist, maxSpeed);
|
||||
@@ -45,4 +49,6 @@ bool DriveForward::IsFinished() {
|
||||
}
|
||||
|
||||
// Called once after isFinished returns true
|
||||
void DriveForward::End() { Robot::drivetrain.Stop(); }
|
||||
void DriveForward::End() {
|
||||
Robot::drivetrain.Stop();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
DriveWithJoystick::DriveWithJoystick() { Requires(&Robot::drivetrain); }
|
||||
DriveWithJoystick::DriveWithJoystick() {
|
||||
Requires(&Robot::drivetrain);
|
||||
}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
void DriveWithJoystick::Execute() {
|
||||
@@ -15,7 +17,11 @@ void DriveWithJoystick::Execute() {
|
||||
}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
bool DriveWithJoystick::IsFinished() { return false; }
|
||||
bool DriveWithJoystick::IsFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Called once after isFinished returns true
|
||||
void DriveWithJoystick::End() { Robot::drivetrain.Stop(); }
|
||||
void DriveWithJoystick::End() {
|
||||
Robot::drivetrain.Stop();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,11 @@ ExtendShooter::ExtendShooter() : frc::TimedCommand(1.0) {
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
void ExtendShooter::Initialize() { Robot::shooter.ExtendBoth(); }
|
||||
void ExtendShooter::Initialize() {
|
||||
Robot::shooter.ExtendBoth();
|
||||
}
|
||||
|
||||
// Called once after isFinished returns true
|
||||
void ExtendShooter::End() { Robot::shooter.RetractBoth(); }
|
||||
void ExtendShooter::End() {
|
||||
Robot::shooter.RetractBoth();
|
||||
}
|
||||
|
||||
@@ -6,10 +6,16 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
OpenClaw::OpenClaw() { Requires(&Robot::collector); }
|
||||
OpenClaw::OpenClaw() {
|
||||
Requires(&Robot::collector);
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
void OpenClaw::Initialize() { Robot::collector.Open(); }
|
||||
void OpenClaw::Initialize() {
|
||||
Robot::collector.Open();
|
||||
}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
bool OpenClaw::IsFinished() { return Robot::collector.IsOpen(); }
|
||||
bool OpenClaw::IsFinished() {
|
||||
return Robot::collector.IsOpen();
|
||||
}
|
||||
|
||||
@@ -12,4 +12,6 @@ SetCollectionSpeed::SetCollectionSpeed(double speed) {
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
void SetCollectionSpeed::Initialize() { Robot::collector.SetSpeed(m_speed); }
|
||||
void SetCollectionSpeed::Initialize() {
|
||||
Robot::collector.SetSpeed(m_speed);
|
||||
}
|
||||
|
||||
@@ -18,4 +18,6 @@ void SetPivotSetpoint::Initialize() {
|
||||
}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
bool SetPivotSetpoint::IsFinished() { return Robot::pivot.OnTarget(); }
|
||||
bool SetPivotSetpoint::IsFinished() {
|
||||
return Robot::pivot.OnTarget();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
WaitForBall::WaitForBall() { Requires(&Robot::collector); }
|
||||
WaitForBall::WaitForBall() {
|
||||
Requires(&Robot::collector);
|
||||
}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
bool WaitForBall::IsFinished() { return Robot::collector.HasBall(); }
|
||||
bool WaitForBall::IsFinished() {
|
||||
return Robot::collector.HasBall();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
WaitForPressure::WaitForPressure() { Requires(&Robot::pneumatics); }
|
||||
WaitForPressure::WaitForPressure() {
|
||||
Requires(&Robot::pneumatics);
|
||||
}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
bool WaitForPressure::IsFinished() { return Robot::pneumatics.IsPressurized(); }
|
||||
bool WaitForPressure::IsFinished() {
|
||||
return Robot::pneumatics.IsPressurized();
|
||||
}
|
||||
|
||||
@@ -18,16 +18,24 @@ bool Collector::HasBall() {
|
||||
return m_ballDetector.Get(); // TODO: prepend ! to reflect real robot
|
||||
}
|
||||
|
||||
void Collector::SetSpeed(double speed) { m_rollerMotor.Set(-speed); }
|
||||
void Collector::SetSpeed(double speed) {
|
||||
m_rollerMotor.Set(-speed);
|
||||
}
|
||||
|
||||
void Collector::Stop() { m_rollerMotor.Set(0); }
|
||||
void Collector::Stop() {
|
||||
m_rollerMotor.Set(0);
|
||||
}
|
||||
|
||||
bool Collector::IsOpen() {
|
||||
return m_openDetector.Get(); // TODO: prepend ! to reflect real robot
|
||||
}
|
||||
|
||||
void Collector::Open() { m_piston.Set(true); }
|
||||
void Collector::Open() {
|
||||
m_piston.Set(true);
|
||||
}
|
||||
|
||||
void Collector::Close() { m_piston.Set(false); }
|
||||
void Collector::Close() {
|
||||
m_piston.Set(false);
|
||||
}
|
||||
|
||||
void Collector::InitDefaultCommand() {}
|
||||
|
||||
@@ -58,10 +58,18 @@ void DriveTrain::TankDrive(double leftAxis, double rightAxis) {
|
||||
m_robotDrive.TankDrive(leftAxis, rightAxis);
|
||||
}
|
||||
|
||||
void DriveTrain::Stop() { m_robotDrive.TankDrive(0.0, 0.0); }
|
||||
void DriveTrain::Stop() {
|
||||
m_robotDrive.TankDrive(0.0, 0.0);
|
||||
}
|
||||
|
||||
frc::Encoder& DriveTrain::GetLeftEncoder() { return m_leftEncoder; }
|
||||
frc::Encoder& DriveTrain::GetLeftEncoder() {
|
||||
return m_leftEncoder;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveTrain::GetRightEncoder() { return m_rightEncoder; }
|
||||
frc::Encoder& DriveTrain::GetRightEncoder() {
|
||||
return m_rightEncoder;
|
||||
}
|
||||
|
||||
double DriveTrain::GetAngle() { return m_gyro.GetAngle(); }
|
||||
double DriveTrain::GetAngle() {
|
||||
return m_gyro.GetAngle();
|
||||
}
|
||||
|
||||
@@ -22,9 +22,13 @@ Pivot::Pivot() : frc::PIDSubsystem("Pivot", 7.0, 0.0, 8.0) {
|
||||
|
||||
void InitDefaultCommand() {}
|
||||
|
||||
double Pivot::ReturnPIDInput() { return m_pot.Get(); }
|
||||
double Pivot::ReturnPIDInput() {
|
||||
return m_pot.Get();
|
||||
}
|
||||
|
||||
void Pivot::UsePIDOutput(double output) { m_motor.PIDWrite(output); }
|
||||
void Pivot::UsePIDOutput(double output) {
|
||||
m_motor.PIDWrite(output);
|
||||
}
|
||||
|
||||
bool Pivot::IsAtUpperLimit() {
|
||||
return m_upperLimitSwitch.Get(); // TODO: inverted from real robot
|
||||
@@ -36,4 +40,6 @@ bool Pivot::IsAtLowerLimit() {
|
||||
// (prefix with !)
|
||||
}
|
||||
|
||||
double Pivot::GetAngle() { return m_pot.Get(); }
|
||||
double Pivot::GetAngle() {
|
||||
return m_pot.Get();
|
||||
}
|
||||
|
||||
@@ -27,31 +27,55 @@ void Shooter::RetractBoth() {
|
||||
m_piston2.Set(frc::DoubleSolenoid::kReverse);
|
||||
}
|
||||
|
||||
void Shooter::Extend1() { m_piston1.Set(frc::DoubleSolenoid::kForward); }
|
||||
void Shooter::Extend1() {
|
||||
m_piston1.Set(frc::DoubleSolenoid::kForward);
|
||||
}
|
||||
|
||||
void Shooter::Retract1() { m_piston1.Set(frc::DoubleSolenoid::kReverse); }
|
||||
void Shooter::Retract1() {
|
||||
m_piston1.Set(frc::DoubleSolenoid::kReverse);
|
||||
}
|
||||
|
||||
void Shooter::Extend2() { m_piston2.Set(frc::DoubleSolenoid::kReverse); }
|
||||
void Shooter::Extend2() {
|
||||
m_piston2.Set(frc::DoubleSolenoid::kReverse);
|
||||
}
|
||||
|
||||
void Shooter::Retract2() { m_piston2.Set(frc::DoubleSolenoid::kForward); }
|
||||
void Shooter::Retract2() {
|
||||
m_piston2.Set(frc::DoubleSolenoid::kForward);
|
||||
}
|
||||
|
||||
void Shooter::Off1() { m_piston1.Set(frc::DoubleSolenoid::kOff); }
|
||||
void Shooter::Off1() {
|
||||
m_piston1.Set(frc::DoubleSolenoid::kOff);
|
||||
}
|
||||
|
||||
void Shooter::Off2() { m_piston2.Set(frc::DoubleSolenoid::kOff); }
|
||||
void Shooter::Off2() {
|
||||
m_piston2.Set(frc::DoubleSolenoid::kOff);
|
||||
}
|
||||
|
||||
void Shooter::Unlatch() { m_latchPiston.Set(true); }
|
||||
void Shooter::Unlatch() {
|
||||
m_latchPiston.Set(true);
|
||||
}
|
||||
|
||||
void Shooter::Latch() { m_latchPiston.Set(false); }
|
||||
void Shooter::Latch() {
|
||||
m_latchPiston.Set(false);
|
||||
}
|
||||
|
||||
void Shooter::ToggleLatchPosition() { m_latchPiston.Set(!m_latchPiston.Get()); }
|
||||
void Shooter::ToggleLatchPosition() {
|
||||
m_latchPiston.Set(!m_latchPiston.Get());
|
||||
}
|
||||
|
||||
bool Shooter::Piston1IsExtended() { return !m_piston1ReedSwitchFront.Get(); }
|
||||
bool Shooter::Piston1IsExtended() {
|
||||
return !m_piston1ReedSwitchFront.Get();
|
||||
}
|
||||
|
||||
bool Shooter::Piston1IsRetracted() { return !m_piston1ReedSwitchBack.Get(); }
|
||||
bool Shooter::Piston1IsRetracted() {
|
||||
return !m_piston1ReedSwitchBack.Get();
|
||||
}
|
||||
|
||||
void Shooter::OffBoth() {
|
||||
m_piston1.Set(frc::DoubleSolenoid::kOff);
|
||||
m_piston2.Set(frc::DoubleSolenoid::kOff);
|
||||
}
|
||||
|
||||
bool Shooter::GoalIsHot() { return m_hotGoalSensor.Get(); }
|
||||
bool Shooter::GoalIsHot() {
|
||||
return m_hotGoalSensor.Get();
|
||||
}
|
||||
|
||||
@@ -66,5 +66,7 @@ class Robot : public frc::TimedRobot {
|
||||
constexpr std::array<double, 3> Robot::kSetPoints;
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -25,5 +25,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -50,9 +50,13 @@ double DriveSubsystem::GetAverageEncoderDistance() {
|
||||
return (m_leftEncoder.GetDistance() + m_rightEncoder.GetDistance()) / 2.0;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() { return m_leftEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() {
|
||||
return m_leftEncoder;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() { return m_rightEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() {
|
||||
return m_rightEncoder;
|
||||
}
|
||||
|
||||
void DriveSubsystem::SetMaxOutput(double maxOutput) {
|
||||
m_drive.SetMaxOutput(maxOutput);
|
||||
@@ -62,9 +66,13 @@ units::degree_t DriveSubsystem::GetHeading() const {
|
||||
return m_gyro.GetRotation2d().Degrees();
|
||||
}
|
||||
|
||||
double DriveSubsystem::GetTurnRate() { return -m_gyro.GetRate(); }
|
||||
double DriveSubsystem::GetTurnRate() {
|
||||
return -m_gyro.GetRate();
|
||||
}
|
||||
|
||||
frc::Pose2d DriveSubsystem::GetPose() { return m_odometry.GetPose(); }
|
||||
frc::Pose2d DriveSubsystem::GetPose() {
|
||||
return m_odometry.GetPose();
|
||||
}
|
||||
|
||||
frc::DifferentialDriveWheelSpeeds DriveSubsystem::GetWheelSpeeds() {
|
||||
return {units::meters_per_second_t(m_leftEncoder.GetRate()),
|
||||
|
||||
@@ -31,4 +31,6 @@ void Drivetrain::ResetOdometry(const frc::Pose2d& pose) {
|
||||
m_odometry.ResetPosition(pose, m_gyro.GetRotation2d());
|
||||
}
|
||||
|
||||
frc::Pose2d Drivetrain::GetPose() const { return m_odometry.GetPose(); }
|
||||
frc::Pose2d Drivetrain::GetPose() const {
|
||||
return m_odometry.GetPose();
|
||||
}
|
||||
|
||||
@@ -82,5 +82,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -53,5 +53,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -77,5 +77,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -69,5 +69,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -65,5 +65,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -142,5 +142,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -79,5 +81,7 @@ void Robot::SimulationPeriodic() {
|
||||
}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -35,9 +35,13 @@ RobotContainer::RobotContainer() {
|
||||
{&m_drive}));
|
||||
}
|
||||
|
||||
void RobotContainer::ZeroAllOutputs() { m_drive.TankDriveVolts(0_V, 0_V); }
|
||||
void RobotContainer::ZeroAllOutputs() {
|
||||
m_drive.TankDriveVolts(0_V, 0_V);
|
||||
}
|
||||
|
||||
const DriveSubsystem& RobotContainer::GetRobotDrive() const { return m_drive; }
|
||||
const DriveSubsystem& RobotContainer::GetRobotDrive() const {
|
||||
return m_drive;
|
||||
}
|
||||
|
||||
void RobotContainer::ConfigureButtonBindings() {
|
||||
// Configure your button bindings here
|
||||
|
||||
@@ -75,9 +75,13 @@ double DriveSubsystem::GetAverageEncoderDistance() {
|
||||
return (m_leftEncoder.GetDistance() + m_rightEncoder.GetDistance()) / 2.0;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() { return m_leftEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetLeftEncoder() {
|
||||
return m_leftEncoder;
|
||||
}
|
||||
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() { return m_rightEncoder; }
|
||||
frc::Encoder& DriveSubsystem::GetRightEncoder() {
|
||||
return m_rightEncoder;
|
||||
}
|
||||
|
||||
void DriveSubsystem::SetMaxOutput(double maxOutput) {
|
||||
m_drive.SetMaxOutput(maxOutput);
|
||||
@@ -87,9 +91,13 @@ units::degree_t DriveSubsystem::GetHeading() const {
|
||||
return m_gyro.GetRotation2d().Degrees();
|
||||
}
|
||||
|
||||
double DriveSubsystem::GetTurnRate() { return -m_gyro.GetRate(); }
|
||||
double DriveSubsystem::GetTurnRate() {
|
||||
return -m_gyro.GetRate();
|
||||
}
|
||||
|
||||
frc::Pose2d DriveSubsystem::GetPose() { return m_odometry.GetPose(); }
|
||||
frc::Pose2d DriveSubsystem::GetPose() {
|
||||
return m_odometry.GetPose();
|
||||
}
|
||||
|
||||
frc::DifferentialDriveWheelSpeeds DriveSubsystem::GetWheelSpeeds() {
|
||||
return {units::meters_per_second_t(m_leftEncoder.GetRate()),
|
||||
|
||||
@@ -140,5 +140,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -116,5 +116,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -117,5 +117,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -54,5 +54,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,9 @@ void Robot::RobotInit() {}
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() { frc2::CommandScheduler::GetInstance().Run(); }
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
@@ -64,5 +66,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -85,11 +85,17 @@ units::degree_t DriveSubsystem::GetHeading() const {
|
||||
return m_gyro.GetRotation2d().Degrees();
|
||||
}
|
||||
|
||||
void DriveSubsystem::ZeroHeading() { m_gyro.Reset(); }
|
||||
void DriveSubsystem::ZeroHeading() {
|
||||
m_gyro.Reset();
|
||||
}
|
||||
|
||||
double DriveSubsystem::GetTurnRate() { return -m_gyro.GetRate(); }
|
||||
double DriveSubsystem::GetTurnRate() {
|
||||
return -m_gyro.GetRate();
|
||||
}
|
||||
|
||||
frc::Pose2d DriveSubsystem::GetPose() { return m_odometry.GetPose(); }
|
||||
frc::Pose2d DriveSubsystem::GetPose() {
|
||||
return m_odometry.GetPose();
|
||||
}
|
||||
|
||||
void DriveSubsystem::ResetOdometry(frc::Pose2d pose) {
|
||||
m_odometry.ResetPosition(pose,
|
||||
|
||||
@@ -54,5 +54,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -28,5 +28,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -55,5 +55,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -63,5 +63,7 @@ class Robot : public frc::TimedRobot {
|
||||
};
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user