2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <frc2/command/Command.h>
|
2022-11-28 18:55:13 +02:00
|
|
|
#include <frc2/command/CommandPtr.h>
|
|
|
|
|
#include <frc2/command/Commands.h>
|
|
|
|
|
#include <frc2/command/button/CommandXboxController.h>
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
#include "Constants.h"
|
|
|
|
|
#include "subsystems/DriveSubsystem.h"
|
|
|
|
|
#include "subsystems/ShooterSubsystem.h"
|
|
|
|
|
|
|
|
|
|
namespace ac = AutoConstants;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class is where the bulk of the robot should be declared. Since
|
|
|
|
|
* Command-based is a "declarative" paradigm, very little robot logic should
|
|
|
|
|
* actually be handled in the {@link Robot} periodic methods (other than the
|
|
|
|
|
* scheduler calls). Instead, the structure of the robot (including subsystems,
|
|
|
|
|
* commands, and button mappings) should be declared here.
|
|
|
|
|
*/
|
|
|
|
|
class RobotContainer {
|
|
|
|
|
public:
|
|
|
|
|
RobotContainer();
|
|
|
|
|
|
2022-11-28 18:55:13 +02:00
|
|
|
// The chooser for the autonomous routines
|
2019-08-25 23:55:59 -04:00
|
|
|
frc2::Command* GetAutonomousCommand();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// The driver's controller
|
2022-11-28 18:55:13 +02:00
|
|
|
frc2::CommandXboxController m_driverController{
|
|
|
|
|
OIConstants::kDriverControllerPort};
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
// The robot's subsystems
|
|
|
|
|
DriveSubsystem m_drive;
|
|
|
|
|
ShooterSubsystem m_shooter;
|
|
|
|
|
|
2022-11-28 18:55:13 +02:00
|
|
|
// RobotContainer-owned commands
|
|
|
|
|
// (These variables will still be valid after binding, because we don't move
|
|
|
|
|
// ownership)
|
|
|
|
|
|
|
|
|
|
frc2::CommandPtr m_spinUpShooter =
|
|
|
|
|
frc2::cmd::RunOnce([this] { m_shooter.Enable(); }, {&m_shooter});
|
|
|
|
|
|
|
|
|
|
frc2::CommandPtr m_stopShooter =
|
|
|
|
|
frc2::cmd::RunOnce([this] { m_shooter.Disable(); }, {&m_shooter});
|
|
|
|
|
|
|
|
|
|
// An autonomous routine that shoots the loaded frisbees
|
2022-10-06 01:19:28 +03:00
|
|
|
frc2::CommandPtr m_autonomousCommand =
|
2022-11-28 18:55:13 +02:00
|
|
|
frc2::cmd::Sequence(
|
2019-08-25 23:55:59 -04:00
|
|
|
// Start the command by spinning up the shooter...
|
2022-11-28 18:55:13 +02:00
|
|
|
frc2::cmd::RunOnce([this] { m_shooter.Enable(); }, {&m_shooter}),
|
2019-08-25 23:55:59 -04:00
|
|
|
// Wait until the shooter is at speed before feeding the frisbees
|
2022-11-28 18:55:13 +02:00
|
|
|
frc2::cmd::WaitUntil([this] { return m_shooter.AtSetpoint(); }),
|
2019-08-25 23:55:59 -04:00
|
|
|
// Start running the feeder
|
2022-11-28 18:55:13 +02:00
|
|
|
frc2::cmd::RunOnce([this] { m_shooter.RunFeeder(); }, {&m_shooter}),
|
2019-08-25 23:55:59 -04:00
|
|
|
// Shoot for the specified time
|
2022-11-28 18:55:13 +02:00
|
|
|
frc2::cmd::Wait(ac::kAutoShootTimeSeconds))
|
2019-08-25 23:55:59 -04:00
|
|
|
// Add a timeout (will end the command if, for instance, the shooter
|
2021-08-01 07:17:51 -07:00
|
|
|
// never gets up to speed)
|
2019-08-25 23:55:59 -04:00
|
|
|
.WithTimeout(ac::kAutoTimeoutSeconds)
|
|
|
|
|
// When the command ends, turn off the shooter and the feeder
|
2022-11-28 18:55:13 +02:00
|
|
|
.AndThen(frc2::cmd::RunOnce([this] {
|
2019-08-25 23:55:59 -04:00
|
|
|
m_shooter.Disable();
|
|
|
|
|
m_shooter.StopFeeder();
|
2022-11-28 18:55:13 +02:00
|
|
|
}));
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
void ConfigureButtonBindings();
|
|
|
|
|
};
|