From 99ce225dc62b77c9d29c823ee2284d1017e529eb Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 8 Mar 2023 19:11:46 -0500 Subject: [PATCH 1/3] df --- .../frc/robot/subsystems/BasePilotable.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/BasePilotable.java b/src/main/java/frc/robot/subsystems/BasePilotable.java index 9c1b909..cc90ca1 100644 --- a/src/main/java/frc/robot/subsystems/BasePilotable.java +++ b/src/main/java/frc/robot/subsystems/BasePilotable.java @@ -7,22 +7,25 @@ package frc.robot.subsystems; import com.kauailabs.navx.frc.AHRS; import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkMaxLowLevel.MotorType; + import edu.wpi.first.wpilibj.DoubleSolenoid; import edu.wpi.first.wpilibj.PneumaticsModuleType; import edu.wpi.first.wpilibj.DoubleSolenoid.Value; import edu.wpi.first.wpilibj.drive.DifferentialDrive; import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup; +import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; +import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Constants; public class BasePilotable extends SubsystemBase { - final CANSparkMax avantd = new CANSparkMax(Constants.avantdroit, MotorType.kBrushless); + final CANSparkMax avantdroit = new CANSparkMax(Constants.avantdroit, MotorType.kBrushless); final CANSparkMax avantgauche = new CANSparkMax(Constants.avantgauche, MotorType.kBrushless); final CANSparkMax arrieredroit = new CANSparkMax(Constants.arrieredroit, MotorType.kBrushless); final CANSparkMax arrieregauche = new CANSparkMax(Constants.arrieregauche, MotorType.kBrushless); - final MotorControllerGroup droit = new MotorControllerGroup(avantd, arrieredroit); + final MotorControllerGroup droit = new MotorControllerGroup(avantdroit, arrieredroit); final MotorControllerGroup gauche = new MotorControllerGroup(avantgauche, arrieregauche); final DifferentialDrive drive = new DifferentialDrive(gauche, droit); @@ -31,26 +34,35 @@ public class BasePilotable extends SubsystemBase { private DoubleSolenoid brakegauche = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.brakegauche, Constants.brakegauche); //gyro ShuffleboardTab teb = Shuffleboard.getTab("teb"); + ShuffleboardLayout layout = Shuffleboard.getTab("teb") + .getLayout ("encodeurs base pilotable", BuiltInLayouts.kList) + .withSize(2, 2); private AHRS gyroscope = new AHRS();public double getangle() {return gyroscope.getAngle();} public double getpitch() { return gyroscope.getPitch(); } - public void drive(double xSpeed, double zRotation){ + public void drive(double xSpeed, double zRotation, int i){ drive.arcadeDrive(xSpeed, zRotation); } public double distance(){ - return (-avantd.getEncoder().getPosition() + teb .add ("distance",0.1); + return (-avantdroit.getEncoder().getPosition() +avantgauche.getEncoder().getPosition() -arrieredroit.getEncoder().getPosition() +arrieregauche.getEncoder().getPosition()) / 4; } public void Reset() { - avantd.getEncoder().setPosition(0); + avantdroit.getEncoder().setPosition(0); avantgauche.getEncoder().setPosition(0); arrieredroit.getEncoder().setPosition(0); arrieregauche.getEncoder().setPosition(0); } + public void resetGyro(){ + {gyroscope.reset(); + } + } + public void BrakeOuvre(){ brakedroit.set(Value.kForward); brakegauche.set(Value.kForward); @@ -59,24 +71,13 @@ public void BrakeFerme(){ brakedroit.set(Value.kReverse); brakegauche.set(Value.kReverse); } -public void resetGyro(){ - {gyroscope.reset();} - } /** Creates a new BasePilotable. */ public BasePilotable() { droit.setInverted(true); - teb .addDouble("distance", this::distance); } @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); - + } -} \ No newline at end of file +} From fc4607f3c6d7203a155182eded4626d37f75de5e Mon Sep 17 00:00:00 2001 From: OlivierDubois Date: Wed, 8 Mar 2023 19:14:16 -0500 Subject: [PATCH 2/3] rft --- src/main/java/frc/robot/RobotContainer.java | 9 ++++----- src/main/java/frc/robot/commands/Apriltag.java | 2 +- src/main/java/frc/robot/commands/Cone.java | 2 +- src/main/java/frc/robot/commands/Cube.java | 2 +- src/main/java/frc/robot/commands/Gyro.java | 10 +++++----- src/main/java/frc/robot/commands/Reculer.java | 2 +- src/main/java/frc/robot/commands/Tape.java | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 669f3f5..3612eaa 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -7,7 +7,6 @@ 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.RunCommand; -import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; //subsystems @@ -25,7 +24,6 @@ import frc.robot.commands.Cone; import frc.robot.commands.GratteBaisser; import frc.robot.commands.GratteMonte; import frc.robot.commands.Gyro; -import frc.robot.commands.Reculer; import frc.robot.commands.bras.FermePince; import frc.robot.commands.bras.OuvrePince; import frc.robot.commands.bras.PivotBrasRentre; @@ -33,7 +31,6 @@ 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; @@ -74,13 +71,15 @@ public RobotContainer() { configureBindings(); CameraServer.startAutomaticCapture(); basePilotable.setDefaultCommand(new RunCommand(() -> { - basePilotable.drive(-manette1.getLeftY(), manette1.getLeftX()); + basePilotable.drive(-manette1.getLeftY(), manette1.getLeftX(), 0); },basePilotable)); } private void configureBindings() { - + basePilotable.setDefaultCommand(new RunCommand(() -> { + basePilotable.drive(-manette1.getLeftY(), -manette1.getLeftX(), 0); + },basePilotable)); // manette 1 manette1.povDown().onTrue(pivoteBrasHaut); manette1.povUp().onTrue(pivoteBrasBas); diff --git a/src/main/java/frc/robot/commands/Apriltag.java b/src/main/java/frc/robot/commands/Apriltag.java index 9ef54b3..3ef6b06 100644 --- a/src/main/java/frc/robot/commands/Apriltag.java +++ b/src/main/java/frc/robot/commands/Apriltag.java @@ -32,7 +32,7 @@ public class Apriltag extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw()); + basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw(), 0); } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/Cone.java b/src/main/java/frc/robot/commands/Cone.java index d780293..8121b19 100644 --- a/src/main/java/frc/robot/commands/Cone.java +++ b/src/main/java/frc/robot/commands/Cone.java @@ -32,7 +32,7 @@ public class Cone extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw()); + basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw(), 0); } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/Cube.java b/src/main/java/frc/robot/commands/Cube.java index d54839e..2bd023f 100644 --- a/src/main/java/frc/robot/commands/Cube.java +++ b/src/main/java/frc/robot/commands/Cube.java @@ -32,7 +32,7 @@ public class Cube extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw()); + basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw(), 0); } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/Gyro.java b/src/main/java/frc/robot/commands/Gyro.java index 9665ecb..ffeca0a 100644 --- a/src/main/java/frc/robot/commands/Gyro.java +++ b/src/main/java/frc/robot/commands/Gyro.java @@ -30,20 +30,20 @@ public class Gyro extends CommandBase { public void execute() { if(basePilotable.getpitch()>4) { - basePilotable.drive(0.3*basePilotable.getpitch()/12, 0); + basePilotable.drive(0.3*basePilotable.getpitch()/12, 0, 0); } else if(basePilotable.getpitch()<-4) { - basePilotable.drive(0.3*basePilotable.getpitch()/12, 0); - basePilotable.drive(0.3*basePilotable.getpitch()/15, 0); + basePilotable.drive(0.3*basePilotable.getpitch()/12, 0, 0); + basePilotable.drive(0.3*basePilotable.getpitch()/15, 0, 0); } else if(basePilotable.getpitch()<-4) { - basePilotable.drive(0.3*basePilotable.getpitch()/15, 0); + basePilotable.drive(0.3*basePilotable.getpitch()/15, 0, 0); } else { - basePilotable.drive(0, 0); + basePilotable.drive(0, 0, 0); } } diff --git a/src/main/java/frc/robot/commands/Reculer.java b/src/main/java/frc/robot/commands/Reculer.java index 7ff9989..674ef40 100644 --- a/src/main/java/frc/robot/commands/Reculer.java +++ b/src/main/java/frc/robot/commands/Reculer.java @@ -27,7 +27,7 @@ public class Reculer extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - basePilotable.drive(SmartDashboard.getNumber("vitesse auto", -0.3), 0); + basePilotable.drive(SmartDashboard.getNumber("vitesse auto", -0.3), 0, 0); } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc/robot/commands/Tape.java b/src/main/java/frc/robot/commands/Tape.java index e1346f0..e240da4 100644 --- a/src/main/java/frc/robot/commands/Tape.java +++ b/src/main/java/frc/robot/commands/Tape.java @@ -32,7 +32,7 @@ public class Tape extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw()); + basePilotable.drive(doubleSupplier.getAsDouble(), limelight.getYaw(), 0); } // Called once the command ends or is interrupted. From 8a9a331e66b4837c36657a0b62a1d84471387d16 Mon Sep 17 00:00:00 2001 From: samuel desharnais Date: Wed, 8 Mar 2023 19:42:24 -0500 Subject: [PATCH 3/3] tehgfhcg --- src/main/java/frc/robot/Constants.java | 3 -- src/main/java/frc/robot/RobotContainer.java | 44 +++++++++++++++---- src/main/java/frc/robot/commands/Gyro.java | 4 +- .../java/frc/robot/subsystems/Gratte.java | 4 -- .../subsystems/bras/BrasTelescopique.java | 6 --- .../java/frc/robot/subsystems/bras/Pivot.java | 9 +--- 6 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 6d6e398..e46be4b 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -10,11 +10,8 @@ public class Constants { //moteur public static int leverGratte = 0; -<<<<<<< HEAD public static int baiserGratte = 1; -======= public static int baisserGratte = 1; ->>>>>>> cd7604e30f9d6c974930cf5af86554639315c8a0 // pneumatique public static int pistonpinceouvre = 0; diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index c239352..de3edd1 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -3,7 +3,13 @@ // the WPILib BSD license file in the root directory of this project. package frc.robot; +import java.util.Map; + import edu.wpi.first.cameraserver.CameraServer; +import edu.wpi.first.networktables.GenericEntry; +import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; +import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout; +import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; @@ -34,7 +40,7 @@ import frc.robot.commands.bras.PivoteBrasMilieux; public class RobotContainer { - CameraServer.startAutomaticCapture(); + CommandXboxController manette1 = new CommandXboxController(0); CommandXboxController manette2 = new CommandXboxController(1); // subsystems @@ -57,7 +63,24 @@ 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()); +Reculer reculer = new Reculer(basePilotable); + +SendableChooser chooser = new SendableChooser<>(); +String enhaut = "en bas"; +String aumilieux = "au milieux"; +String enbas = "en bas"; +String nulpart = "nul part"; +ShuffleboardLayout layoutauto = Shuffleboard.getTab("teb").getLayout("auto"); +GenericEntry autobalance = layoutauto.add("choix balance",true).getEntry(); +GenericEntry autosortir = layoutauto.add("choix sorit",false).getEntry(); public RobotContainer() { + chooser.setDefaultOption(enhaut, enhaut); + chooser.addOption(enbas, enbas); + chooser.addOption(aumilieux, aumilieux); + chooser.addOption(nulpart, nulpart); + layoutauto.add("choix hauteur",chooser); + + configureBindings(); basePilotable.setDefaultCommand(new RunCommand(() -> { @@ -79,20 +102,25 @@ public RobotContainer() { manette2.povRight().toggleOnTrue(Commands.startEnd(brasTelescopique::PivotChercheBas, brasTelescopique::PivotChercheBas, brasTelescopique)); manette2.povLeft().toggleOnTrue(Commands.startEnd(brasTelescopique::PivotChercheHaut, brasTelescopique::PivotChercheHaut, brasTelescopique)); manette2.rightBumper().toggleOnTrue(Commands.startEnd(null, null, null)); -<<<<<<< HEAD manette2.leftBumper().toggleOnTrue(Commands.startEnd(null, null, null));**/ -======= manette2.leftBumper().toggleOnTrue(Commands.startEnd(null, null, null)); ->>>>>>> cd7604e30f9d6c974930cf5af86554639315c8a0 } public Command getAutonomousCommand() { + chooser.getSelected(); + autobalance.getBoolean(true); return new SequentialCommandGroup( - new PivoteBrasMilieux(brasTelescopique, pivot), - new OuvrePince(pince), - new PivotBrasRentre(brasTelescopique, pivot).alongWith(new Reculer(basePilotable)), - new Gyro(basePilotable) + Commands.either(gyro, Commands.none(),()-> autobalance.getBoolean(true)), + Commands.either(reculer, Commands.none(),()-> autosortir.getBoolean(true)), + Commands.select(Map.ofEntries( + Map.entry(enhaut,pivoteBrasHaut), + Map.entry(aumilieux,null), + Map.entry(enbas,null), + Map.entry(nulpart,null) + ), chooser::getSelected) ); + + } } diff --git a/src/main/java/frc/robot/commands/Gyro.java b/src/main/java/frc/robot/commands/Gyro.java index 88aec83..06271ec 100644 --- a/src/main/java/frc/robot/commands/Gyro.java +++ b/src/main/java/frc/robot/commands/Gyro.java @@ -23,11 +23,11 @@ public class Gyro extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - if(basePilotable.getpitch()>4) + if(basePilotable.getpitch()>10) { basePilotable.drive(0.3*basePilotable.getpitch()/15, 0); } - else if(basePilotable.getpitch()<-4) + else if(basePilotable.getpitch()<-10) { basePilotable.drive(0.3*basePilotable.getpitch()/15, 0); } diff --git a/src/main/java/frc/robot/subsystems/Gratte.java b/src/main/java/frc/robot/subsystems/Gratte.java index 7176d4f..4fefe9f 100644 --- a/src/main/java/frc/robot/subsystems/Gratte.java +++ b/src/main/java/frc/robot/subsystems/Gratte.java @@ -14,11 +14,7 @@ import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import frc.robot.Constants; public class Gratte extends SubsystemBase { -<<<<<<< HEAD -ShuffleboardTab teb = Shuffleboard.getTab("teb"); -======= ShuffleboardTab teb = Shuffleboard.getTab("teb"); ->>>>>>> cd7604e30f9d6c974930cf5af86554639315c8a0 ShuffleboardLayout limitswitchgratte = Shuffleboard.getTab("teb") .getLayout("limitswitchsgratte", BuiltInLayouts.kList) .withSize(2, 2); diff --git a/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java b/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java index cb92af3..8ddbd77 100644 --- a/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java +++ b/src/main/java/frc/robot/subsystems/bras/BrasTelescopique.java @@ -24,16 +24,10 @@ public class BrasTelescopique extends SubsystemBase { ShuffleboardLayout layout = Shuffleboard.getTab("teb") .getLayout("layout", BuiltInLayouts.kList) .withSize(2, 2); -<<<<<<< HEAD - ShuffleboardLayout bras = Shuffleboard.getTab("teb") - .getLayout("bras", BuiltInLayouts.kList) - .withSize(2, 2); -======= ShuffleboardLayout bras = Shuffleboard.getTab("teb") .getLayout("bras", BuiltInLayouts.kList) .withSize(2, 2); ->>>>>>> cd7604e30f9d6c974930cf5af86554639315c8a0 /** Creates a new BrasTelescopique. */ public BrasTelescopique() {} final CANSparkMax Winch = new CANSparkMax(Constants.BrasTelescopique,MotorType.kBrushless); diff --git a/src/main/java/frc/robot/subsystems/bras/Pivot.java b/src/main/java/frc/robot/subsystems/bras/Pivot.java index e82eecc..acab25c 100644 --- a/src/main/java/frc/robot/subsystems/bras/Pivot.java +++ b/src/main/java/frc/robot/subsystems/bras/Pivot.java @@ -14,11 +14,7 @@ import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkMaxLowLevel.MotorType; public class Pivot extends SubsystemBase { -<<<<<<< HEAD -ShuffleboardTab teb = Shuffleboard.getTab("teb"); -======= ShuffleboardTab teb = Shuffleboard.getTab("teb"); ->>>>>>> cd7604e30f9d6c974930cf5af86554639315c8a0 // moteur private CANSparkMax pivot = new CANSparkMax(Constants.pivot,MotorType.kBrushless); private DigitalInput limitpivot = new DigitalInput(Constants.limitpivot); @@ -43,14 +39,11 @@ ShuffleboardTab teb = Shuffleboard.getTab("teb"); teb .add("encodeur", 0.1); teb .add ("encodeur pivot",0.1); } -<<<<<<< HEAD -} + -======= { teb.add ("encodeur pivot",0.1); } } ->>>>>>> cd7604e30f9d6c974930cf5af86554639315c8a0