// 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; import org.photonvision.estimation.CameraTargetRelation; import edu.wpi.first.cameraserver.CameraServer; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; //subsystems import frc.robot.subsystems.BasePilotable; import frc.robot.subsystems.Gratte; import frc.robot.subsystems.bras.BrasTelescopique; import frc.robot.subsystems.bras.Pince; import frc.robot.subsystems.bras.Pivot; import frc.robot.subsystems.Limelight; import frc.robot.commands.Apriltag; // command import frc.robot.commands.BrakeFerme; import frc.robot.commands.BrakeOuvre; import frc.robot.commands.Cone; import frc.robot.commands.GratteBaisser; import frc.robot.commands.GratteMonte; import frc.robot.commands.Gyro; import frc.robot.commands.bras.FermePince; import frc.robot.commands.bras.OuvrePince; 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.commands.bras.PivotChercheBas; import frc.robot.commands.bras.PivotChercheHaut; import frc.robot.commands.Cube; import frc.robot.commands.Tape; public class RobotContainer { //CameraServer.startAutomaticCapture(); CommandXboxController manette1 = new CommandXboxController(0); CommandXboxController manette2 = new CommandXboxController(1); // subsystems BasePilotable basePilotable = new BasePilotable(); Gratte gratte = new Gratte(); BrasTelescopique brasTelescopique = new BrasTelescopique(); Pince pince = new Pince(); Pivot pivot = new Pivot(); Limelight limelight = new Limelight();/** */ //commands BrakeFerme brakeFerme = new BrakeFerme(basePilotable); BrakeOuvre brakeOuvre = new BrakeOuvre(basePilotable); GratteBaisser gratteBaisser = new GratteBaisser(gratte); GratteMonte gratteMonte = new GratteMonte(gratte); Gyro gyro = new Gyro(basePilotable); FermePince fermePince = new FermePince(pince); OuvrePince ouvrePince = new OuvrePince(pince); PivotBrasRentre pivotBrasRentre = new PivotBrasRentre(brasTelescopique, pivot); PivoteBrasBas pivoteBrasBas = new PivoteBrasBas(brasTelescopique, pivot); PivoteBrasMilieux pivoteBrasMilieux = new PivoteBrasMilieux(brasTelescopique, pivot); PivoteBrasHaut pivoteBrasHaut = new PivoteBrasHaut(brasTelescopique, pivot); Cone cone = new Cone(limelight, basePilotable, ()->-manette1.getLeftY()); PivotChercheBas pivotChercheBas = new PivotChercheBas(brasTelescopique, pivot); PivotChercheHaut pivotChercheHaut = new PivotChercheHaut(brasTelescopique, pivot); Cube cube = new Cube(limelight, basePilotable, null); Apriltag aprilTag = new Apriltag(limelight, basePilotable, null); Tape tape = new Tape(limelight, basePilotable, null); ShuffleboardTab teb = Shuffleboard.getTab("teb"); public RobotContainer() { configureBindings(); CameraServer.startAutomaticCapture(); teb.add (CameraServer.startAutomaticCapture(null, 0)); basePilotable.setDefaultCommand(new RunCommand(() -> { basePilotable.drive(-manette1.getLeftY(), manette1.getLeftX(), 0); },basePilotable)); } private void configureBindings() { // 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.b().onTrue(Commands.either(gratteBaisser, gratteMonte, gratte::getenHaut)); manette1.leftBumper().toggleOnTrue(cube); manette1.rightBumper().toggleOnTrue(cone); // manette 2 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(aprilTag); manette2.leftBumper().toggleOnTrue(tape); } public Command getAutonomousCommand() { return null; //return new SequentialCommandGroup( //new PivoteBrasMilieux(brasTelescopique, pivot), //new OuvrePince(pince), //new PivotBrasRentre(brasTelescopique, pivot).alongWith(new Reculer(basePilotable)), //new Gyro(basePilotable) //); } }