This commit is contained in:
samuel desharnais
2026-03-31 19:53:27 -04:00
2 changed files with 44 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.commands.Aspirer;
import frc.robot.commands.DescendreBalyeuse;
import frc.robot.commands.DescendreGrimpeur;
import frc.robot.commands.Inverser;
import frc.robot.commands.Lancer;
import frc.robot.commands.LancerAspirer;
import frc.robot.commands.LancerBaseVitesse;
@@ -132,6 +133,7 @@ public class RobotContainer {
manette1.y().whileTrue(new ModeOposerBalayeuse(balayeuse));
manette1.povRight().whileTrue(new BougerDroiteAuto(drivetrain));
manette1.povLeft().whileTrue(new BougerGaucheAuto(drivetrain));
manette1.start().whileTrue(new Inverser(drivetrain));
}
public Command getAutonomousCommand() {

View File

@@ -0,0 +1,42 @@
// 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.
package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.CommandSwerveDrivetrain;
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
public class Inverser extends Command {
CommandSwerveDrivetrain drivetrain;
boolean inverse = false;
/** Creates a new Inverser. */
public Inverser(CommandSwerveDrivetrain drivetrain) {
addRequirements(drivetrain);
// Use addRequirements() here to declare subsystem dependencies.
}
// Called when the command is initially scheduled.
@Override
public void initialize() {}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
if(!inverse){
drivetrain.getPigeon2().setYaw(drivetrain.getPigeon2().getYaw().getValueAsDouble()+180);
inverse = true;
}
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}