Merge branch 'main' of https://demerso.net/pls5618/2023/robot
This commit is contained in:
		| @@ -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; | ||||
|      | ||||
|      | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|      | ||||
|  | ||||
| } | ||||
|    | ||||
							
								
								
									
										42
									
								
								src/main/java/frc/robot/commands/BrakeFerme.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/main/java/frc/robot/commands/BrakeFerme.java
									
									
									
									
									
										Normal 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; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										42
									
								
								src/main/java/frc/robot/commands/BrakeOuvre.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/main/java/frc/robot/commands/BrakeOuvre.java
									
									
									
									
									
										Normal 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; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										49
									
								
								src/main/java/frc/robot/commands/Gyro.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								src/main/java/frc/robot/commands/Gyro.java
									
									
									
									
									
										Normal 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; | ||||
|   } | ||||
| } | ||||
| @@ -54,7 +54,6 @@ public class PivoteBrasBas extends CommandBase { | ||||
|   // 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() { | ||||
|   | ||||
| @@ -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); | ||||
|    | ||||
|   public void drive(double xSpeed, double zRotation){ | ||||
|   //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, 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); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user