Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
831b9fec75 | ||
|
982db16833 | ||
|
12b5e6954e | ||
|
7e40328af4 | ||
|
9653ca7205 | ||
|
1583a95f52 |
@ -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");
|
||||
|
47
src/main/java/frc/robot/command/GrimperHaut.java
Normal file
47
src/main/java/frc/robot/command/GrimperHaut.java
Normal 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;
|
||||
}
|
||||
}
|
47
src/main/java/frc/robot/command/GrimpeurBas.java
Normal file
47
src/main/java/frc/robot/command/GrimpeurBas.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user