This commit is contained in:
samuel desharnais 2023-02-13 19:52:00 -05:00
commit 17f310be9d
10 changed files with 159 additions and 19 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5,28 +5,24 @@ public class Constants {
public static int avantgauche = 1; public static int avantgauche = 1;
public static int arrieredroit = 2; public static int arrieredroit = 2;
public static int arrieregauche = 3; public static int arrieregauche = 3;
public static int BrasTelescopique = 4;
//moteur gris
public static int leverGratte = 0; public static int leverGratte = 0;
public static int baisserGratte = 1; public static int baisserGratte = 1;
public static int BrasTelescopique = 5;
// pneumatique // pneumatique
public static int pistonpinceouvre = 0; public static int pistonpinceouvre = 0;
public static int pistonpinceferme = 1; public static int pistonpinceferme = 1;
public static int actuateur = 2; public static int actuateur = 2;
public static int brakedroit = 3; public static int brakedroit = 3;
public static int brakegauche = 4; public static int brakegauche = 4;
// DIO // DIO Brando
public static int limitbd = 0; public static int limitbd = 0;
public static int limitbg = 2; public static int limitbg = 2;
public static int limithd = 3; public static int limithd = 3;
public static int limithg = 1; public static int limithg = 1;
} }

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -54,7 +54,6 @@ public class PivoteBrasBas extends CommandBase {
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.
@Override @Override
public void end(boolean interrupted) {} public void end(boolean interrupted) {}
// Returns true when the command should end. // Returns true when the command should end.
@Override @Override
public boolean isFinished() { public boolean isFinished() {

View File

@ -4,11 +4,12 @@
package frc.robot.subsystems; package frc.robot.subsystems;
import com.kauailabs.navx.frc.AHRS;
import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType; import com.revrobotics.CANSparkMaxLowLevel.MotorType;
import edu.wpi.first.wpilibj.DoubleSolenoid; import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.PneumaticsModuleType; 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.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup; import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup;
import edu.wpi.first.wpilibj2.command.SubsystemBase; 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 droit = new MotorControllerGroup(avantdroit, arrieredroit);
final MotorControllerGroup gauche = new MotorControllerGroup(avantgauche, arrieregauche); final MotorControllerGroup gauche = new MotorControllerGroup(avantgauche, arrieregauche);
final DifferentialDrive drive = new DifferentialDrive(gauche, droit); final DifferentialDrive drive = new DifferentialDrive(gauche, droit);
final DoubleSolenoid brakedroit = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.pistonpinceouvre, Constants.pistonpinceferme); //piston
final DoubleSolenoid brakegauche = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.pistonpinceouvre, Constants.pistonpinceferme); private DoubleSolenoid brakedroit = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.brakedroit, Constants.brakedroit);
private DoubleSolenoid brakegauche = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.brakegauche, Constants.brakegauche);
public void drive(double xSpeed, double zRotation){ //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); drive.arcadeDrive(xSpeed, zRotation);
} }
public double distance(){ public double distance(){
@ -40,7 +47,14 @@ public class BasePilotable extends SubsystemBase {
arrieredroit.getEncoder().setPosition(0); arrieredroit.getEncoder().setPosition(0);
arrieregauche.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. */ /** Creates a new BasePilotable. */
public BasePilotable() { public BasePilotable() {
droit.setInverted(true); droit.setInverted(true);

View File

@ -9,8 +9,6 @@ import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.DigitalInput;
import frc.robot.Constants; import frc.robot.Constants;
public class Gratte extends SubsystemBase { public class Gratte extends SubsystemBase {
private WPI_TalonSRX Gratted = new WPI_TalonSRX(Constants.leverGratte); private WPI_TalonSRX Gratted = new WPI_TalonSRX(Constants.leverGratte);
private WPI_TalonSRX Gratteg = new WPI_TalonSRX(Constants.baisserGratte); private WPI_TalonSRX Gratteg = new WPI_TalonSRX(Constants.baisserGratte);