control changes

This commit is contained in:
TheRealGrayden 2026-03-22 15:54:28 -04:00
parent 4dc406583a
commit c89b0f299b
6 changed files with 18 additions and 44 deletions

View File

@ -79,6 +79,9 @@ public class RobotContainer {
m_driverController.x().onTrue(intakeSubsystem.killSpeedCommand()); m_driverController.x().onTrue(intakeSubsystem.killSpeedCommand());
m_driverController.a().onTrue(intakeSubsystem.startSpeedCommand()); m_driverController.a().onTrue(intakeSubsystem.startSpeedCommand());
m_driverController.b().onTrue(intakeSubsystem.revSpeedCommand());
m_driverController.b().onTrue(hopperSubsystem.revSpeedCommand());
m_driverController.b().onTrue(turretSubsystem.revSpeedCommand());
intakeSubsystem.setDefaultCommand(new ManualIntake(intakeSubsystem, m_driverController.getHID())); intakeSubsystem.setDefaultCommand(new ManualIntake(intakeSubsystem, m_driverController.getHID()));
} }

View File

@ -36,18 +36,10 @@ public class ManualIntake 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_XboxController.getLeftBumper()==true) if(m_XboxController.getYButton()==true)
{ {
m_subsystem.extend(); m_subsystem.extend();
} }
else if(m_XboxController.getRightBumper()==true)
{
m_subsystem.retract();
}
else
{
m_subsystem.neutral();
}
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.

View File

@ -13,6 +13,7 @@ import edu.wpi.first.wpilibj2.command.Command;
public class ManualShootCommand extends Command { public class ManualShootCommand extends Command {
private final TurretSubsystem m_subsystem; private final TurretSubsystem m_subsystem;
private final XboxController m_controller; private final XboxController m_controller;
private double tempAng;
public ManualShootCommand(TurretSubsystem subsystem, XboxController controller) { public ManualShootCommand(TurretSubsystem subsystem, XboxController controller) {
m_subsystem = subsystem; m_subsystem = subsystem;

View File

@ -9,6 +9,8 @@ import org.fairportrobotics.frc.posty.test.PostTest;
import com.ctre.phoenix6.hardware.TalonFX; import com.ctre.phoenix6.hardware.TalonFX;
import edu.wpi.first.wpilibj2.command.Command;
import static org.fairportrobotics.frc.posty.assertions.Assertions.*; import static org.fairportrobotics.frc.posty.assertions.Assertions.*;
import static org.fairportrobotics.frc.robolib.motors.Utils.*; import static org.fairportrobotics.frc.robolib.motors.Utils.*;
import frc.robot.Constants; import frc.robot.Constants;
@ -34,6 +36,11 @@ public class HopperSubsystem extends TestableSubsystem {
public void spin(double speed) {spindexerMotor.set(speed);} public void spin(double speed) {spindexerMotor.set(speed);}
public Command revSpeedCommand()
{
return this.runOnce(() -> reverse());
}
@PostTest(name = "A friendly name", enabled = true) @PostTest(name = "A friendly name", enabled = true)
public void myFailingPostTest(){ public void myFailingPostTest(){
assertThat(true).isFalse(); assertThat(true).isFalse();

View File

@ -37,51 +37,16 @@ public class IntakeSubsystem extends TestableSubsystem {
deployMotor.setInverted(Constants.IntakeConstants.DEPLOY_MOTOR_INVERTED); deployMotor.setInverted(Constants.IntakeConstants.DEPLOY_MOTOR_INVERTED);
} }
public void neutral()
{
deployMotor.set(0);
}
public void extend() public void extend()
{ {
deployMotor.set(1); deployMotor.set(1);
} }
public void retract()
{
deployMotor.set(-1);
}
public void setSpeed(double speed) public void setSpeed(double speed)
{ {
intakeMotor.set(speed); intakeMotor.set(speed);
} }
public boolean isDeployed()
{
return deployMotor.isFwdLimitSwitchClosed()==1;
}
public boolean isRetracted()
{
return deployMotor.isRevLimitSwitchClosed()==1;
}
public Command deployCommand()
{
return new FunctionalCommand(this::extend, this::extend, interrupted -> neutral(), this::isDeployed, this).andThen(Commands.startEnd(() -> setSpeed(.5), () -> setSpeed(0), this));
}
public Command reverseCommand()
{
return new FunctionalCommand(this::extend, this::extend, interrupted -> neutral(), this::isDeployed, this).andThen(Commands.startEnd(() -> setSpeed(-.5), () -> setSpeed(0), this));
}
public Command retractCommand()
{
return this.runOnce(() -> setSpeed(0)).andThen(new FunctionalCommand(this::retract, this::retract, interrupted -> neutral(), this::isRetracted, this));
}
public Command startSpeedCommand() public Command startSpeedCommand()
{ {
return this.runOnce(() -> setSpeed(-.5)); return this.runOnce(() -> setSpeed(-.5));

View File

@ -25,6 +25,7 @@ import edu.wpi.first.units.measure.Angle;
import edu.wpi.first.units.measure.Velocity; import edu.wpi.first.units.measure.Velocity;
import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Servo; import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj2.command.Command;
public class TurretSubsystem extends TestableSubsystem { public class TurretSubsystem extends TestableSubsystem {
public enum TurretState { public enum TurretState {
@ -76,6 +77,11 @@ public class TurretSubsystem extends TestableSubsystem {
hood.setAngle(elev.in(Units.Degrees)); hood.setAngle(elev.in(Units.Degrees));
} }
public Command revSpeedCommand()
{
return this.runOnce(() -> setLauncher(-.5));
}
public void startHoming() public void startHoming()
{ {
//turretMotor.set(Constants.ShooterConstants.HOMING_SPEED); //turretMotor.set(Constants.ShooterConstants.HOMING_SPEED);