Skip to content

Commit

Permalink
Run wpiformat
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Dec 2, 2023
1 parent 08ed91e commit d55c55b
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,21 @@ void RobotContainer::ConfigureButtonBindings() {
frc2::CommandPtr RobotContainer::GetAutonomousCommand() {
// Runs the chosen command in autonomous
return frc2::cmd::Sequence(
// Start the command by spinning up the shooter...
frc2::cmd::RunOnce([this] { m_shooter.Enable(); }, {&m_shooter}),
// Wait until the shooter is at speed before feeding the frisbees
frc2::cmd::WaitUntil([this] { return m_shooter.AtSetpoint(); }),
// Start running the feeder
frc2::cmd::RunOnce([this] { m_shooter.RunFeeder(); }, {&m_shooter}),
// Shoot for the specified time
frc2::cmd::Wait(ac::kAutoShootTimeSeconds))
// Add a timeout (will end the command if, for instance, the shooter
// never gets up to speed)
.WithTimeout(ac::kAutoTimeoutSeconds)
// When the command ends, turn off the shooter and the feeder
.AndThen(frc2::cmd::RunOnce([this] {
m_shooter.Disable();
m_shooter.StopFeeder();
}));
// Start the command by spinning up the shooter...
frc2::cmd::RunOnce([this] { m_shooter.Enable(); }, {&m_shooter}),
// Wait until the shooter is at speed before feeding the frisbees
frc2::cmd::WaitUntil([this] { return m_shooter.AtSetpoint(); }),
// Start running the feeder
frc2::cmd::RunOnce([this] { m_shooter.RunFeeder(); },
{&m_shooter}),
// Shoot for the specified time
frc2::cmd::Wait(ac::kAutoShootTimeSeconds))
// Add a timeout (will end the command if, for instance, the shooter
// never gets up to speed)
.WithTimeout(ac::kAutoTimeoutSeconds)
// When the command ends, turn off the shooter and the feeder
.AndThen(frc2::cmd::RunOnce([this] {
m_shooter.Disable();
m_shooter.StopFeeder();
}));
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,5 @@ class RobotContainer {
frc2::CommandPtr m_stopShooter =
frc2::cmd::RunOnce([this] { m_shooter.Disable(); }, {&m_shooter});


void ConfigureButtonBindings();
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#pragma once

#include <frc/XboxController.h>
#include <frc2/command/CommandPtr.h>
#include <frc2/command/Command.h>
#include <frc2/command/CommandPtr.h>

#include "commands/Autonomous.h"
#include "subsystems/Claw.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <frc/PS4Controller.h>
#include <frc/controller/PIDController.h>
#include <frc/smartdashboard/SendableChooser.h>
#include <frc2/command/CommandPtr.h>
#include <frc2/command/Command.h>
#include <frc2/command/CommandPtr.h>
#include <frc2/command/InstantCommand.h>

#include "Constants.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ frc2::CommandPtr RobotContainer::GetAutonomousCommand() {
switch (m_chooser.GetSelected()) {
case autos::AutoEnum::kSimpleAuto:
return autos::SimpleAuto(&m_drive);
break;
break;
case autos::AutoEnum::kComplexAuto:
return autos::ComplexAuto(&m_drive, &m_hatch);
break;
break;
default:
return frc2::CommandPtr(nullptr);
break;
break;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <frc/smartdashboard/SendableChooser.h>
#include <frc2/command/Command.h>
#include <frc2/command/Commands.h>
#include <frc2/command/CommandPtr.h>
#include <frc2/command/Commands.h>
#include <frc2/command/button/CommandPS4Controller.h>

#include "Constants.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ frc2::CommandPtr SimpleAuto(DriveSubsystem* drive);
*/
frc2::CommandPtr ComplexAuto(DriveSubsystem* drive, HatchSubsystem* hatch);

enum class AutoEnum {
kSimpleAuto,
kComplexAuto
};
enum class AutoEnum { kSimpleAuto, kComplexAuto };

} // namespace autos
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ frc2::CommandPtr RobotContainer::GetAutonomousCommand() {
switch (m_chooser.GetSelected()) {
case Autos::kSimpleAuto:
return DriveDistance(AutoConstants::kAutoDriveDistanceInches,
AutoConstants::kAutoDriveSpeed, &m_drive).ToPtr();
break;
AutoConstants::kAutoDriveSpeed, &m_drive)
.ToPtr();
break;
case Autos::kComplexAuto:
return ComplexAuto(&m_drive, &m_hatch).ToPtr();
break;
default:
break;
default:
return frc2::CommandPtr(nullptr);
break;
break;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <frc/XboxController.h>
#include <frc/smartdashboard/SendableChooser.h>
#include <frc2/command/CommandPtr.h>
#include <frc2/command/Command.h>
#include <frc2/command/CommandPtr.h>

#include "Constants.h"
#include "commands/ComplexAuto.h"
Expand All @@ -17,13 +17,10 @@
#include "subsystems/HatchSubsystem.h"

/**
* This is where the autos can be listed for the autonomous chooser so it can use CommandPtr
* the sendable chooser does not support the use of CommandPtr
* This is where the autos can be listed for the autonomous chooser so it can
* use CommandPtr the sendable chooser does not support the use of CommandPtr
*/
enum class Autos {
kSimpleAuto,
kComplexAuto
};
enum class Autos { kSimpleAuto, kComplexAuto };

/**
* This class is where the bulk of the robot should be declared. Since
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#include <frc/trajectory/Trajectory.h>
#include <frc/trajectory/TrajectoryGenerator.h>
#include <frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h>
#include <frc2/command/Commands.h>
#include <frc2/command/InstantCommand.h>
#include <frc2/command/MecanumControllerCommand.h>
#include <frc2/command/SequentialCommandGroup.h>
#include <frc2/command/button/JoystickButton.h>
#include <frc2/command/Commands.h>

#include "Constants.h"

Expand Down Expand Up @@ -71,43 +71,45 @@ frc2::CommandPtr RobotContainer::GetAutonomousCommand() {

// no auto
return frc2::cmd::Sequence(
frc2::MecanumControllerCommand(
exampleTrajectory, [this]() { return m_drive.GetPose(); },

frc::SimpleMotorFeedforward<units::meters>(ks, kv, ka),
DriveConstants::kDriveKinematics,

frc::PIDController{AutoConstants::kPXController, 0, 0},
frc::PIDController{AutoConstants::kPYController, 0, 0},
frc::ProfiledPIDController<units::radians>(
AutoConstants::kPThetaController, 0, 0,
AutoConstants::kThetaControllerConstraints),

AutoConstants::kMaxSpeed,

[this]() {
return frc::MecanumDriveWheelSpeeds{
units::meters_per_second_t{m_drive.GetFrontLeftEncoder().GetRate()},
units::meters_per_second_t{
m_drive.GetFrontRightEncoder().GetRate()},
units::meters_per_second_t{m_drive.GetRearLeftEncoder().GetRate()},
units::meters_per_second_t{
m_drive.GetRearRightEncoder().GetRate()}};
},

frc::PIDController{DriveConstants::kPFrontLeftVel, 0, 0},
frc::PIDController{DriveConstants::kPRearLeftVel, 0, 0},
frc::PIDController{DriveConstants::kPFrontRightVel, 0, 0},
frc::PIDController{DriveConstants::kPRearRightVel, 0, 0},

[this](units::volt_t frontLeft, units::volt_t rearLeft,
units::volt_t frontRight, units::volt_t rearRight) {
m_drive.SetMotorControllersVolts(frontLeft, rearLeft, frontRight,
rearRight);
},

{&m_drive}).ToPtr(),
frc2::InstantCommand([this] { m_drive.Drive(0, 0, 0, false); }, {}).ToPtr()
);

frc2::MecanumControllerCommand(
exampleTrajectory, [this]() { return m_drive.GetPose(); },

frc::SimpleMotorFeedforward<units::meters>(ks, kv, ka),
DriveConstants::kDriveKinematics,

frc::PIDController{AutoConstants::kPXController, 0, 0},
frc::PIDController{AutoConstants::kPYController, 0, 0},
frc::ProfiledPIDController<units::radians>(
AutoConstants::kPThetaController, 0, 0,
AutoConstants::kThetaControllerConstraints),

AutoConstants::kMaxSpeed,

[this]() {
return frc::MecanumDriveWheelSpeeds{
units::meters_per_second_t{
m_drive.GetFrontLeftEncoder().GetRate()},
units::meters_per_second_t{
m_drive.GetFrontRightEncoder().GetRate()},
units::meters_per_second_t{
m_drive.GetRearLeftEncoder().GetRate()},
units::meters_per_second_t{
m_drive.GetRearRightEncoder().GetRate()}};
},

frc::PIDController{DriveConstants::kPFrontLeftVel, 0, 0},
frc::PIDController{DriveConstants::kPRearLeftVel, 0, 0},
frc::PIDController{DriveConstants::kPFrontRightVel, 0, 0},
frc::PIDController{DriveConstants::kPRearRightVel, 0, 0},

[this](units::volt_t frontLeft, units::volt_t rearLeft,
units::volt_t frontRight, units::volt_t rearRight) {
m_drive.SetMotorControllersVolts(frontLeft, rearLeft, frontRight,
rearRight);
},

{&m_drive})
.ToPtr(),
frc2::InstantCommand([this] { m_drive.Drive(0, 0, 0, false); }, {})
.ToPtr());
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include <frc/controller/ProfiledPIDController.h>
#include <frc/smartdashboard/SendableChooser.h>
#include <frc2/command/Command.h>
#include <frc2/command/CommandPtr.h>
#include <frc2/command/InstantCommand.h>
#include <frc2/command/PIDCommand.h>
#include <frc2/command/ParallelRaceGroup.h>
#include <frc2/command/RunCommand.h>
#include <frc2/command/CommandPtr.h>

#include "Constants.h"
#include "subsystems/DriveSubsystem.h"
Expand Down Expand Up @@ -45,6 +45,5 @@ class RobotContainer {
frc2::InstantCommand m_driveFullSpeed{[this] { m_drive.SetMaxOutput(1); },
{}};


void ConfigureButtonBindings();
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#pragma once

#include <frc2/command/Command.h>
#include <frc2/command/Commands.h>
#include <frc2/command/CommandPtr.h>
#include <frc2/command/Commands.h>

/**
* This class is where the bulk of the robot should be declared. Since
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#include <frc/shuffleboard/Shuffleboard.h>
#include <frc/trajectory/Trajectory.h>
#include <frc/trajectory/TrajectoryGenerator.h>
#include <frc2/command/Commands.h>
#include <frc2/command/InstantCommand.h>
#include <frc2/command/SequentialCommandGroup.h>
#include <frc2/command/SwerveControllerCommand.h>
#include <frc2/command/button/JoystickButton.h>
#include <frc2/command/Commands.h>
#include <units/angle.h>
#include <units/velocity.h>

Expand Down Expand Up @@ -79,18 +79,20 @@ frc2::CommandPtr RobotContainer::GetAutonomousCommand() {

// no auto
return frc2::cmd::Sequence(
frc2::SwerveControllerCommand<4>(
exampleTrajectory, [this]() { return m_drive.GetPose(); },

m_drive.kDriveKinematics,
frc2::SwerveControllerCommand<4>(
exampleTrajectory, [this]() { return m_drive.GetPose(); },

frc::PIDController{AutoConstants::kPXController, 0, 0},
frc::PIDController{AutoConstants::kPYController, 0, 0}, thetaController,
m_drive.kDriveKinematics,

[this](auto moduleStates) { m_drive.SetModuleStates(moduleStates); },
frc::PIDController{AutoConstants::kPXController, 0, 0},
frc::PIDController{AutoConstants::kPYController, 0, 0},
thetaController,

{&m_drive}).ToPtr(),
frc2::InstantCommand([this] { m_drive.Drive(0_mps, 0_mps, 0_rad_per_s, false); }, {}).ToPtr()
);
[this](auto moduleStates) { m_drive.SetModuleStates(moduleStates); },

{&m_drive})
.ToPtr(),
frc2::InstantCommand(
[this] { m_drive.Drive(0_mps, 0_mps, 0_rad_per_s, false); }, {})
.ToPtr());
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include <frc/controller/ProfiledPIDController.h>
#include <frc/smartdashboard/SendableChooser.h>
#include <frc2/command/Command.h>
#include <frc2/command/CommandPtr.h>
#include <frc2/command/InstantCommand.h>
#include <frc2/command/PIDCommand.h>
#include <frc2/command/ParallelRaceGroup.h>
#include <frc2/command/RunCommand.h>
#include <frc2/command/CommandPtr.h>

#include "Constants.h"
#include "subsystems/DriveSubsystem.h"
Expand Down

0 comments on commit d55c55b

Please sign in to comment.