diff --git a/simgui-ds.json b/simgui-ds.json index 1ba71ce..4a63cc1 100644 --- a/simgui-ds.json +++ b/simgui-ds.json @@ -1,9 +1,4 @@ { - "Joysticks": { - "window": { - "visible": false - } - }, "System Joysticks": { "window": { "enabled": false diff --git a/src/main/java/frc/robot/commands/GrimperHaut.java b/src/main/java/frc/robot/commands/GrimperHaut.java new file mode 100644 index 0000000..ad0ebf0 --- /dev/null +++ b/src/main/java/frc/robot/commands/GrimperHaut.java @@ -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; + } +} diff --git a/src/main/java/frc/robot/commands/GrimpeurBas.java b/src/main/java/frc/robot/commands/GrimpeurBas.java new file mode 100644 index 0000000..d6d27f7 --- /dev/null +++ b/src/main/java/frc/robot/commands/GrimpeurBas.java @@ -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; + } +} diff --git a/src/main/java/frc/robot/commands/GrimpeurManuel.java b/src/main/java/frc/robot/commands/GrimpeurManuel.java new file mode 100644 index 0000000..31a404b --- /dev/null +++ b/src/main/java/frc/robot/commands/GrimpeurManuel.java @@ -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; + } +} diff --git a/src/main/java/frc/robot/commands/RainBow.java b/src/main/java/frc/robot/commands/RainBow.java index 2c4e5e2..3929ea2 100644 --- a/src/main/java/frc/robot/commands/RainBow.java +++ b/src/main/java/frc/robot/commands/RainBow.java @@ -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); diff --git a/src/main/java/frc/robot/commands/ResetGrimpeur.java b/src/main/java/frc/robot/commands/ResetGrimpeur.java new file mode 100644 index 0000000..b4e6978 --- /dev/null +++ b/src/main/java/frc/robot/commands/ResetGrimpeur.java @@ -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; + } +} diff --git a/src/main/java/frc/robot/subsystems/Grimpeur.java b/src/main/java/frc/robot/subsystems/Grimpeur.java new file mode 100644 index 0000000..759c4b3 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Grimpeur.java @@ -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 + } +}