mirror of
https://github.com/Team4388/2022NoWayHome.git
synced 2026-06-09 00:38:05 -06:00
:))
This commit is contained in:
@@ -11,6 +11,7 @@ import com.ctre.phoenix.motorcontrol.NeutralMode;
|
||||
import com.ctre.phoenix.motorcontrol.TalonFXControlMode;
|
||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
|
||||
|
||||
import edu.wpi.first.wpilibj.simulation.JoystickSim;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.*;
|
||||
import edu.wpi.first.math.controller.BangBangController;
|
||||
import edu.wpi.first.math.controller.SimpleMotorFeedforward;
|
||||
@@ -28,7 +29,7 @@ public ShooterTables m_shooterTable;
|
||||
public static Gains m_drumShooterGains = ShooterConstants.DRUM_SHOOTER_GAINS;
|
||||
public static BoomBoom m_boomBoom;
|
||||
public static IHandController m_driverController; //not sure if driverController in 2022 = m_controller in 2020
|
||||
BangBangController m_controller = new BangBangController();
|
||||
// BangBangController m_controller = new BangBangController();
|
||||
|
||||
double velP;
|
||||
double input;
|
||||
@@ -39,33 +40,19 @@ public double m_fireVel;
|
||||
public Hood m_hoodSubsystem;
|
||||
public Turret m_turretSubsystem;
|
||||
|
||||
SimpleMotorFeedforward feedforward = new SimpleMotorFeedforward(69, 42, 0); //get real values later
|
||||
// SimpleMotorFeedforward feedforward = new SimpleMotorFeedforward(69, 42, 0); //get real values later
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Creates new BoomBoom subsystem, has drum shooter and angle adjuster
|
||||
*/
|
||||
public BoomBoom(){
|
||||
//Testing purposes resetting gyros
|
||||
//resetGryoAngleADj();
|
||||
//shooterTrims = new Trims(0,0);
|
||||
feedforward.calculate(15, 20); // feedforward.calculate(velocity, acceleration);
|
||||
|
||||
|
||||
}
|
||||
/** Creates a new BoomBoom. */
|
||||
public BoomBoom(WPI_TalonFX shooterFalconLeft, WPI_TalonFX shooterFalconRight) {
|
||||
public BoomBoom(WPI_TalonFX shooterFalconLeft, WPI_TalonFX shooterFalconRight) {
|
||||
m_shooterFalconLeft = shooterFalconLeft;
|
||||
m_shooterFalconRight = shooterFalconRight;
|
||||
|
||||
|
||||
|
||||
|
||||
m_shooterTable = new ShooterTables();
|
||||
|
||||
|
||||
}
|
||||
m_shooterTable = new ShooterTables();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -92,7 +79,10 @@ try {
|
||||
m_hoodSubsystem = subsystem0;
|
||||
m_turretSubsystem = subsystem1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the Drum motor at a given speed
|
||||
* @param speed percent output form -1.0 to 1.0
|
||||
*/
|
||||
public void runDrumShooter(double speed) {
|
||||
m_shooterFalconLeft.set(TalonFXControlMode.PercentOutput, speed);
|
||||
|
||||
@@ -114,7 +104,8 @@ public void setShooterGains() {
|
||||
//Controls a motor with the output of the BangBang conroller and a feedforward
|
||||
//Shrinks the feedforward slightly to avoid over speeding the shooter
|
||||
|
||||
|
||||
// m_shooterFalconLeft.set(controller.calculate(encoder.getRate(), targetVel) + 0.9 * feedforward.calculate(targetVel));
|
||||
m_shooterFalconLeft.set(m_controller.calculate(m_shooterFalconLeft.get(), targetVel));
|
||||
// m_shooterFalconLeft.set(m_controller.calculate(m_shooterFalconLeft.get(), targetVel));
|
||||
}
|
||||
}
|
||||
@@ -42,14 +42,14 @@ public class Turret extends SubsystemBase {
|
||||
|
||||
|
||||
//Variables
|
||||
public Turret() {
|
||||
public Turret(CANSparkMax BoomBoomRotateMotor) { //Take in rotate motor as an argument
|
||||
|
||||
m_boomBoomRotateMotor = new CANSparkMax(30, MotorType.kBrushless);
|
||||
m_boomBoomRotateMotor = BoomBoomRotateMotor;
|
||||
m_boomBoomRotatePIDController = m_boomBoomRotateMotor.getPIDController();
|
||||
m_boomBoomRotateEncoder = m_boomBoomRotateMotor.getEncoder();
|
||||
m_boomBoomRotateMotor.setIdleMode(IdleMode.kBrake);
|
||||
|
||||
m_turretGyro = getGyroInterface();
|
||||
|
||||
m_boomBoomLeftLimit = m_boomBoomRotateMotor.getReverseLimitSwitch(SparkMaxLimitSwitch.Type.kNormallyOpen);
|
||||
m_boomBoomRightLimit = m_boomBoomRotateMotor.getForwardLimitSwitch(SparkMaxLimitSwitch.Type.kNormallyOpen);
|
||||
m_boomBoomRightLimit.enableLimitSwitch(true);
|
||||
@@ -57,14 +57,11 @@ public class Turret extends SubsystemBase {
|
||||
|
||||
m_boomBoomRotateMotor.enableSoftLimit(SoftLimitDirection.kForward, false);
|
||||
m_boomBoomRotateMotor.enableSoftLimit(SoftLimitDirection.kReverse, true);
|
||||
m_boomBoomRotateMotor.setSoftLimit(SoftLimitDirection.kForward, ShooterConstants.TURRET_RIGHT_SOFT_LIMIT);
|
||||
m_boomBoomRotateMotor.setSoftLimit(SoftLimitDirection.kForward, ShooterConstants.TURRET_RIGHT_SOFT_LIMIT); //Set second soft limit
|
||||
m_boomBoomRotateMotor.setInverted(false);
|
||||
|
||||
}
|
||||
|
||||
private Gyro getGyroInterface() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void periodic() {
|
||||
@@ -81,16 +78,18 @@ public class Turret extends SubsystemBase {
|
||||
m_sDriveSubsystem = subsystem1;
|
||||
}
|
||||
|
||||
public void runShooterWithInput(double input) {
|
||||
public void runTurretWithInput(double input) { //Rename to turret
|
||||
m_boomBoomRotateMotor.set(input*ShooterConstants.TURRET_SPEED_MULTIPLIER);
|
||||
}
|
||||
|
||||
public void runshooterRotatePID(double targetAngle) {
|
||||
public void runshooterRotatePID(double targetAngle) { //Split into configure and run
|
||||
m_boomBoomRotatePIDController.setP(m_shooterTGains.m_kP);
|
||||
m_boomBoomRotatePIDController.setI(m_shooterTGains.m_kI);
|
||||
m_boomBoomRotatePIDController.setD(m_shooterTGains.m_kD);
|
||||
m_boomBoomRotatePIDController.setFF(m_shooterTGains.m_kF);
|
||||
m_boomBoomRotatePIDController.setIZone(m_shooterTGains.m_kIzone);
|
||||
|
||||
|
||||
m_boomBoomRotatePIDController.setOutputRange(ShooterConstants.SHOOTER_TURRET_MIN, m_shooterTGains.m_kPeakOutput);
|
||||
|
||||
targetAngle = targetAngle/ShooterConstants.DEGREES_PER_ROT;
|
||||
@@ -111,16 +110,5 @@ public class Turret extends SubsystemBase {
|
||||
public double getAnglePositionDegrees() {
|
||||
return (m_boomBoomRotateEncoder.getPosition() - ShooterConstants.TURRET_MOTOR_POS_AT_ZERO_ROT) * 360/ShooterConstants. TURRET_MOTOR_ROTS_PER_ROT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//function turnWithJoystick(double input)
|
||||
// motor.set(input)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** TODO
|
||||
* setPosition function
|
||||
* Limit switches
|
||||
**/
|
||||
}
|
||||
@@ -37,6 +37,8 @@ public static double fireAngle;
|
||||
public double m_hoodTrim;
|
||||
public double m_turretTrim;
|
||||
public double m_fireAngle;
|
||||
|
||||
|
||||
public Vision(Turret aimSubsystem, BoomBoom boomBoom) {
|
||||
m_turret = aimSubsystem;
|
||||
m_boomBoom = boomBoom;
|
||||
|
||||
Reference in New Issue
Block a user