diff --git a/bin/main/frc/robot/commands/BrakeFerme.class b/bin/main/frc/robot/commands/BrakeFerme.class new file mode 100644 index 0000000..9911767 Binary files /dev/null and b/bin/main/frc/robot/commands/BrakeFerme.class differ diff --git a/bin/main/frc/robot/commands/BrakeOuvre.class b/bin/main/frc/robot/commands/BrakeOuvre.class new file mode 100644 index 0000000..17058de Binary files /dev/null and b/bin/main/frc/robot/commands/BrakeOuvre.class differ diff --git a/bin/main/frc/robot/subsystems/BasePilotable.class b/bin/main/frc/robot/subsystems/BasePilotable.class new file mode 100644 index 0000000..a2332e1 Binary files /dev/null and b/bin/main/frc/robot/subsystems/BasePilotable.class differ diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 196a748..450a43b 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -5,28 +5,24 @@ public class Constants { public static int avantgauche = 1; public static int arrieredroit = 2; public static int arrieregauche = 3; + public static int BrasTelescopique = 4; + + //moteur gris public static int leverGratte = 0; public static int baisserGratte = 1; - public static int BrasTelescopique = 5; + // pneumatique public static int pistonpinceouvre = 0; public static int pistonpinceferme = 1; public static int actuateur = 2; public static int brakedroit = 3; public static int brakegauche = 4; - // DIO + // DIO Brando public static int limitbd = 0; public static int limitbg = 2; public static int limithd = 3; public static int limithg = 1; - - - - - - - - } + \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/BrakeFerme.java b/src/main/java/frc/robot/commands/BrakeFerme.java new file mode 100644 index 0000000..cd2be53 --- /dev/null +++ b/src/main/java/frc/robot/commands/BrakeFerme.java @@ -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.CommandBase; +import frc.robot.subsystems.BasePilotable; + +public class BrakeFerme extends CommandBase { + + private BasePilotable basePilotable; + + /** Creates a new BrakeFerme. */ + public BrakeFerme(BasePilotable basePilotable) { + this.basePilotable = basePilotable; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(basePilotable); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + basePilotable.BrakeFerme(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + + } + + // 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; + } +} diff --git a/src/main/java/frc/robot/commands/BrakeOuvre.java b/src/main/java/frc/robot/commands/BrakeOuvre.java new file mode 100644 index 0000000..96b0997 --- /dev/null +++ b/src/main/java/frc/robot/commands/BrakeOuvre.java @@ -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.CommandBase; +import frc.robot.subsystems.BasePilotable; + +public class BrakeOuvre extends CommandBase { + + private BasePilotable basePilotable; + + /** Creates a new BrakeFerme. */ + public BrakeOuvre(BasePilotable basePilotable) { + this.basePilotable = basePilotable; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(basePilotable); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + basePilotable.BrakeOuvre(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + + } + + // 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; + } +} diff --git a/src/main/java/frc/robot/commands/Gyro.java b/src/main/java/frc/robot/commands/Gyro.java new file mode 100644 index 0000000..f2dd5b8 --- /dev/null +++ b/src/main/java/frc/robot/commands/Gyro.java @@ -0,0 +1,49 @@ +// 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.CommandBase; +import frc.robot.subsystems.BasePilotable; + +public class Gyro extends CommandBase { + private BasePilotable basePilotable; + /** Creates a new Gyro. */ + public Gyro(BasePilotable basePilotable) { + this.basePilotable = basePilotable; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(basePilotable); + } + + // 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(basePilotable.getpitch()<15) + { + basePilotable.drive(0.2, 0, 0); + } + else if(basePilotable.getpitch()>-15) + { + basePilotable.drive(-0.2, 0, 0); + } + else + { + basePilotable.drive(0, 0, 0); + } +} + + // 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; + } +} diff --git a/src/main/java/frc/robot/commands/bras/PivoteBrasBas.java b/src/main/java/frc/robot/commands/bras/PivoteBrasBas.java index de9ddfb..038ec51 100644 --- a/src/main/java/frc/robot/commands/bras/PivoteBrasBas.java +++ b/src/main/java/frc/robot/commands/bras/PivoteBrasBas.java @@ -54,7 +54,6 @@ public class PivoteBrasBas extends CommandBase { // 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() { diff --git a/src/main/java/frc/robot/subsystems/BasePilotable.java b/src/main/java/frc/robot/subsystems/BasePilotable.java index e7e12fc..9b1eb24 100644 --- a/src/main/java/frc/robot/subsystems/BasePilotable.java +++ b/src/main/java/frc/robot/subsystems/BasePilotable.java @@ -4,11 +4,12 @@ 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.wpilibj2.command.SubsystemBase; @@ -22,10 +23,16 @@ public class BasePilotable extends SubsystemBase { final MotorControllerGroup droit = new MotorControllerGroup(avantdroit, arrieredroit); final MotorControllerGroup gauche = new MotorControllerGroup(avantgauche, arrieregauche); final DifferentialDrive drive = new DifferentialDrive(gauche, droit); - final DoubleSolenoid brakedroit = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.pistonpinceouvre, Constants.pistonpinceferme); - final DoubleSolenoid brakegauche = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.pistonpinceouvre, Constants.pistonpinceferme); - - public void drive(double xSpeed, double zRotation){ + //piston + private DoubleSolenoid brakedroit = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.brakedroit, Constants.brakedroit); + private DoubleSolenoid brakegauche = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.brakegauche, Constants.brakegauche); + //gyro + private AHRS gyroscope = new AHRS();public double getangle() {return gyroscope.getAngle();} + public double getpitch() { + return gyroscope.getPitch(); + } + + public void drive(double xSpeed, double zRotation, int i){ drive.arcadeDrive(xSpeed, zRotation); } public double distance(){ @@ -40,7 +47,14 @@ public class BasePilotable extends SubsystemBase { arrieredroit.getEncoder().setPosition(0); arrieregauche.getEncoder().setPosition(0); } - +public void BrakeOuvre(){ + brakedroit.set(Value.kForward); + brakegauche.set(Value.kForward); +} +public void BrakeFerme(){ + brakedroit.set(Value.kReverse); + brakegauche.set(Value.kReverse); +} /** Creates a new BasePilotable. */ public BasePilotable() { droit.setInverted(true); diff --git a/src/main/java/frc/robot/subsystems/Gratte.java b/src/main/java/frc/robot/subsystems/Gratte.java index 58c7d11..9bc4bb1 100644 --- a/src/main/java/frc/robot/subsystems/Gratte.java +++ b/src/main/java/frc/robot/subsystems/Gratte.java @@ -9,8 +9,6 @@ import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; import edu.wpi.first.wpilibj.DigitalInput; import frc.robot.Constants; - - public class Gratte extends SubsystemBase { private WPI_TalonSRX Gratted = new WPI_TalonSRX(Constants.leverGratte); private WPI_TalonSRX Gratteg = new WPI_TalonSRX(Constants.baisserGratte);