This commit is contained in:
samuel desharnais 2024-01-22 19:32:35 -05:00
parent 2404f94faa
commit 24ac20a097
2 changed files with 41 additions and 6 deletions

View File

@ -22,9 +22,7 @@ public class Constants {
public static int guideurhaut = 10;
public static int guideurbas = 11;
public static int limitacc = 12;
public static int limitbasd =15;
public static int limitbasg =16;
public static int limithautd =17;
public static int limithautg =18;
public static int limitbas =15;
public static int limithaut =16;
}

View File

@ -4,15 +4,52 @@
package frc.robot.subsystem;
import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkLowLevel.MotorType;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
public class Grimpeur extends SubsystemBase {
/** Creates a new Acrocheur. */
// moteur
public Grimpeur() {}
final
final CANSparkMax grimpeurd = new CANSparkMax(Constants.grimpeurd,MotorType.kBrushless);
final CANSparkMax grimpeurg = new CANSparkMax(Constants.grimpeurg,MotorType.kBrushless);
// limit switch
final DigitalInput limitdroite = new DigitalInput(Constants.limithaut);
final DigitalInput limitgauche = new DigitalInput(Constants.limitbas);
//fonction
public void droit(double vitesse){
grimpeurd.set(vitesse);
}
public void gauche(double vitesse){
grimpeurg.set(vitesse);
}
public boolean droite(){
return limitdroite.get();
}
public boolean gauche(){
return limitgauche.get();
}
public void resetencodeurd(){
grimpeurd.getEncoder().setPosition(0);
}
public void resetencodeurg(){
grimpeurg.getEncoder().setPosition(0);
}
public void grimpeur(){
grimpeurg.follow(grimpeurd);
}
@Override
public void periodic() {
// This method will be called once per scheduler run
if(droite()) {
resetencodeurd();
}
if(gauche()) {
resetencodeurg();
}
}
}