This commit is contained in:
samuel desharnais 2024-02-12 18:15:00 -05:00
commit 4e205b00d2

View File

@ -10,14 +10,12 @@ import com.revrobotics.CANSparkLowLevel.MotorType;
import edu.wpi.first.networktables.GenericEntry; import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.PneumaticsModuleType; import edu.wpi.first.wpilibj.PneumaticsModuleType;
import edu.wpi.first.wpilibj.Solenoid; import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts; import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
import edu.wpi.first.wpilibj2.command.SubsystemBase; import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants; import frc.robot.Constants;
@ -33,15 +31,11 @@ public class Grimpeur extends SubsystemBase {
final CANSparkMax grimpeurd = new CANSparkMax(Constants.grimpeurd,MotorType.kBrushless); final CANSparkMax grimpeurd = new CANSparkMax(Constants.grimpeurd,MotorType.kBrushless);
final CANSparkMax grimpeurg = new CANSparkMax(Constants.grimpeurg,MotorType.kBrushless); final CANSparkMax grimpeurg = new CANSparkMax(Constants.grimpeurg,MotorType.kBrushless);
// limit switch // limit switch
final DigitalInput limitdroite = new DigitalInput(Constants.limithaut);
final DigitalInput limitgauche = new DigitalInput(Constants.limitbas);
final Solenoid pistondroite= new Solenoid(PneumaticsModuleType.CTREPCM, Constants.pistondroiteouvre); final Solenoid pistondroite= new Solenoid(PneumaticsModuleType.CTREPCM, Constants.pistondroiteouvre);
final Solenoid pistondgauche = new Solenoid(PneumaticsModuleType.CTREPCM, Constants.pistondgaucheouvre); final Solenoid pistondgauche = new Solenoid(PneumaticsModuleType.CTREPCM, Constants.pistondgaucheouvre);
//fonction //fonction
public Grimpeur() { public Grimpeur() {
pistonferme(); pistonferme();
layout.addBoolean("limitgrimpeurd", limitdroite::get);
layout.addBoolean("limitgrimpeurg", limitdroite::get);
layout.add("grimpeurencodeurd", encoderd()); layout.add("grimpeurencodeurd", encoderd());
layout.add("grimpeurencodeurg", encoderg()); layout.add("grimpeurencodeurg", encoderg());
layout.add("pitchgyrogrimpeur", getpitch()); layout.add("pitchgyrogrimpeur", getpitch());
@ -52,12 +46,6 @@ public void droit(double vitesse){
public void gauche(double vitesse){ public void gauche(double vitesse){
grimpeurg.set(vitesse); grimpeurg.set(vitesse);
} }
public boolean droite(){
return limitdroite.get();
}
public boolean gauche(){
return limitgauche.get();
}
public void resetencodeurd(){ public void resetencodeurd(){
grimpeurd.getEncoder().setPosition(0); grimpeurd.getEncoder().setPosition(0);
} }
@ -85,14 +73,10 @@ public AHRS gyroscope = new AHRS();
public boolean piston(){ public boolean piston(){
return pistondgauche.get(); return pistondgauche.get();
} }
@Override
@Override
public void periodic() { public void periodic() {
// This method will be called once per scheduler run // This method will be called once per scheduler run
if(droite()) {
resetencodeurd();
}
if(gauche()) {
resetencodeurg();
}
} }
} }