kjhgf
This commit is contained in:
commit
909d3f424b
@ -18,6 +18,8 @@ public class Constants {
|
||||
public static int actuateur = 2;
|
||||
public static int brakedroit = 3;
|
||||
public static int brakegauche = 4;
|
||||
public static int brakewinchf = 5;
|
||||
public static int brakewinchb = 5;
|
||||
// DIO
|
||||
public static int limitbd = 0;
|
||||
public static int limitbg = 2;
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package frc.robot;
|
||||
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.Commands;
|
||||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||
@ -23,19 +22,16 @@ import frc.robot.subsystems.Limelight;
|
||||
import frc.robot.commands.BrakeFerme;
|
||||
import frc.robot.commands.BrakeOuvre;
|
||||
import frc.robot.commands.Cone;
|
||||
import frc.robot.commands.Cube;
|
||||
import frc.robot.commands.GratteBaisser;
|
||||
import frc.robot.commands.GratteMonte;
|
||||
import frc.robot.commands.Gyro;
|
||||
import frc.robot.commands.Reculer;
|
||||
import frc.robot.commands.Tape;
|
||||
import frc.robot.commands.bras.FermePince;
|
||||
import frc.robot.commands.bras.OuvrePince;
|
||||
import frc.robot.commands.bras.PivotBrasRentre;
|
||||
import frc.robot.commands.bras.PivoteBrasBas;
|
||||
import frc.robot.commands.bras.PivoteBrasHaut;
|
||||
import frc.robot.commands.bras.PivoteBrasMilieux;
|
||||
import frc.robot.commands.Apriltag;
|
||||
|
||||
public class RobotContainer {
|
||||
CommandXboxController manette1 = new CommandXboxController(0);
|
||||
@ -60,9 +56,6 @@ PivoteBrasBas pivoteBrasBas = new PivoteBrasBas(brasTelescopique, pivot);
|
||||
PivoteBrasMilieux pivoteBrasMilieux = new PivoteBrasMilieux(brasTelescopique, pivot);
|
||||
PivoteBrasHaut pivoteBrasHaut = new PivoteBrasHaut(brasTelescopique, pivot);
|
||||
Cone cone = new Cone(limelight, basePilotable, ()->-manette1.getLeftY());
|
||||
Cube cube = new Cube(limelight, basePilotable, ()->-manette1.getLeftY());
|
||||
Apriltag aprilTag = new Apriltag(limelight, basePilotable, ()->-manette1.getLeftY());
|
||||
Tape tape = new Tape(limelight, basePilotable, ()->-manette1.getLeftY());
|
||||
public RobotContainer() {
|
||||
configureBindings();
|
||||
|
||||
@ -76,9 +69,8 @@ public RobotContainer() {
|
||||
manette1.a().toggleOnTrue(Commands.startEnd(pince::ouvrir, pince::fermer,pince));
|
||||
manette1.x().toggleOnTrue(Commands.startEnd(basePilotable::BrakeFerme,basePilotable::BrakeOuvre,basePilotable));
|
||||
manette1.y().whileTrue(gyro);
|
||||
manette1.b().toggleOnTrue(Commands.startEnd());
|
||||
manette1.b().toggleOnTrue(Commands.startEnd(gratte::baiser, gratte::Lever,gratte));
|
||||
manette1.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable));
|
||||
|
||||
}
|
||||
|
||||
public Command getAutonomousCommand() {
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
package frc.robot.commands;
|
||||
|
||||
import com.ctre.phoenix.motorcontrol.LimitSwitchNormal;
|
||||
import frc.robot.Constants;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.Gratte;
|
||||
|
||||
|
@ -29,6 +29,7 @@ public class PivotBrasRentre extends CommandBase {
|
||||
public void execute() {
|
||||
if(brasTelescopique.distance()>1){
|
||||
brasTelescopique.AvanceRecule(0.5);
|
||||
brasTelescopique.fermer();
|
||||
}
|
||||
if (pivot.distance()>1){
|
||||
pivot.monteDescendre(0.5);
|
||||
@ -36,9 +37,10 @@ public class PivotBrasRentre extends CommandBase {
|
||||
else if(brasTelescopique.photocell()){
|
||||
brasTelescopique.Reset();
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
brasTelescopique.ouvrir();
|
||||
}
|
||||
else{
|
||||
brasTelescopique.AvanceRecule(.5);
|
||||
brasTelescopique.AvanceRecule(0.5);
|
||||
}
|
||||
if(pivot.limitpivot()){
|
||||
pivot.Reset();
|
||||
|
61
src/main/java/frc/robot/commands/bras/PivotChercheBas.java
Normal file
61
src/main/java/frc/robot/commands/bras/PivotChercheBas.java
Normal file
@ -0,0 +1,61 @@
|
||||
// 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.bras;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.bras.BrasTelescopique;
|
||||
import frc.robot.subsystems.bras.Pivot;
|
||||
|
||||
public class PivotChercheBas extends CommandBase {
|
||||
private BrasTelescopique brasTelescopique;
|
||||
private Pivot pivot;
|
||||
/** Creates a new PivotChercheBas. */
|
||||
public PivotChercheBas(BrasTelescopique brasTelescopique, Pivot pivot) {
|
||||
this.brasTelescopique = brasTelescopique;
|
||||
this.pivot = pivot;
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
addRequirements(brasTelescopique);
|
||||
addRequirements(pivot);
|
||||
}
|
||||
|
||||
// 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(brasTelescopique.distance()<10){
|
||||
brasTelescopique.AvanceRecule(0.5);
|
||||
brasTelescopique.fermer();
|
||||
}
|
||||
else if(brasTelescopique.distance()>11) {
|
||||
brasTelescopique.AvanceRecule(-0.5);
|
||||
}
|
||||
else {
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
brasTelescopique.ouvrir();
|
||||
}
|
||||
if (pivot.distance()<10){
|
||||
pivot.monteDescendre(0.5);
|
||||
}
|
||||
else if(pivot.distance()>11) {
|
||||
pivot.monteDescendre(-0.5);
|
||||
}
|
||||
else{
|
||||
pivot.monteDescendre(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
}
|
61
src/main/java/frc/robot/commands/bras/PivotChercheHaut.java
Normal file
61
src/main/java/frc/robot/commands/bras/PivotChercheHaut.java
Normal file
@ -0,0 +1,61 @@
|
||||
// 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.bras;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.bras.BrasTelescopique;
|
||||
import frc.robot.subsystems.bras.Pivot;
|
||||
|
||||
public class PivotChercheHaut extends CommandBase {
|
||||
private BrasTelescopique brasTelescopique;
|
||||
private Pivot pivot;
|
||||
/** Creates a new PivotChercheHaut. */
|
||||
public PivotChercheHaut(BrasTelescopique brasTelescopique, Pivot pivot) {
|
||||
this.brasTelescopique = brasTelescopique;
|
||||
this.pivot = pivot;
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
addRequirements(brasTelescopique);
|
||||
addRequirements(pivot);
|
||||
}
|
||||
|
||||
// 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(brasTelescopique.distance()<10){
|
||||
brasTelescopique.AvanceRecule(0.5);
|
||||
brasTelescopique.fermer();
|
||||
}
|
||||
else if(brasTelescopique.distance()>11) {
|
||||
brasTelescopique.AvanceRecule(-0.5);
|
||||
}
|
||||
else {
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
brasTelescopique.ouvrir();
|
||||
}
|
||||
if (pivot.distance()<10){
|
||||
pivot.monteDescendre(0.5);
|
||||
}
|
||||
else if(pivot.distance()>11) {
|
||||
pivot.monteDescendre(-0.5);
|
||||
}
|
||||
else{
|
||||
pivot.monteDescendre(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -31,12 +31,14 @@ public class PivoteBrasBas extends CommandBase {
|
||||
public void execute() {
|
||||
if(brasTelescopique.distance()<10){
|
||||
brasTelescopique.AvanceRecule(0.5);
|
||||
brasTelescopique.fermer();
|
||||
}
|
||||
else if(brasTelescopique.distance()>11) {
|
||||
brasTelescopique.AvanceRecule(-0.5);
|
||||
}
|
||||
else {
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
brasTelescopique.ouvrir();
|
||||
}
|
||||
if (pivot.distance()<10){
|
||||
pivot.monteDescendre(0.5);
|
||||
|
@ -29,12 +29,14 @@ public class PivoteBrasHaut extends CommandBase {
|
||||
public void execute() {
|
||||
if(brasTelescopique.distance()<10){
|
||||
brasTelescopique.AvanceRecule(0.5);
|
||||
brasTelescopique.fermer();
|
||||
}
|
||||
else if(brasTelescopique.distance()>11) {
|
||||
brasTelescopique.AvanceRecule(-0.5);
|
||||
}
|
||||
else {
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
brasTelescopique.ouvrir();
|
||||
}
|
||||
if (pivot.distance()<10){
|
||||
pivot.monteDescendre(0.5);
|
||||
|
@ -29,12 +29,14 @@ public class PivoteBrasMilieux extends CommandBase {
|
||||
public void execute() {
|
||||
if(brasTelescopique.distance()<10){
|
||||
brasTelescopique.AvanceRecule(0.5);
|
||||
brasTelescopique.fermer();
|
||||
}
|
||||
else if(brasTelescopique.distance()>11) {
|
||||
brasTelescopique.AvanceRecule(-0.5);
|
||||
}
|
||||
else {
|
||||
brasTelescopique.AvanceRecule(0);
|
||||
brasTelescopique.ouvrir();
|
||||
}
|
||||
if (pivot.distance()<10){
|
||||
pivot.monteDescendre(0.5);
|
||||
|
@ -10,7 +10,7 @@ import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
||||
|
||||
import org.photonvision.PhotonCamera;
|
||||
import org.photonvision.common.hardware.VisionLEDMode;
|
||||
import org.photonvision.targeting.PhotonTrackedTarget;
|
||||
|
||||
|
||||
import edu.wpi.first.net.PortForwarder;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
|
@ -9,6 +9,12 @@ import com.revrobotics.CANSparkMax;
|
||||
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
|
||||
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import edu.wpi.first.wpilibj.DoubleSolenoid;
|
||||
import edu.wpi.first.wpilibj.PneumaticsModuleType;
|
||||
import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
|
||||
>>>>>>> 2c79346ce98c80f71d749f5cfbe0025b5dedf77a
|
||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
@ -20,6 +26,7 @@ public class BrasTelescopique extends SubsystemBase {
|
||||
public BrasTelescopique() {}
|
||||
final CANSparkMax Winch = new CANSparkMax(Constants.BrasTelescopique,MotorType.kBrushless);
|
||||
private DigitalInput photocell = new DigitalInput(Constants.photocell);
|
||||
private DoubleSolenoid brakewinch = new DoubleSolenoid(PneumaticsModuleType.CTREPCM,Constants.brakewinchf, Constants.brakewinchb);
|
||||
public void AvanceRecule(double vitesse) {
|
||||
Winch.set(vitesse);
|
||||
}
|
||||
@ -30,11 +37,22 @@ public class BrasTelescopique extends SubsystemBase {
|
||||
Winch.getEncoder().setPosition(0);
|
||||
}
|
||||
public boolean photocell(){
|
||||
return photocell.get();
|
||||
return photocell.get();
|
||||
}
|
||||
public void fermer() {
|
||||
brakewinch.set(Value.kReverse);
|
||||
}
|
||||
public void ouvrir() {
|
||||
brakewinch.set(Value.kForward);
|
||||
}
|
||||
@Override
|
||||
public void periodic() {
|
||||
<<<<<<< HEAD
|
||||
teb .add("``photocell``",0.1);
|
||||
teb .add("winch",0.1);
|
||||
=======
|
||||
Shuffleboard.getTab("SmartDashBoard") .add("photocell",0.1);
|
||||
Shuffleboard.getTab("SmartDashBoard") .add("winch",0.1);
|
||||
>>>>>>> 2c79346ce98c80f71d749f5cfbe0025b5dedf77a
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,14 @@ public class Pivot extends SubsystemBase {
|
||||
}
|
||||
@Override
|
||||
public void periodic() {
|
||||
<<<<<<< HEAD
|
||||
teb .add("encodeur", 0.1);
|
||||
}
|
||||
}
|
||||
=======
|
||||
Shuffleboard.getTab("SmartDashBoard") .add("limitpivot",0.1);
|
||||
Shuffleboard.getTab("SmartDashBoard") .add("pivot encodeur",0.1);
|
||||
}
|
||||
}
|
||||
|
||||
>>>>>>> 2c79346ce98c80f71d749f5cfbe0025b5dedf77a
|
||||
|
Loading…
x
Reference in New Issue
Block a user