This commit is contained in:
Olivier Dubois 2023-02-08 19:16:36 -05:00
parent 7082379eec
commit c2fbb7f553
5 changed files with 50 additions and 5 deletions

View File

@ -14,4 +14,5 @@ public class Constants {
public static int actuateur = 4;
} }

View File

@ -22,6 +22,22 @@ public class BasePilotable extends SubsystemBase {
final DifferentialDrive drive = new DifferentialDrive(gauche, droit); final DifferentialDrive drive = new DifferentialDrive(gauche, droit);
public void drive(double xSpeed, double zRotation){
drive.arcadeDrive(xSpeed, zRotation);
}
public double distance(){
return (-avantdroit.getEncoder().getPosition()
+avantgauche.getEncoder().getPosition()
-arrieredroit.getEncoder().getPosition()
+arrieregauche.getEncoder().getPosition()) / 4;
}
public void Reset() {
avantdroit.getEncoder().setPosition(0);
avantgauche.getEncoder().setPosition(0);
arrieredroit.getEncoder().setPosition(0);
arrieregauche.getEncoder().setPosition(0);
}
/** Creates a new BasePilotable. */ /** Creates a new BasePilotable. */
public BasePilotable() { public BasePilotable() {
droit.setInverted(true); droit.setInverted(true);

View File

@ -0,0 +1,17 @@
// 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.subsystems;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class Gratte extends SubsystemBase {
/** Creates a new Gratte. */
public Gratte() {}
@Override
public void periodic() {
// This method will be called once per scheduler run
}
}

View File

@ -14,15 +14,12 @@ public class Pince extends SubsystemBase {
private DoubleSolenoid pistonPince = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.pistonpinceouvre, Constants.pistonpinceferme); private DoubleSolenoid pistonPince = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.pistonpinceouvre, Constants.pistonpinceferme);
/** Creates a new Pince. */ /** Creates a new Pince. */
public Pince() { public Pince() {
} }
public void fermer() { public void fermer() {
pistonPince.set(Value.kReverse); pistonPince.set(Value.kReverse);
} }
public void ouvrir() { public void ouvrir() {
pistonPince.set(Value.kForward); pistonPince.set(Value.kForward);
} }
@Override @Override
public void periodic() { public void periodic() {

View File

@ -5,11 +5,25 @@
package frc.robot.subsystems.bras; package frc.robot.subsystems.bras;
import edu.wpi.first.wpilibj2.command.SubsystemBase; import edu.wpi.first.wpilibj2.command.SubsystemBase;
import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
import static frc.robot.Constants.*;
public class Pivot extends SubsystemBase { public class Pivot extends SubsystemBase {
/** Creates a new Pivot. */ // moteur
public Pivot() {} private CANSparkMax pivot = new CANSparkMax(actuateur, MotorType.kBrushless);
// function
public void monteDescendre(double vitesse) {
pivot.set (vitesse);
}
// encoder
public double distance(){
return (pivot.getEncoder().getPosition());
}
public void Reset(){
pivot.getEncoder().setPosition(0);
}
@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