Changer Force 1 a 7
This commit is contained in:
parent
1efb3f77c5
commit
6d9373c990
@ -3,42 +3,52 @@
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package frc.robot.commands;
|
||||
|
||||
import frc.robot.subsystems.Accumulateur;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.Lanceur;
|
||||
|
||||
public class Force1 extends CommandBase {
|
||||
private Lanceur lanceur;
|
||||
|
||||
/** Creates a new Force1. */
|
||||
public Force1(Lancer lancer) {
|
||||
private Lanceur lanceur;
|
||||
private Accumulateur accumulateur;
|
||||
|
||||
public void Lancer(Lanceur lanceur) {
|
||||
this.lanceur = lanceur;
|
||||
addRequirements(lanceur);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
this.accumulateur = accumulateur;
|
||||
addRequirements(lanceur , accumulateur);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
lanceur.setPID(0,0,0);
|
||||
lanceur.setPID(0, 0, 0);
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
lanceur.lancer(500);
|
||||
|
||||
double vitesse = SmartDashboard.getNumber("Force Lanceur", 100);
|
||||
lanceur.lancer(200);
|
||||
if (lanceur.vitesse() > vitesse ){
|
||||
accumulateur.tourneavant();
|
||||
accumulateur.tournearriere();
|
||||
} else {
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
lanceur.lancer(0);
|
||||
}
|
||||
lanceur.stop();
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
return lanceur.distance()>1;
|
||||
}
|
||||
}
|
||||
|
@ -2,42 +2,57 @@
|
||||
// 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.
|
||||
|
||||
// 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.commands;
|
||||
|
||||
import frc.robot.subsystems.Accumulateur;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.Lanceur;
|
||||
|
||||
public class Force2 extends CommandBase {
|
||||
private Lanceur lanceur;
|
||||
|
||||
/** Creates a new Force1. */
|
||||
public Force2(Lancer lancer) {
|
||||
private Lanceur lanceur;
|
||||
private Accumulateur accumulateur;
|
||||
|
||||
public void Lancer(Lanceur lanceur) {
|
||||
this.lanceur = lanceur;
|
||||
addRequirements(lanceur);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
this.accumulateur = accumulateur;
|
||||
addRequirements(lanceur , accumulateur);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
lanceur.setPID(0,0,0);
|
||||
lanceur.setPID(0, 0, 0);
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
lanceur.lancer(500);
|
||||
double vitesse = SmartDashboard.getNumber("Force Lanceur", 200);
|
||||
lanceur.lancer(200);
|
||||
if (lanceur.vitesse() > vitesse ){
|
||||
accumulateur.tourneavant();
|
||||
accumulateur.tournearriere();
|
||||
} else {
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
lanceur.lancer(0);
|
||||
}
|
||||
lanceur.stop();
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
return lanceur.distance()>1;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,42 +2,57 @@
|
||||
// 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.
|
||||
|
||||
// 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.commands;
|
||||
|
||||
import frc.robot.subsystems.Accumulateur;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.Lanceur;
|
||||
|
||||
public class Force3 extends CommandBase {
|
||||
private Lanceur lanceur;
|
||||
|
||||
/** Creates a new Force1. */
|
||||
public Force3(Lancer lancer) {
|
||||
private Lanceur lanceur;
|
||||
private Accumulateur accumulateur;
|
||||
|
||||
public void Lancer(Lanceur lanceur) {
|
||||
this.lanceur = lanceur;
|
||||
addRequirements(lanceur);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
this.accumulateur = accumulateur;
|
||||
addRequirements(lanceur , accumulateur);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
lanceur.setPID(0,0,0);
|
||||
lanceur.setPID(0, 0, 0);
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
lanceur.lancer(500);
|
||||
double vitesse = SmartDashboard.getNumber("Force Lanceur", 300);
|
||||
lanceur.lancer(200);
|
||||
if (lanceur.vitesse() > vitesse ){
|
||||
accumulateur.tourneavant();
|
||||
accumulateur.tournearriere();
|
||||
} else {
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
lanceur.lancer(0);
|
||||
}
|
||||
lanceur.stop();
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
return lanceur.distance()>1;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,41 +3,52 @@
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package frc.robot.commands;
|
||||
|
||||
import frc.robot.subsystems.Accumulateur;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.Lanceur;
|
||||
|
||||
public class Force4 extends CommandBase {
|
||||
private Lanceur lanceur;
|
||||
|
||||
/** Creates a new Force1. */
|
||||
public Force4(Lancer lancer) {
|
||||
private Lanceur lanceur;
|
||||
private Accumulateur accumulateur;
|
||||
|
||||
public void Lancer(Lanceur lanceur) {
|
||||
this.lanceur = lanceur;
|
||||
addRequirements(lanceur);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
this.accumulateur = accumulateur;
|
||||
addRequirements(lanceur , accumulateur);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
lanceur.setPID(0,0,0);
|
||||
lanceur.setPID(0, 0, 0);
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
lanceur.lancer(500);
|
||||
double vitesse = SmartDashboard.getNumber("Force Lanceur", 400);
|
||||
lanceur.lancer(200);
|
||||
if (lanceur.vitesse() > vitesse ){
|
||||
accumulateur.tourneavant();
|
||||
accumulateur.tournearriere();
|
||||
} else {
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
lanceur.lancer(0);
|
||||
}
|
||||
lanceur.stop();
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
return lanceur.distance()>1;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,41 +3,52 @@
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package frc.robot.commands;
|
||||
|
||||
import frc.robot.subsystems.Accumulateur;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.Lanceur;
|
||||
|
||||
public class Force5 extends CommandBase {
|
||||
private Lanceur lanceur;
|
||||
|
||||
/** Creates a new Force1. */
|
||||
public Force5(Lancer lancer) {
|
||||
private Lanceur lanceur;
|
||||
private Accumulateur accumulateur;
|
||||
|
||||
public void Lancer(Lanceur lanceur) {
|
||||
this.lanceur = lanceur;
|
||||
addRequirements(lanceur);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
this.accumulateur = accumulateur;
|
||||
addRequirements(lanceur , accumulateur);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
lanceur.setPID(0,0,0);
|
||||
lanceur.setPID(0, 0, 0);
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
lanceur.lancer(500);
|
||||
double vitesse = SmartDashboard.getNumber("Force Lanceur", 500);
|
||||
lanceur.lancer(200);
|
||||
if (lanceur.vitesse() > vitesse ){
|
||||
accumulateur.tourneavant();
|
||||
accumulateur.tournearriere();
|
||||
} else {
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
lanceur.lancer(0);
|
||||
}
|
||||
lanceur.stop();
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
return lanceur.distance()>1;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,41 +3,52 @@
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package frc.robot.commands;
|
||||
|
||||
import frc.robot.subsystems.Accumulateur;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.Lanceur;
|
||||
|
||||
public class Force6 extends CommandBase {
|
||||
private Lanceur lanceur;
|
||||
|
||||
/** Creates a new Force1. */
|
||||
public Force6(Lancer lancer) {
|
||||
private Lanceur lanceur;
|
||||
private Accumulateur accumulateur;
|
||||
|
||||
public void Lancer(Lanceur lanceur) {
|
||||
this.lanceur = lanceur;
|
||||
addRequirements(lanceur);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
this.accumulateur = accumulateur;
|
||||
addRequirements(lanceur , accumulateur);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
lanceur.setPID(0,0,0);
|
||||
lanceur.setPID(0, 0, 0);
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
lanceur.lancer(500);
|
||||
double vitesse = SmartDashboard.getNumber("Force Lanceur", 600);
|
||||
lanceur.lancer(200);
|
||||
if (lanceur.vitesse() > vitesse ){
|
||||
accumulateur.tourneavant();
|
||||
accumulateur.tournearriere();
|
||||
} else {
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
lanceur.lancer(0);
|
||||
}
|
||||
lanceur.stop();
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
return lanceur.distance()>1;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,41 +3,52 @@
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package frc.robot.commands;
|
||||
|
||||
import frc.robot.subsystems.Accumulateur;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.Lanceur;
|
||||
|
||||
public class Force7 extends CommandBase {
|
||||
private Lanceur lanceur;
|
||||
|
||||
/** Creates a new Force1. */
|
||||
public Force7(Lancer lancer) {
|
||||
private Lanceur lanceur;
|
||||
private Accumulateur accumulateur;
|
||||
|
||||
public void Lancer(Lanceur lanceur) {
|
||||
this.lanceur = lanceur;
|
||||
addRequirements(lanceur);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
this.accumulateur = accumulateur;
|
||||
addRequirements(lanceur , accumulateur);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
lanceur.setPID(0,0,0);
|
||||
lanceur.setPID(0, 0, 0);
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
lanceur.lancer(500);
|
||||
double vitesse = SmartDashboard.getNumber("Force Lanceur", 700);
|
||||
lanceur.lancer(200);
|
||||
if (lanceur.vitesse() > vitesse ){
|
||||
accumulateur.tourneavant();
|
||||
accumulateur.tournearriere();
|
||||
} else {
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
lanceur.lancer(0);
|
||||
}
|
||||
lanceur.stop();
|
||||
accumulateur.stop();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
return lanceur.distance()>1;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
// 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.commands;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.Lanceur;
|
||||
|
||||
public class Lancer extends CommandBase {
|
||||
|
||||
private Lanceur lanceur;
|
||||
|
||||
/** Creates a new Lancer. */
|
||||
public Lancer(Lanceur lanceur) {
|
||||
this.lanceur = lanceur;
|
||||
addRequirements(lanceur);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
|
||||
lanceur.setPID(0, 0, 0);
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
lanceur.lancer(0);
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
lanceur.lancer(0); }
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return lanceur.distance()>1;
|
||||
}
|
||||
}
|
@ -21,9 +21,19 @@ public class Accumulateur extends SubsystemBase {
|
||||
public void Deaccumuler(){
|
||||
moteuracc.set(0.5);
|
||||
}
|
||||
|
||||
public double tourneavant(){
|
||||
moteuracc.set(0.5);
|
||||
return(moteuracc.getSelectedSensorPosition());
|
||||
}
|
||||
|
||||
public double tournearriere(){
|
||||
moteuracc.set(-0.5);
|
||||
return(moteuracc.getSelectedSensorPosition());
|
||||
}
|
||||
|
||||
public boolean limit(){
|
||||
return limitacc.get();
|
||||
public void stop(){
|
||||
moteuracc.set(0);
|
||||
}
|
||||
|
||||
public double distance() {
|
||||
|
@ -13,26 +13,24 @@ public class Lanceur extends SubsystemBase {
|
||||
|
||||
final CANSparkMax lanceur = new CANSparkMax(Constants.lanceur, MotorType.kBrushless);
|
||||
|
||||
public Lanceur() {}
|
||||
public Lanceur(){}
|
||||
|
||||
public void lancer(double vitesse){
|
||||
lanceur.set(vitesse);
|
||||
}
|
||||
public double vitesse(){
|
||||
return(lanceur.getEncoder().getVelocity());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// encodeur
|
||||
// encodeur
|
||||
public double distance() {
|
||||
return(lanceur.getEncoder().getPosition());
|
||||
|
||||
}
|
||||
public void Reset() {
|
||||
lanceur.getEncoder().setPosition(0);
|
||||
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user