Merge branch 'grimpe' of https://git.demerso.net/PLS5618/Reefscape-2025
This commit is contained in:
		| @@ -1,9 +1,4 @@ | ||||
| { | ||||
|   "Joysticks": { | ||||
|     "window": { | ||||
|       "visible": false | ||||
|     } | ||||
|   }, | ||||
|   "System Joysticks": { | ||||
|     "window": { | ||||
|       "enabled": false | ||||
|   | ||||
							
								
								
									
										56
									
								
								src/main/java/frc/robot/commands/GrimperHaut.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								src/main/java/frc/robot/commands/GrimperHaut.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| // 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.Command; | ||||
| import frc.robot.subsystems.Bougie; | ||||
| import frc.robot.subsystems.Grimpeur; | ||||
|  | ||||
| /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ | ||||
| public class GrimperHaut extends Command { | ||||
|   private Grimpeur grimpeur; | ||||
|   private Bougie bougie; | ||||
|   /** Creates a new Grimper. */ | ||||
|   public GrimperHaut(Grimpeur grimpeur, Bougie bougie) { | ||||
|     this.grimpeur = grimpeur; | ||||
|     this.bougie = bougie; | ||||
|     addRequirements(grimpeur,bougie); | ||||
|     // Use addRequirements() here to declare subsystem dependencies. | ||||
|   } | ||||
|  | ||||
|   // 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(grimpeur.stop()==true){ | ||||
|       grimpeur.grimpe(0); | ||||
|       grimpeur.reset(); | ||||
|       bougie.RainBow(); | ||||
|     } | ||||
|     else{ | ||||
|       grimpeur.grimpe(0.5); | ||||
|       bougie.RainBowStop(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // Called once the command ends or is interrupted. | ||||
|   @Override | ||||
|   public void end(boolean interrupted) { | ||||
|     grimpeur.grimpe(0); | ||||
|    if(grimpeur.stop()){ | ||||
|     bougie.RainBow(); | ||||
|    } | ||||
|  | ||||
|   } | ||||
|  | ||||
|   // Returns true when the command should end. | ||||
|   @Override | ||||
|   public boolean isFinished() { | ||||
|     return grimpeur.stop()==true; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										48
									
								
								src/main/java/frc/robot/commands/GrimpeurBas.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/main/java/frc/robot/commands/GrimpeurBas.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| // 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.Command; | ||||
| import frc.robot.subsystems.Grimpeur; | ||||
|  | ||||
| /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ | ||||
| public class GrimpeurBas extends Command { | ||||
|   private Grimpeur grimpeur; | ||||
|   /** Creates a new GrimpeurBas. */ | ||||
|   public GrimpeurBas(Grimpeur grimpeur) { | ||||
|     this.grimpeur = grimpeur; | ||||
|     addRequirements(grimpeur); | ||||
|     // Use addRequirements() here to declare subsystem dependencies. | ||||
|   } | ||||
|  | ||||
|   // 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(grimpeur.encodeur()>=-38.5 && grimpeur.encodeur()<=-39.19){ | ||||
|       grimpeur.grimpe(0); | ||||
|     } | ||||
|     else if(grimpeur.encodeur()>=-38.5){ | ||||
|       grimpeur.grimpe(-0.5); | ||||
|     } | ||||
|    else{grimpeur.grimpe(0.5); | ||||
|   }  | ||||
|   } | ||||
|  | ||||
|   // Called once the command ends or is interrupted. | ||||
|   @Override | ||||
|   public void end(boolean interrupted) { | ||||
|     grimpeur.grimpe(0); | ||||
|   } | ||||
|  | ||||
|   // Returns true when the command should end. | ||||
|   @Override | ||||
|   public boolean isFinished() { | ||||
|     return false; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										51
									
								
								src/main/java/frc/robot/commands/GrimpeurManuel.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/main/java/frc/robot/commands/GrimpeurManuel.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| // 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 java.util.function.DoubleSupplier; | ||||
|  | ||||
| import edu.wpi.first.wpilibj2.command.Command; | ||||
| import frc.robot.subsystems.Grimpeur; | ||||
|  | ||||
| /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ | ||||
| public class GrimpeurManuel extends Command { | ||||
|   private Grimpeur grimpeur; | ||||
|   private DoubleSupplier x; | ||||
|   /** Creates a new GrimpeurManuel. */ | ||||
|   public GrimpeurManuel(Grimpeur grimpeur,DoubleSupplier x) { | ||||
|     this.grimpeur = grimpeur; | ||||
|     this.x = x; | ||||
|     addRequirements(grimpeur); | ||||
|     // Use addRequirements() here to declare subsystem dependencies. | ||||
|   } | ||||
|  | ||||
|   // 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(grimpeur.stop()){ | ||||
|       grimpeur.grimpe(0); | ||||
|     } | ||||
|     else{ | ||||
|     grimpeur.grimpe(x.getAsDouble());   | ||||
|     } | ||||
|      | ||||
|   } | ||||
|  | ||||
|   // Called once the command ends or is interrupted. | ||||
|   @Override | ||||
|   public void end(boolean interrupted) { | ||||
|     grimpeur.grimpe(0); | ||||
|   } | ||||
|  | ||||
|   // Returns true when the command should end. | ||||
|   @Override | ||||
|   public boolean isFinished() { | ||||
|     return false; | ||||
|   } | ||||
| } | ||||
| @@ -9,8 +9,8 @@ import frc.robot.subsystems.Bougie; | ||||
|  | ||||
| /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ | ||||
| public class RainBow extends Command { | ||||
|   Bougie bougie; | ||||
|   /** Creates a new RainBow. */ | ||||
|   private Bougie bougie; | ||||
|   public RainBow(Bougie bougie) { | ||||
|     this.bougie = bougie; | ||||
|     addRequirements(bougie); | ||||
|   | ||||
							
								
								
									
										39
									
								
								src/main/java/frc/robot/commands/ResetGrimpeur.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/main/java/frc/robot/commands/ResetGrimpeur.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| // 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.Command; | ||||
| import frc.robot.subsystems.Grimpeur; | ||||
|  | ||||
| /* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */ | ||||
| public class ResetGrimpeur extends Command { | ||||
|   private Grimpeur grimpeur; | ||||
|   /** Creates a new ResetGrimpeur. */ | ||||
|   public ResetGrimpeur(Grimpeur grimpeur) { | ||||
|     this.grimpeur = grimpeur; | ||||
|     addRequirements(grimpeur); | ||||
|     // Use addRequirements() here to declare subsystem dependencies. | ||||
|   } | ||||
|  | ||||
|   // 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() { | ||||
|     grimpeur.reset(); | ||||
|   } | ||||
|  | ||||
|   // 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; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										40
									
								
								src/main/java/frc/robot/subsystems/Grimpeur.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/main/java/frc/robot/subsystems/Grimpeur.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| // 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 com.revrobotics.spark.SparkMax; | ||||
| import com.revrobotics.spark.SparkLowLevel.MotorType; | ||||
|  | ||||
| import edu.wpi.first.wpilibj.DigitalInput; | ||||
| import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; | ||||
| import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; | ||||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||||
|  | ||||
| public class Grimpeur extends SubsystemBase { | ||||
|   /** Creates a new Grimpeur. */ | ||||
|   ShuffleboardTab teb = Shuffleboard.getTab("teb"); | ||||
|   public Grimpeur() { | ||||
|     teb.addBoolean("limit grimpeur", this::stop); | ||||
|     teb.addDouble("encodeur grimpeur", this::encodeur); | ||||
|   } | ||||
|   final SparkMax grimpeur = new SparkMax(21,MotorType.kBrushless); | ||||
|   final DigitalInput limit1 = new DigitalInput(2); | ||||
|   public void grimpe(double vitesse){ | ||||
|     grimpeur.set(vitesse); | ||||
|   } | ||||
|   public boolean stop(){ | ||||
|    return limit1.get(); | ||||
|   } | ||||
|   public double encodeur(){ | ||||
|   return grimpeur.getEncoder().getPosition(); | ||||
|   } | ||||
|   public void reset(){ | ||||
|      grimpeur.getEncoder().setPosition(0); | ||||
|     } | ||||
|   @Override | ||||
|   public void periodic() { | ||||
|     // This method will be called once per scheduler run | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user