2022-11-28 10:41:25 -05: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.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
2025-11-07 19:57:55 -05:00
|
|
|
#include <wpi/commands2/CommandPtr.hpp>
|
|
|
|
|
#include <wpi/commands2/SubsystemBase.hpp>
|
|
|
|
|
#include <wpi/hardware/motor/PWMSparkMax.hpp>
|
|
|
|
|
#include <wpi/hardware/rotation/Encoder.hpp>
|
|
|
|
|
#include <wpi/math/controller/PIDController.hpp>
|
|
|
|
|
#include <wpi/math/controller/SimpleMotorFeedforward.hpp>
|
|
|
|
|
#include <wpi/units/angle.hpp>
|
|
|
|
|
#include <wpi/units/angular_velocity.hpp>
|
2025-11-07 19:56:21 -05:00
|
|
|
|
|
|
|
|
#include "Constants.hpp"
|
2022-11-28 10:41:25 -05:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
class Shooter : public wpi::cmd::SubsystemBase {
|
2022-11-28 10:41:25 -05:00
|
|
|
public:
|
|
|
|
|
Shooter();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a command to shoot the balls currently stored in the robot. Spins
|
|
|
|
|
* the shooter flywheel up to the specified setpoint, and then runs the feeder
|
|
|
|
|
* motor.
|
|
|
|
|
*
|
|
|
|
|
* @param setpointRotationsPerSecond The desired shooter velocity
|
|
|
|
|
*/
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::cmd::CommandPtr ShootCommand(wpi::units::turns_per_second_t setpoint);
|
2022-11-28 10:41:25 -05:00
|
|
|
|
|
|
|
|
private:
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::PWMSparkMax m_shooterMotor{ShooterConstants::kShooterMotorPort};
|
|
|
|
|
wpi::PWMSparkMax m_feederMotor{ShooterConstants::kFeederMotorPort};
|
2022-11-28 10:41:25 -05:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::Encoder m_shooterEncoder{ShooterConstants::kEncoderPorts[0],
|
2022-11-28 10:41:25 -05:00
|
|
|
ShooterConstants::kEncoderPorts[1],
|
|
|
|
|
ShooterConstants::kEncoderReversed};
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::math::SimpleMotorFeedforward<wpi::units::radians> m_shooterFeedforward{
|
2022-11-28 10:41:25 -05:00
|
|
|
ShooterConstants::kS, ShooterConstants::kV};
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::math::PIDController m_shooterFeedback{ShooterConstants::kP, 0.0, 0.0};
|
2022-11-28 10:41:25 -05:00
|
|
|
};
|