Compare commits

...

6 Commits
main ... grimpe

Author SHA1 Message Date
Antoine PerreaultE
831b9fec75 Touche grinpeur 2025-01-29 19:51:59 -05:00
Antoine PerreaultE
982db16833 grimpeMieux 2025-01-28 19:22:43 -05:00
Antoine PerreaultE
12b5e6954e 2025-01-28 18:31:02 -05:00
Antoine PerreaultE
7e40328af4 il grimpe mieux 2025-01-28 17:51:17 -05:00
Antoine PerreaultE
9653ca7205 grimpe 2025-01-27 19:12:49 -05:00
Antoine PerreaultE
1583a95f52 il grimpe 2025-01-27 18:40:58 -05:00
4 changed files with 118 additions and 5 deletions

View File

@ -6,13 +6,23 @@ package frc.robot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.command.GrimperHaut;
import frc.robot.command.GrimpeurBas;
import frc.robot.subsystems.Grimpeur;
public class RobotContainer {
CommandXboxController manette1 = new CommandXboxController(0);
CommandXboxController manette2 = new CommandXboxController(0);
Grimpeur grimpeur = new Grimpeur();
public RobotContainer() {
configureBindings();
}
private void configureBindings() {}
private void configureBindings() {
manette1.leftBumper().whileTrue(new GrimperHaut(grimpeur));
manette1.rightBumper().whileTrue(new GrimpeurBas(grimpeur));
}
public Command getAutonomousCommand() {
return Commands.print("No autonomous command configured");

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.command;
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 GrimperHaut extends Command {
private Grimpeur grimpeur;
/** Creates a new Grimper. */
public GrimperHaut(Grimpeur grimpeur) {
this.grimpeur = new 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.stop()==true){
grimpeur.grimpe(0);
grimpeur.reset();
}
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 grimpeur.stop()==true;
}
}

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.command;
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()>=500 && grimpeur.encodeur()<=510){
grimpeur.grimpe(0);
}
else if(grimpeur.encodeur()>=510){
grimpeur.grimpe(0.5);
}
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;
}
}

View File

@ -4,21 +4,30 @@
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.motorcontrol.Spark;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class Grimpeur extends SubsystemBase {
/** Creates a new Grimpeur. */
public Grimpeur() {}
final Spark grimpeur = new Spark(0);
final SparkMax grimpeur = new SparkMax(0,MotorType.kBrushless);
final DigitalInput limit1 = new DigitalInput(0);
public void grimpe(double vitesse){
grimpeur.set(vitesse);
}
final void stop(){
limit1.get();
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