Compare commits

..

22 Commits
main ... pince

Author SHA1 Message Date
Antoine PerreaultE
06abfa4dbb Named Commands 2025-01-30 20:18:15 -05:00
Antoine PerreaultE
26a4b9f9a3 touche 2025-01-29 20:15:07 -05:00
Antoine PerreaultE
b384585224 pince mieux 2025-01-29 20:13:38 -05:00
Antoine PerreaultE
ee2c9ff4b2 manette 2025-01-29 19:37:35 -05:00
Antoine PerreaultE
20c95efe93 2025-01-29 19:35:13 -05:00
Antoine PerreaultE
4869632d6d manette pince elevateur 2025-01-29 19:29:01 -05:00
Antoine PerreaultE
afaec61f6d touche pince+elevateur 2025-01-29 19:19:14 -05:00
Antoine PerreaultE
126058e9d4 touche 2025-01-29 19:01:51 -05:00
Antoine PerreaultE
1f17aaf4de pince+elevateur 2025-01-29 18:55:06 -05:00
Antoine PerreaultE
eece0f47fa pince et elevateur 2025-01-29 18:43:31 -05:00
Antoine PerreaultE
c81f118058 Merge branch 'elevateur' into pince 2025-01-29 18:42:45 -05:00
Antoine PerreaultE
7848c4aaf2 debug 2025-01-29 18:12:14 -05:00
Antoine PerreaultE
1d1d6e962d pince 2025-01-28 19:19:34 -05:00
Antoine PerreaultE
d6420659e9 2025-01-28 19:10:42 -05:00
Antoine PerreaultE
aafb2a62b5 Algue 2025-01-28 19:09:16 -05:00
Antoine PerreaultE
0fdfa4269d elevateurise mieux 2025-01-28 18:54:42 -05:00
Antoine PerreaultE
017f168b3c Pince 2025-01-28 18:46:42 -05:00
Antoine PerreaultE
5ffa28596c aspire 2025-01-28 18:24:21 -05:00
Antoine PerreaultE
e7b4b47928 elevateur 2025-01-27 19:51:46 -05:00
Antoine PerreaultE
0577ce368a positon 2025-01-27 19:26:11 -05:00
Antoine PerreaultE
7521c0d94e elevateur 2025-01-27 19:15:16 -05:00
Antoine PerreaultE
b16d11b70a elevateur 2025-01-27 19:11:22 -05:00
14 changed files with 612 additions and 42 deletions

View File

