Merge branch 'main' of https://git.demerso.net/pls5618/2024/robot
This commit is contained in:
commit
83069a3fda
51
src/main/java/frc/robot/command/GrimpeurBas.java
Normal file
51
src/main/java/frc/robot/command/GrimpeurBas.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.command;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import frc.robot.subsystem.Grimpeur;
|
||||
|
||||
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() {
|
||||
grimpeur.resetencodeurd();
|
||||
grimpeur.resetencodeurg();
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
if(grimpeur.droite()){
|
||||
grimpeur.resetencodeurd();
|
||||
grimpeur.gauche(0);
|
||||
}
|
||||
if(grimpeur.gauche()){
|
||||
grimpeur.resetencodeurg();
|
||||
grimpeur.gauche(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
grimpeur.droit(0);
|
||||
grimpeur.gauche(0);
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -7,10 +7,10 @@ package frc.robot.command;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import frc.robot.subsystem.Grimpeur;
|
||||
|
||||
public class GrimpeurHaut extends Command {
|
||||
public class GrimpeurHautDroit extends Command {
|
||||
private Grimpeur grimpeur;
|
||||
/** Creates a new GrimpeurHaut. */
|
||||
public GrimpeurHaut(Grimpeur grimpeur) {
|
||||
public GrimpeurHautDroit(Grimpeur grimpeur) {
|
||||
this.grimpeur = grimpeur;
|
||||
addRequirements(grimpeur);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
@ -18,17 +18,35 @@ public class GrimpeurHaut extends Command {
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {}
|
||||
public void initialize() {
|
||||
grimpeur.resetencodeurd();
|
||||
grimpeur.resetencodeurg();
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
if(grimpeur.encoderd()>261 ){
|
||||
grimpeur.droit(0);
|
||||
}
|
||||
else if(grimpeur.getpitch()<-15){
|
||||
grimpeur.droit(-0.6);
|
||||
|
||||
}
|
||||
else if(grimpeur.getpitch()>15){
|
||||
grimpeur.droit(0.6);
|
||||
}
|
||||
else{
|
||||
grimpeur.droit(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {}
|
||||
public void end(boolean interrupted) {
|
||||
grimpeur.droit(0);
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
55
src/main/java/frc/robot/command/GrimpeurHautGauche.java
Normal file
55
src/main/java/frc/robot/command/GrimpeurHautGauche.java
Normal file
@ -0,0 +1,55 @@
|
||||
// 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.subsystem.Grimpeur;
|
||||
|
||||
public class GrimpeurHautGauche extends Command {
|
||||
private Grimpeur grimpeur;
|
||||
/** Creates a new GrimpeurHautGauche. */
|
||||
public GrimpeurHautGauche(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() {
|
||||
grimpeur.resetencodeurd();
|
||||
grimpeur.resetencodeurg();
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
if(grimpeur.encoderg()>261 ){
|
||||
grimpeur.gauche(0);
|
||||
}
|
||||
else if(grimpeur.getpitch()<-15){
|
||||
grimpeur.gauche(0.6);
|
||||
|
||||
}
|
||||
else if(grimpeur.getpitch()>15){
|
||||
grimpeur.gauche(-0.6);
|
||||
}
|
||||
else{
|
||||
grimpeur.gauche(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
grimpeur.gauche(0);
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -4,12 +4,22 @@
|
||||
|
||||
package frc.robot.command;
|
||||
|
||||
import com.revrobotics.CANSparkMax;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import frc.robot.subsystem.Accumulateur;
|
||||
import frc.robot.subsystem.Lanceur;
|
||||
|
||||
public class Lancer extends Command {
|
||||
/** Creates a new Lanceur. */
|
||||
|
||||
private Lanceur lancer;
|
||||
private Lanceur lancer2;
|
||||
private Lanceur lancer3;
|
||||
private Lanceur lancer4;
|
||||
public Lancer() {
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
addRequirements(lancer,lancer2,lancer3,lancer4);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@ -18,11 +28,15 @@ public class Lancer extends Command {
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {}
|
||||
public void execute() {
|
||||
lancer.lancer(0.3);
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {}
|
||||
public void end(boolean interrupted) {
|
||||
lancer.lancer(0);
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
|
@ -9,14 +9,18 @@ import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import frc.robot.Constants;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
|
||||
|
||||
public class Accumulateur extends SubsystemBase {
|
||||
/** Creates a new Accumulateur. */
|
||||
|
||||
|
||||
ShuffleboardTab dashboard = Shuffleboard.getTab("dashboard");
|
||||
final WPI_TalonSRX Moteuracc2 = new WPI_TalonSRX(Constants.Moteuracc2);
|
||||
final WPI_TalonSRX Moteuracc = new WPI_TalonSRX(Constants.Moteuracc);
|
||||
final DigitalInput limitacc = new DigitalInput(Constants.limitacc);
|
||||
final DigitalInput limitacc = new DigitalInput(Constants.limitacc);
|
||||
|
||||
public void Deaccumuler(double vitesse){
|
||||
Moteuracc2.set(vitesse);
|
||||
}
|
||||
@ -27,7 +31,9 @@ public class Accumulateur extends SubsystemBase {
|
||||
public boolean limitswitch(){
|
||||
return limitacc.get();
|
||||
}
|
||||
public Accumulateur() {}
|
||||
public Accumulateur() {
|
||||
dashboard.addBoolean("limitacc", this::limitswitch);
|
||||
}
|
||||
public void Accumuler(double vitesse){
|
||||
Moteuracc.set(vitesse);
|
||||
Moteuracc2.set(vitesse);
|
||||
|
@ -45,7 +45,12 @@ public void resetencodeurd(){
|
||||
public void resetencodeurg(){
|
||||
grimpeurg.getEncoder().setPosition(0);
|
||||
}
|
||||
|
||||
public double encoderd(){
|
||||
return grimpeurd.getEncoder().getPosition();
|
||||
}
|
||||
public double encoderg(){
|
||||
return grimpeurg.getEncoder().getPosition();
|
||||
}
|
||||
public AHRS gyroscope = new AHRS();
|
||||
public double getpitch(){
|
||||
return gyroscope.getPitch();
|
||||
|
@ -18,13 +18,13 @@ public class Lanceur extends SubsystemBase {
|
||||
public Lanceur() {}
|
||||
final CANSparkMax lancer = new CANSparkMax(Constants.lanceur, MotorType.kBrushless);
|
||||
final CANSparkMax lancer2 = new CANSparkMax(Constants.lancer2, MotorType.kBrushless);
|
||||
final CANSparkMax lancer3 = new CANSparkMax(Constants.lanceur, MotorType.kBrushless);
|
||||
final CANSparkMax lancer4 = new CANSparkMax(Constants.lancer2, MotorType.kBrushless);
|
||||
final CANSparkMax lancer3 = new CANSparkMax(Constants.lancer3, MotorType.kBrushless);
|
||||
final CANSparkMax lancer4 = new CANSparkMax(Constants.lancer4, MotorType.kBrushless);
|
||||
|
||||
public void lancer(double vitesse){
|
||||
lancer.set(vitesse);
|
||||
public void lancer(double vitesse){
|
||||
lancer.set(vitesse);
|
||||
}
|
||||
public void lanceur(){
|
||||
public void lanceur(){
|
||||
lancer2.follow(lancer);
|
||||
lancer3.follow(lancer);
|
||||
lancer4.follow(lancer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user