41 lines
1.3 KiB
Java
41 lines
1.3 KiB
Java
// 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
|
|
}
|
|
}
|