This commit is contained in:
Olivier Dubois 2023-03-08 18:34:08 -05:00
commit f814e4f7ce
5 changed files with 45 additions and 24 deletions

View File

@ -1,12 +1,12 @@
package frc.robot;
public class Constants {
public static int avantdroit = 0;
public static int avantgauche = 1;
public static int arrieredroit = 2;
public static int arrieregauche = 3;
public static int avantdroit = 1;
public static int avantgauche = 4;
public static int arrieredroit = 3;
public static int arrieregauche = 5;
public static int BrasTelescopique = 4;
public static int pivot = 5;
public static int pivot = 0;
//moteur
public static int leverGratte = 0;

View File

@ -7,8 +7,8 @@ import edu.wpi.first.cameraserver.CameraServer;
//import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.RunCommand;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
//subsystems
@ -33,6 +33,8 @@ import frc.robot.commands.bras.PivotBrasRentre;
import frc.robot.commands.bras.PivoteBrasBas;
import frc.robot.commands.bras.PivoteBrasHaut;
import frc.robot.commands.bras.PivoteBrasMilieux;
//subsystems
import frc.robot.subsystems.BasePilotable;
import frc.robot.commands.bras.PivotChercheBas;
import frc.robot.commands.bras.PivotChercheHaut;
import frc.robot.commands.Cube;
@ -49,7 +51,7 @@ Gratte gratte = new Gratte();
BrasTelescopique brasTelescopique = new BrasTelescopique();
Pince pince = new Pince();
Pivot pivot = new Pivot();
Limelight limelight = new Limelight();
Limelight limelight = new Limelight();/** */
//commands
BrakeFerme brakeFerme = new BrakeFerme(basePilotable);
BrakeOuvre brakeOuvre = new BrakeOuvre(basePilotable);
@ -79,31 +81,35 @@ public RobotContainer() {
}
private void configureBindings() {
basePilotable.setDefaultCommand(new RunCommand(() -> {
basePilotable.drive(-manette1.getLeftY(), -manette1.getLeftX());
},basePilotable));
// manette 1
manette1.povDown().onTrue(pivoteBrasHaut);
manette1.povUp().onTrue(pivoteBrasBas);
manette1.povLeft().onTrue(pivoteBrasMilieux);
manette1.povRight().onTrue(pivotBrasRentre);
manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince));
manette1.x().toggleOnTrue(Commands.startEnd(basePilotable::BrakeFerme,basePilotable::BrakeOuvre,basePilotable));
manette1.y().whileTrue(gyro);
manette1.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable));
manette1.b().onTrue(Commands.either(gratteBaisser, gratteMonte, gratte::getenHaut));
manette1.leftBumper().toggleOnTrue(aprilTag);
manette1.rightBumper().toggleOnTrue(tape);
manette1.leftBumper().toggleOnTrue(cube);
manette1.rightBumper().toggleOnTrue(cone);
// manette 2
manette2.a().onTrue(pivoteBrasHaut);
manette2.b().onTrue(pivoteBrasBas);
manette2.x().onTrue(pivoteBrasMilieux);
manette2.y().onTrue(pivotBrasRentre);
manette2.y().whileTrue(gyro);
manette2.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable));
manette2.povRight().onTrue(pivotChercheBas);
manette2.povLeft().onTrue(pivotChercheHaut);
manette2.rightBumper().toggleOnTrue(cube);
manette2.leftBumper().toggleOnTrue(cone);
manette2.rightBumper().toggleOnTrue(aprilTag);
manette2.leftBumper().toggleOnTrue(tape);
}
public Command getAutonomousCommand() {
return new SequentialCommandGroup(
new PivoteBrasMilieux(brasTelescopique, pivot),
new OuvrePince(pince),
new PivotBrasRentre(brasTelescopique, pivot).alongWith(new Reculer(basePilotable)),
new Gyro(basePilotable)
);
return null;
//return new SequentialCommandGroup(
//new PivoteBrasMilieux(brasTelescopique, pivot),
//new OuvrePince(pince),
//new PivotBrasRentre(brasTelescopique, pivot).alongWith(new Reculer(basePilotable)),
//new Gyro(basePilotable)
//);
}
}

View File

@ -30,11 +30,19 @@ public class Gyro extends CommandBase {
public void execute() {
if(basePilotable.getpitch()>4)
{
<<<<<<< HEAD
basePilotable.drive(0.3*basePilotable.getpitch()/12, 0);
}
else if(basePilotable.getpitch()<-4)
{
basePilotable.drive(0.3*basePilotable.getpitch()/12, 0);
=======
basePilotable.drive(0.3*basePilotable.getpitch()/15, 0);
}
else if(basePilotable.getpitch()<-4)
{
basePilotable.drive(0.3*basePilotable.getpitch()/15, 0);
>>>>>>> 3d2364b54822fb53a6cd71a0347d11baeef62001
}
else
{

View File

@ -70,6 +70,13 @@ public void resetGyro(){
@Override
public void periodic() {
//teb .add("encodeuravantdroit",0.1);
//teb .add("encodeurarrieregauche",0.1);
//teb .add("encodeurarrieredroit",0.1);
//teb .add("encodeuravantgauche",0.1);
//teb .add("distance",0.1);
//teb .add("brakedroit",0.1);
//teb .add("brakegauche", 0.1);
}
}