Added turret changes and manual command for testing

This commit is contained in:
TheRealGrayden 2026-03-26 19:15:38 -04:00
parent d6824df962
commit 556a5067b3
4 changed files with 39 additions and 41 deletions

View File

@ -27,7 +27,6 @@ public final class Constants {
public static class IDFilters { public static class IDFilters {
public static final int[] RED_HUB_SHOOTING_IDS = new int[]{ 8, 9, 10, 11 }; public static final int[] RED_HUB_SHOOTING_IDS = new int[]{ 8, 9, 10, 11 };
public static final int[] BLUE_HUB_SHOOTING_IDS = new int[]{ 27, 26, 25, 24 }; public static final int[] BLUE_HUB_SHOOTING_IDS = new int[]{ 27, 26, 25, 24 };
// public static final int[] BLUE_HUB_SHOOTING_IDS = new int[]{ 18, 19, 20, 21 };
} }
public static final String BACK_CAMERA_NAME = "limelight-back"; public static final String BACK_CAMERA_NAME = "limelight-back";
@ -97,7 +96,7 @@ public final class Constants {
public static final int TURRET_MOTOR_ID = 4; public static final int TURRET_MOTOR_ID = 4;
public static final InvertedValue TURRET_MOTOR_DIRECTION = InvertedValue.CounterClockwise_Positive; public static final InvertedValue TURRET_MOTOR_DIRECTION = InvertedValue.CounterClockwise_Positive;
public static final int TURRET_LIMIT_CHANNEL = 0; public static final int TURRET_LIMIT_CHANNEL = 0;
public static final Angle LIMIT_AXIMUTH_POS = edu.wpi.first.units.Units.Degrees.of(265); public static final Angle LIMIT_AXIMUTH_POS = edu.wpi.first.units.Units.Degrees.of(165);
public static final Angle LIMIT_AXIMUTH_NEG = edu.wpi.first.units.Units.Degrees.of(5); public static final Angle LIMIT_AXIMUTH_NEG = edu.wpi.first.units.Units.Degrees.of(5);
public static final double HOMING_SPEED = .35; public static final double HOMING_SPEED = .35;
public static final double TURRET_GEAR_RATIO = 1; public static final double TURRET_GEAR_RATIO = 1;

View File

@ -42,7 +42,6 @@ public class RobotContainer {
/** The container for the robot. Contains subsystems, OI devices, and commands. */ /** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() { public RobotContainer() {
// Configure the trigger bindings // Configure the trigger bindings
configureBindings(); configureBindings();
} }
@ -58,20 +57,13 @@ public class RobotContainer {
*/ */
private void configureBindings() { private void configureBindings() {
// turretSubsystem.setDefaultCommand(new ManualShootCommand(turretSubsystem, m_driverController.getHID())); turretSubsystem.startHoming();
// hopperSubsystem.setDefaultCommand(new ManualHopperCommand(hopperSubsystem, m_driverController.getHID()));
// intakeSubsystem.setDefaultCommand(new ManualIntake(intakeSubsystem, m_driverController.getHID()));
m_driverController.povDown().onTrue(new SetDeflectorCommand(turretSubsystem, Constants.ShooterConstants.DEFLECTOR_STORED_ANGLE)); m_driverController.povDown().onTrue(new SetDeflectorCommand(turretSubsystem, Constants.ShooterConstants.DEFLECTOR_STORED_ANGLE));
m_driverController.povLeft().onTrue(new SetDeflectorCommand(turretSubsystem, Constants.ShooterConstants.DEFLECTOR_SET_ANGLE1)); m_driverController.povLeft().onTrue(new SetDeflectorCommand(turretSubsystem, Constants.ShooterConstants.DEFLECTOR_SET_ANGLE1));
m_driverController.povRight().onTrue(new SetDeflectorCommand(turretSubsystem, Constants.ShooterConstants.DEFLECTOR_SET_ANGLE3)); m_driverController.povRight().onTrue(new SetDeflectorCommand(turretSubsystem, Constants.ShooterConstants.DEFLECTOR_SET_ANGLE3));
m_driverController.povUp().onTrue(new SetDeflectorCommand(turretSubsystem, Constants.ShooterConstants.DEFLECTOR_SET_ANGLE2)); m_driverController.povUp().onTrue(new SetDeflectorCommand(turretSubsystem, Constants.ShooterConstants.DEFLECTOR_SET_ANGLE2));
// m_driverController.x().onTrue(intakeSubsystem.killSpeedCommand());
// m_driverController.a().onTrue(intakeSubsystem.startSpeedCommand());
m_driverController.a().whileTrue(new AutoShootCommandChassisTurret(driveSubsystem, hopperSubsystem, turretSubsystem)); m_driverController.a().whileTrue(new AutoShootCommandChassisTurret(driveSubsystem, hopperSubsystem, turretSubsystem));
} }
/** /**

View File

@ -24,24 +24,19 @@ public class ManualShootCommand extends Command {
// Called every time the scheduler runs while the command is scheduled. // Called every time the scheduler runs while the command is scheduled.
@Override @Override
public void execute() { public void execute() {
if(m_controller.getRightTriggerAxis()>.8) if(m_controller.getRightTriggerAxis()>.5 && m_controller.getLeftTriggerAxis()==0)
{ {
m_subsystem.setLauncher(5000); m_subsystem.startRotate(-.5);
m_controller.setRumble(RumbleType.kBothRumble, 1); m_controller.setRumble(RumbleType.kRightRumble, 1);
} }
else if(m_controller.getRightTriggerAxis()>.5) else if(m_controller.getLeftTriggerAxis()>.5 && m_controller.getRightTriggerAxis()==0)
{ {
m_subsystem.setLauncher(3000); m_subsystem.startRotate(.5);
m_controller.setRumble(RumbleType.kBothRumble, .67); m_controller.setRumble(RumbleType.kLeftRumble, 1);
}
else if(m_controller.getRightTriggerAxis()>.2)
{
m_subsystem.setLauncher(2000);
m_controller.setRumble(RumbleType.kBothRumble, .33);
} }
else else
{ {
m_subsystem.setLauncher(0); m_subsystem.startRotate(0);
m_controller.setRumble(RumbleType.kBothRumble, 0); m_controller.setRumble(RumbleType.kBothRumble, 0);
} }
} }

View File

@ -27,8 +27,6 @@ import com.revrobotics.spark.SparkLowLevel.MotorType;
import com.revrobotics.spark.config.SparkMaxConfig; import com.revrobotics.spark.config.SparkMaxConfig;
import frc.robot.Constants; import frc.robot.Constants;
import edu.wpi.first.units.AngleUnit;
import edu.wpi.first.units.Units;
import edu.wpi.first.units.measure.Angle; import edu.wpi.first.units.measure.Angle;
import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Servo; import edu.wpi.first.wpilibj.Servo;
@ -42,7 +40,6 @@ public class TurretSubsystem extends TestableSubsystem {
} }
private final boolean LOGGING = true; private final boolean LOGGING = true;
private TurretState currentState; private TurretState currentState;
private DigitalInput turretLimitSwitch; private DigitalInput turretLimitSwitch;
private TalonFX turretMotor; private TalonFX turretMotor;
@ -78,8 +75,7 @@ public class TurretSubsystem extends TestableSubsystem {
// Launcher configuration // Launcher configuration
launcherMotor = new SparkMax(Constants.ShooterConstants.LAUNCHER_MOTOR_ID, MotorType.kBrushless); launcherMotor = new SparkMax(Constants.ShooterConstants.LAUNCHER_MOTOR_ID, MotorType.kBrushless);
SparkMaxConfig config = new SparkMaxConfig() SparkMaxConfig config = new SparkMaxConfig().apply((SparkMaxConfig) SparkMaxConfig.Presets.REV_NEO);
.apply((SparkMaxConfig) SparkMaxConfig.Presets.REV_NEO);
config.inverted(Constants.ShooterConstants.LAUNCHER_MOTOR_INVERTED); config.inverted(Constants.ShooterConstants.LAUNCHER_MOTOR_INVERTED);
config.closedLoop.p(1).i(0).d(0.1); config.closedLoop.p(1).i(0).d(0.1);
config.closedLoop.allowedClosedLoopError(10, ClosedLoopSlot.kSlot0); config.closedLoop.allowedClosedLoopError(10, ClosedLoopSlot.kSlot0);
@ -119,13 +115,13 @@ public class TurretSubsystem extends TestableSubsystem {
public void startHoming() public void startHoming()
{ {
//turretMotor.set(Constants.ShooterConstants.HOMING_SPEED); turretMotor.set(Constants.ShooterConstants.HOMING_SPEED);
//currentState = TurretState.HOMING; currentState = TurretState.HOMING;
} }
public void startRotate(double speed) public void startRotate(double speed)
{ {
/*turretGoingPos=speed>0; turretGoingPos=speed>0;
if(!passedLimit()) if(!passedLimit())
{ {
@ -134,7 +130,7 @@ public class TurretSubsystem extends TestableSubsystem {
else else
{ {
turretMotor.set(0); turretMotor.set(0);
}*/ }
} }
public boolean passedLimit(){ public boolean passedLimit(){
@ -148,7 +144,6 @@ public class TurretSubsystem extends TestableSubsystem {
@Override @Override
public void periodic() { public void periodic() {
// This method will be called once per scheduler run // This method will be called once per scheduler run
switch (currentState) { switch (currentState) {
case HOMING: case HOMING:
@ -174,19 +169,36 @@ public class TurretSubsystem extends TestableSubsystem {
if(turretLimitSwitch.get()) if(turretLimitSwitch.get())
{ {
currentState = TurretState.MANUAL; currentState = TurretState.MANUAL;
//turretMotor.set(0); turretMotor.set(0);
//turretMotor.setPosition(0); turretMotor.setPosition(0);
goTo(limitPos);
}
}
private void goTo(Angle pos)
{
if(pos.gt(limitNeg) && pos.lt(limitPos))
{
while(getTurretAngle()!=pos)
{
if(getTurretAngle().gt(pos))
{
turretMotor.set(.5);
}
else
{
turretMotor.set(-.5);
}
}
} }
} }
private void periodicManual() private void periodicManual()
{ {
//If the turret move, it will be a uh-oh, so DONT MOVE IT if(passedLimit())
/*if(passedLimit())
{ {
//turretMotor.set(0); turretMotor.set(0);
}*/ }
} }
@PostTest() @PostTest()