This commit is contained in:
EdwardFaucher 2023-02-15 18:11:56 -05:00
commit c8958d765f
14 changed files with 290 additions and 30 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 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;
}

View File

@ -6,6 +6,25 @@ package frc.robot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
//subsystems
import frc.robot.subsystems.BasePilotable;
import frc.robot.subsystems.Gratte;
import frc.robot.subsystems.bras.BrasTelescopique;
import frc.robot.subsystems.bras.Pince;
import frc.robot.subsystems.bras.Pivot;
import frc.robot.subsystems.Limelight;
// command
import frc.robot.commands.BrakeFerme;
import frc.robot.commands.BrakeOuvre;
import frc.robot.commands.GratteBaisser;
import frc.robot.commands.GratteMonte;
import frc.robot.commands.Gyro;
import frc.robot.commands.bras.FermePince;
import frc.robot.commands.bras.OuvrePince;
import frc.robot.commands.bras.PivotBrasRentre;
import frc.robot.commands.bras.PivoteBrasBas;
import frc.robot.commands.bras.PivoteBrasHaut;
import frc.robot.commands.bras.PivoteBrasMilieux;
public class RobotContainer {
public RobotContainer() {

View File

@ -5,20 +5,30 @@
package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.BasePilotable;
public class StablePlateform extends CommandBase {
/** Creates a new StablePlateform. */
public StablePlateform() {
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() {}
public void initialize() {
basePilotable.BrakeFerme();
}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}
public void execute() {
}
// Called once the command ends or is interrupted.
@Override

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()<10)
{
basePilotable.drive(0.4, 0, 0);
}
else if(basePilotable.getpitch()>-10)
{
basePilotable.drive(-0.4, 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

@ -0,0 +1,47 @@
// 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.bras;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.bras.BrasTelescopique;
import frc.robot.subsystems.bras.Pivot;
public class PivotBrasRentre extends CommandBase {
private BrasTelescopique brasTelescopique;
private Pivot pivot;
/** Creates a new PivotBrasRentre. */
public PivotBrasRentre(BrasTelescopique brasTelescopique, Pivot pivot) {
this.brasTelescopique = brasTelescopique;
this.pivot = pivot;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(brasTelescopique);
addRequirements(pivot);
}
// 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(brasTelescopique.distance()>1){
brasTelescopique.AvanceRecule(0.5);
}
if (pivot.distance()>1){
pivot.monteDescendre(0.5);
}
}
// 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

@ -4,12 +4,22 @@
package frc.robot.commands.bras;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.bras.BrasTelescopique;
import frc.robot.subsystems.bras.Pivot;
public class PivoteBrasBas extends CommandBase {
private BrasTelescopique brasTelescopique;
private Pivot pivot;
/** Creates a new PivoteBrasBas. */
public PivoteBrasBas() {
public PivoteBrasBas(BrasTelescopique brasTelescopique, Pivot pivot) {
this.brasTelescopique = brasTelescopique;
this.pivot = pivot;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(brasTelescopique);
addRequirements(pivot);
}
// Called when the command is initially scheduled.
@ -18,12 +28,32 @@ public class PivoteBrasBas extends CommandBase {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}
public void execute() {
if(brasTelescopique.distance()<10){
brasTelescopique.AvanceRecule(0.5);
}
else if(brasTelescopique.distance()>11) {
brasTelescopique.AvanceRecule(-0.5);
}
else {
brasTelescopique.AvanceRecule(0);
}
if (pivot.distance()<10){
pivot.monteDescendre(0.5);
}
else if(pivot.distance()>11) {
pivot.monteDescendre(-0.5);
}
else{
pivot.monteDescendre(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() {

View File

@ -5,11 +5,19 @@
package frc.robot.commands.bras;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.bras.BrasTelescopique;
import frc.robot.subsystems.bras.Pivot;
public class PivoteBrasHaut extends CommandBase {
private BrasTelescopique brasTelescopique;
private Pivot pivot;
/** Creates a new PivoteBrasHaut. */
public PivoteBrasHaut() {
public PivoteBrasHaut(BrasTelescopique brasTelescopique, Pivot pivot) {
this.brasTelescopique = brasTelescopique;
this.pivot = pivot;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(brasTelescopique);
addRequirements(pivot);
}
// Called when the command is initially scheduled.
@ -18,7 +26,26 @@ public class PivoteBrasHaut extends CommandBase {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}
public void execute() {
if(brasTelescopique.distance()<10){
brasTelescopique.AvanceRecule(0.5);
}
else if(brasTelescopique.distance()>11) {
brasTelescopique.AvanceRecule(-0.5);
}
else {
brasTelescopique.AvanceRecule(0);
}
if (pivot.distance()<10){
pivot.monteDescendre(0.5);
}
else if(pivot.distance()>11) {
pivot.monteDescendre(-0.5);
}
else{
pivot.monteDescendre(0);
}
}
// Called once the command ends or is interrupted.
@Override

View File

@ -5,11 +5,19 @@
package frc.robot.commands.bras;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.bras.BrasTelescopique;
import frc.robot.subsystems.bras.Pivot;
public class PivoteBrasMilieux extends CommandBase {
private BrasTelescopique brasTelescopique;
private Pivot pivot;
/** Creates a new PivoteBrasMilieux. */
public PivoteBrasMilieux() {
public PivoteBrasMilieux(BrasTelescopique brasTelescopique, Pivot pivot) {
this.brasTelescopique = brasTelescopique;
this.pivot = pivot;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(brasTelescopique);
addRequirements(pivot);
}
// Called when the command is initially scheduled.
@ -18,7 +26,27 @@ public class PivoteBrasMilieux extends CommandBase {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}
public void execute() {
if(brasTelescopique.distance()<10){
brasTelescopique.AvanceRecule(0.5);
}
else if(brasTelescopique.distance()>11) {
brasTelescopique.AvanceRecule(-0.5);
}
else {
brasTelescopique.AvanceRecule(0);
}
if (pivot.distance()<10){
pivot.monteDescendre(0.5);
}
else if(pivot.distance()>11) {
pivot.monteDescendre(-0.5);
}
else{
pivot.monteDescendre(0);
}
}
// Called once the command ends or is interrupted.
@Override

View File

@ -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);
//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){
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);

View File

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