@ -4,18 +4,66 @@
package frc.robot; package frc.robot;
import com.pathplanner.lib.auto.AutoBuilder;
import com.pathplanner.lib.auto.NamedCommands;
import com.pathplanner.lib.auto.AutoBuilder;
import com.pathplanner.lib.auto.NamedCommands;
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.RunCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.command.AlgueExpire;
import frc.robot.command.CoralAlgueInspire;
import frc.robot.command.CoralExpire;
import frc.robot.command.CoralInspire;
import frc.robot.command.Depart;
import frc.robot.command.DepartPince;
import frc.robot.command.ElevateurManuel;
import frc.robot.command.L2;
import frc.robot.command.L3;
import frc.robot.command.L4;
import frc.robot.command.StationPince;
import frc.robot.subsystems.Elevateur;
import frc.robot.subsystems.Pince;
public class RobotContainer { public class RobotContainer {
CommandXboxController manette1 = new CommandXboxController(0); CommandXboxController manette1 = new CommandXboxController(0);
CommandXboxController manette2 = new CommandXboxController(0); CommandXboxController manette2 = new CommandXboxController(0);
private final SendableChooser<Command> autoChooser;
Pince pince = new Pince();
Elevateur elevateur = new Elevateur();
ElevateurManuel elevateurManuel = new ElevateurManuel(elevateur, manette2::getLeftY);
public RobotContainer() { public RobotContainer() {
configureBindings(); configureBindings();
elevateur.setDefaultCommand(new RunCommand(()->{
elevateur.vitesse(MathUtil.applyDeadband(manette2.getLeftY(), 0.2));
}, elevateur));
NamedCommands.registerCommand("Station",new StationPince(pince, elevateur));
NamedCommands.registerCommand("L4", new L4(elevateur, pince));
NamedCommands.registerCommand("L3", new L3(elevateur, pince));
NamedCommands.registerCommand("CoralExpire",new CoralExpire(pince));
NamedCommands.registerCommand("CoralInspire", new CoralInspire(pince));
NamedCommands.registerCommand("CoraletAlgue", new CoralAlgueInspire(pince));
autoChooser = AutoBuilder.buildAutoChooser();
} }
private void configureBindings() {} private void configureBindings() {
// manette1
manette1.a().whileTrue(new AlgueExpire(pince));
manette1.b().whileTrue(new CoralAlgueInspire(pince));
manette1.x().whileTrue(new CoralInspire(pince));
manette1.y().whileTrue(new CoralExpire(pince));
manette1.povUp().toggleOnTrue(new L4(elevateur, pince));
manette1.povRight().toggleOnTrue(new L2(elevateur, pince));
manette1.povLeft().toggleOnTrue(new L3(elevateur, pince));
manette1.povDown().toggleOnTrue(new Depart(elevateur, pince));
//manette2
manette2.leftBumper().toggleOnTrue(new DepartPince(pince));
manette2.a().whileTrue(new StationPince(pince,elevateur));
}
public Command getAutonomousCommand() { public Command getAutonomousCommand() {
return Commands.print("No autonomous command configured"); return Commands.print("No autonomous command configured");

View File

@ -0,0 +1,41 @@
// 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.Pince;
/* 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 AlgueExpire extends Command {
private Pince pince;
/** Creates a new CoralAlgue. */
public AlgueExpire(Pince pince) {
this.pince = pince;
addRequirements(pince);
// 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() {
pince.aspirealgue(0.5);
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
pince.aspirealgue(0);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@ -0,0 +1,49 @@
// 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.Pince;
/* 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 CoralAlgueInspire extends Command {
private Pince pince;
/** Creates a new CoralAlgue. */
public CoralAlgueInspire(Pince pince) {
this.pince = pince;
addRequirements(pince);
// 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() {
pince.aspirecoral(-.5);
if(pince.emperagealgue()>8){
pince.aspirealgue(0);
}
else{
pince.aspirealgue(0.5);
}
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
pince.aspirecoral(0);
pince.aspirealgue(0);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@ -2,18 +2,18 @@
// Open Source Software; you can modify and/or share it under the terms of // 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. // the WPILib BSD license file in the root directory of this project.
package frc.robot.commands; package frc.robot.command;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Requin; import frc.robot.subsystems.Pince;
/* 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 */ /* 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 L1 extends Command { public class CoralExpire extends Command {
private Requin requin; private Pince pince;
/** Creates a new L1. */ /** Creates a new CoralAlgue. */
public L1(Requin requin) { public CoralExpire(Pince pince) {
this.requin = requin; this.pince = pince;
addRequirements(requin); addRequirements(pince);
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
} }
@ -24,13 +24,13 @@ public class L1 extends Command {
// Called every time the scheduler runs while the command is scheduled. // Called every time the scheduler runs while the command is scheduled.
@Override @Override
public void execute() { public void execute() {
requin.balaye(-0.5); pince.aspirecoral(-.5);
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.
@Override @Override
public void end(boolean interrupted) { public void end(boolean interrupted) {
requin.balaye(.0); pince.aspirecoral(0);
} }
// Returns true when the command should end. // Returns true when the command should end.

View File

@ -2,18 +2,18 @@
// Open Source Software; you can modify and/or share it under the terms of // 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. // the WPILib BSD license file in the root directory of this project.
package frc.robot.commands; package frc.robot.command;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Requin; import frc.robot.subsystems.Pince;
/* 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 */ /* 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 BalayeuseHaut extends Command { public class CoralInspire extends Command {
private Requin requin; private Pince pince;
/** Creates a new Balayeuse. */ /** Creates a new CoralAlgue. */
public BalayeuseHaut(Requin requin) { public CoralInspire(Pince pince) {
this.requin = requin; this.pince = pince;
addRequirements(requin); addRequirements(pince);
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
} }
@ -24,18 +24,18 @@ public class BalayeuseHaut extends Command {
// Called every time the scheduler runs while the command is scheduled. // Called every time the scheduler runs while the command is scheduled.
@Override @Override
public void execute() { public void execute() {
if(requin.enHaut()==true){ if(pince.emperagecoral()>8){
requin.rotationer(0); pince.aspirecoral(0);
} }
else{ else{
requin.rotationer(0.5); pince.aspirecoral(.5);
} }
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.
@Override @Override
public void end(boolean interrupted) { public void end(boolean interrupted) {
requin.rotationer(0); pince.aspirecoral(0);
} }
// Returns true when the command should end. // Returns true when the command should end.

View File

@ -0,0 +1,60 @@
// 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.Elevateur;
import frc.robot.subsystems.Pince;
/* 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 Depart extends Command {
private Elevateur elevateur;
private Pince pince;
/** Creates a new L2. */
public Depart(Elevateur elevateur, Pince pince) {
this.pince = pince;
this.elevateur = elevateur;
addRequirements(elevateur,pince);
// 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(elevateur.limit2()==true){
elevateur.vitesse(0);
elevateur.reset();
}
else{
elevateur.vitesse(-.5);
}
if(pince.encodeurpivot()>=900 && pince.encodeurpivot()<=910){
pince.pivote(0);
}
else if(pince.encodeurpivot()>=910){
pince.pivote(-0.5);
}
else{
pince.pivote(0.5);
}
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
elevateur.vitesse(0);
pince.pivote(0);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return elevateur.limit2()==true;
}
}

View File

@ -2,18 +2,18 @@
// Open Source Software; you can modify and/or share it under the terms of // 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. // the WPILib BSD license file in the root directory of this project.
package frc.robot.commands; package frc.robot.command;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Requin; import frc.robot.subsystems.Pince;
/* 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 */ /* 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 BalayeuseBas extends Command { public class DepartPince extends Command {
private Requin requin; private Pince pince;
/** Creates a new Balayeuse. */ /** Creates a new DepartPince. */
public BalayeuseBas(Requin requin) { public DepartPince(Pince pince) {
this.requin = requin; this.pince = pince;
addRequirements(requin); addRequirements(pince);
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
} }
@ -24,25 +24,19 @@ public class BalayeuseBas extends Command {
// Called every time the scheduler runs while the command is scheduled. // Called every time the scheduler runs while the command is scheduled.
@Override @Override
public void execute() { public void execute() {
if(requin.enBas()==true){ if(pince.position()==true){
requin.rotationer(0); pince.pivote(0);
pince.reset();
} }
else{ else{
requin.rotationer(-0.5); pince.pivote(.5);
}
if(requin.stop()){
requin.balaye(0);
}
else{
requin.balaye(0.5);
} }
} }
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.
@Override @Override
public void end(boolean interrupted) { public void end(boolean interrupted) {
requin.rotationer(0); pince.pivote(0);
requin.balaye(0);
} }
// Returns true when the command should end. // Returns true when the command should end.

View File

@ -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.command;
import java.util.function.DoubleSupplier;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Elevateur;
/* 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 ElevateurManuel extends Command {
private DoubleSupplier doubleSupplier;
private Elevateur elevateur;
/** Creates a new ElevateurManuel. */
public ElevateurManuel(Elevateur elevateur,DoubleSupplier doubleSupplier) {
this.doubleSupplier = doubleSupplier;
this.elevateur = elevateur;
addRequirements(elevateur);
// 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(elevateur.limit2()==true){
elevateur.vitesse(0);
}
elevateur.vitesse(doubleSupplier.getAsDouble());
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
elevateur.vitesse(0);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@ -0,0 +1,62 @@
// 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.Elevateur;
import frc.robot.subsystems.Pince;
/* 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 L2 extends Command {
private Elevateur elevateur;
private Pince pince;
/** Creates a new L2. */
public L2(Elevateur elevateur,Pince pince) {
this.elevateur = elevateur;
this.pince = pince;
addRequirements(elevateur,pince);
// 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(elevateur.position()>=500 && elevateur.position()<=510){
elevateur.vitesse(0);
}
else if(elevateur.position()>=510){
elevateur.vitesse(-0.3);
}
else{
elevateur.vitesse(.3);
}
if(pince.encodeurpivot()>=500 && pince.encodeurpivot()<=510){
pince.pivote(0);
}
else if(pince.encodeurpivot()>=510){
pince.pivote(-0.3);
}
else{
pince.pivote(0.3);
}
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
elevateur.vitesse(0);
pince.pivote(0);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@ -0,0 +1,62 @@
// 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.Elevateur;
import frc.robot.subsystems.Pince;
/* 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 L3 extends Command {
private Elevateur elevateur;
private Pince pince;
/** Creates a new L2. */
public L3(Elevateur elevateur,Pince pince) {
this.elevateur = elevateur;
this.pince = pince;
addRequirements(elevateur,pince);
// 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(elevateur.position()>=700 && elevateur.position()<=710){
elevateur.vitesse(0);
}
else if(elevateur.position()>=510){
elevateur.vitesse(-0.5);
}
else{
elevateur.vitesse(.5);
}
if(pince.encodeurpivot()>=700 && pince.encodeurpivot()<=710){
pince.pivote(0);
}
else if(pince.encodeurpivot()>=710){
pince.pivote(-0.5);
}
else{
pince.pivote(0.5);
}
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
elevateur.vitesse(0);
pince.pivote(0);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@ -0,0 +1,62 @@
// 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.Elevateur;
import frc.robot.subsystems.Pince;
/* 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 L4 extends Command {
private Elevateur elevateur;
private Pince pince;
/** Creates a new L2. */
public L4(Elevateur elevateur,Pince pince) {
this.elevateur = elevateur;
this.pince = pince;
addRequirements(elevateur,pince);
// 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(elevateur.position()>=800 && elevateur.position()<=810){
elevateur.vitesse(0);
}
else if(elevateur.position()>=810){
elevateur.vitesse(-0.5);
}
else{
elevateur.vitesse(.5);
}
if(pince.encodeurpivot()>=800 && pince.encodeurpivot()<=810){
pince.pivote(0);
}
else if(pince.encodeurpivot()>=810){
pince.pivote(-0.5);
}
else{
pince.pivote(0.5);
}
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
elevateur.vitesse(0);
pince.pivote(0);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return elevateur.position()>=800;
}
}

View File

@ -0,0 +1,62 @@
// 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.Elevateur;
import frc.robot.subsystems.Pince;
/* 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 StationPince extends Command {
private Pince pince;
private Elevateur elevateur;
/** Creates a new L2Pince. */
public StationPince(Pince pince,Elevateur elevateur) {
this.elevateur = elevateur;
this.pince = pince;
addRequirements(pince,elevateur);
// 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(pince.encodeurpivot()>=900 && pince.encodeurpivot()<=910){
pince.pivote(0);
}
else if(pince.encodeurpivot()>=910){
pince.pivote(-0.5);
}
else{
pince.pivote(0.5);
}
if(elevateur.position()>=400 && elevateur.position()<=410){
elevateur.vitesse(0);
}
else if(elevateur.position()>=410){
elevateur.vitesse(-0.3);
}
else{
elevateur.vitesse(.3);
}
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
pince.pivote(0);
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@ -0,0 +1,32 @@
// 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 edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import com.revrobotics.spark.SparkMax;
import com.revrobotics.spark.SparkLowLevel.MotorType;
public class Elevateur extends SubsystemBase {
/** Creates a new Elevateur. */
public Elevateur() {}
final SparkMax monte = new SparkMax(0, MotorType.kBrushless);
final DigitalInput limit2 = new DigitalInput(0);
public double position(){
return monte.getEncoder().getPosition();
}
public void vitesse(double vitesse){
monte.set(vitesse);
}
public boolean limit2(){
return limit2.get();
}
public void reset(){
monte.getEncoder().setPosition(0);
}
@Override
public void periodic() {
// This method will be called once per scheduler run
}
}

View File

@ -0,0 +1,50 @@
// 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.SparkLowLevel.MotorType;
import com.revrobotics.spark.SparkMax;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class Pince extends SubsystemBase {
/** Creates a new Pince. */
public Pince() {}
final SparkMax coral = new SparkMax(0, MotorType.kBrushless);
final SparkMax pivoti = new SparkMax(0, MotorType.kBrushless);
final SparkMax algue1 = new SparkMax(0, MotorType.kBrushless);
final SparkMax algue2 = new SparkMax(0, MotorType.kBrushless);
final DigitalInput limit6 = new DigitalInput(0);
public void aspirecoral(double vitesse){
coral.set(vitesse);
}
public void pivote(double vitesse){
pivoti.set(vitesse);
}
public void aspirealgue(double vitesse){
algue2.set(vitesse);
algue1.set(-vitesse);
}
public double encodeurpivot(){
return pivoti.getEncoder().getPosition();
}
public boolean position(){
return limit6.get();
}
public void reset(){
pivoti.getEncoder().setPosition(0);
}
public double emperagecoral(){
return coral.getOutputCurrent();
}
public double emperagealgue(){
return algue1.getOutputCurrent();
}
@Override
public void periodic() {
// This method will be called once per scheduler run
}
}