Merge branch 'main' of https://demerso.net/pls5618/2023/robot
This commit is contained in:
commit
7ef7548415
@ -11,4 +11,3 @@ build-job: # This job runs in the build stage, which runs first.
|
||||
script:
|
||||
- chmod +x gradlew
|
||||
- ./gradlew build
|
||||
|
||||
|
Binary file not shown.
@ -4,7 +4,9 @@
|
||||
|
||||
package frc.robot;
|
||||
|
||||
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.CommandScheduler;
|
||||
|
||||
@ -35,7 +37,6 @@ public class Robot extends TimedRobot {
|
||||
@Override
|
||||
public void autonomousInit() {
|
||||
m_autonomousCommand = m_robotContainer.getAutonomousCommand();
|
||||
|
||||
if (m_autonomousCommand != null) {
|
||||
m_autonomousCommand.schedule();
|
||||
}
|
||||
|
@ -4,18 +4,19 @@
|
||||
|
||||
package frc.robot;
|
||||
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.XboxController;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.Commands;
|
||||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
||||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||
|
||||
//subsystems
|
||||
import frc.robot.subsystems.BasePilotable;
|
||||
import frc.robot.subsystems.Gratte;
|
||||
import frc.robot.subsystems.bras.BrasTelescopique;
|
||||
import frc.robot.subsystems.bras.Pince;
|
||||
import frc.robot.subsystems.bras.Pivot;
|
||||
import pabeles.concurrency.ConcurrencyOps.Reset;
|
||||
import frc.robot.subsystems.Limelight;
|
||||
// command
|
||||
import frc.robot.commands.BrakeFerme;
|
||||
@ -24,6 +25,7 @@ import frc.robot.commands.Cone;
|
||||
import frc.robot.commands.GratteBaisser;
|
||||
import frc.robot.commands.GratteMonte;
|
||||
import frc.robot.commands.Gyro;
|
||||
import frc.robot.commands.Reculer;
|
||||
import frc.robot.commands.bras.FermePince;
|
||||
import frc.robot.commands.bras.OuvrePince;
|
||||
import frc.robot.commands.bras.PivotBrasRentre;
|
||||
@ -32,8 +34,8 @@ import frc.robot.commands.bras.PivoteBrasHaut;
|
||||
import frc.robot.commands.bras.PivoteBrasMilieux;
|
||||
|
||||
public class RobotContainer {
|
||||
XboxController manette1 = new XboxController(0);
|
||||
XboxController manette2 = new XboxController(1);
|
||||
CommandXboxController manette1 = new CommandXboxController(0);
|
||||
CommandXboxController manette2 = new CommandXboxController(1);
|
||||
// subsystems
|
||||
BasePilotable basePilotable = new BasePilotable();
|
||||
Gratte gratte = new Gratte();
|
||||
@ -57,18 +59,28 @@ Cone cone = new Cone(limelight, basePilotable, ()->-manette1.getLeftY());
|
||||
public RobotContainer() {
|
||||
configureBindings();
|
||||
|
||||
basePilotable.setDefaultCommand(brakeOuvre);
|
||||
basePilotable.drive(-manette1.getLeftY(), manette1.getLeftX(), -manette1.getLeftTriggerAxis()+manette1.getRightTriggerAxis(), basePilotable);
|
||||
basePilotable.setDefaultCommand(new RunCommand(() -> {
|
||||
basePilotable.drive(-manette1.getLeftY(), manette1.getLeftX());
|
||||
},basePilotable));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void configureBindings() {
|
||||
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(gratte::baiser, gratte::Lever,gratte));
|
||||
manette1.start().toggleOnTrue(Commands.startEnd(basePilotable::resetGyro, basePilotable::resetGyro, basePilotable));
|
||||
|
||||
|
||||
JoystickButton buttonA = new JoystickButton(manette1, XboxController.Button.kA.value);
|
||||
buttonA.whenPressed()
|
||||
}
|
||||
|
||||
public Command getAutonomousCommand() {
|
||||
return Commands.print("No autonomous command configured");
|
||||
return new SequentialCommandGroup(
|
||||
new PivoteBrasMilieux(brasTelescopique, pivot),
|
||||
new OuvrePince(pince),
|
||||
new PivotBrasRentre(brasTelescopique, pivot).alongWith(new Reculer(basePilotable)),
|
||||
new Gyro(basePilotable)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -25,15 +25,15 @@ public class Gyro extends CommandBase {
|
||||
public void execute() {
|
||||
if(basePilotable.getpitch()<10)
|
||||
{
|
||||
basePilotable.drive(0.4, 0, 0);
|
||||
basePilotable.drive(0.4, 0);
|
||||
}
|
||||
else if(basePilotable.getpitch()>-10)
|
||||
{
|
||||
basePilotable.drive(-0.4, 0, 0);
|
||||
basePilotable.drive(-0.4, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
basePilotable.drive(0, 0, 0);
|
||||
basePilotable.drive(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
42
src/main/java/frc/robot/commands/Reculer.java
Normal file
42
src/main/java/frc/robot/commands/Reculer.java
Normal file
@ -0,0 +1,42 @@
|
||||
// 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.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc.robot.subsystems.BasePilotable;
|
||||
|
||||
public class Reculer extends CommandBase {
|
||||
BasePilotable basePilotable;
|
||||
/** Creates a new Reculer. */
|
||||
public Reculer(BasePilotable basePilotable) {
|
||||
this.basePilotable = basePilotable;
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
addRequirements(basePilotable);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {
|
||||
basePilotable.Reset();
|
||||
}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
basePilotable.drive(SmartDashboard.getNumber("vitesse auto", -0.3), 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;
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import com.kauailabs.navx.frc.AHRS;
|
||||
import com.revrobotics.CANSparkMax;
|
||||
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
|
||||
import edu.wpi.first.wpilibj.DoubleSolenoid;
|
||||
import edu.wpi.first.wpilibj.DriverStation;
|
||||
import edu.wpi.first.wpilibj.PneumaticsModuleType;
|
||||
import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
|
||||
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||
@ -55,6 +56,10 @@ public void BrakeFerme(){
|
||||
brakedroit.set(Value.kReverse);
|
||||
brakegauche.set(Value.kReverse);
|
||||
}
|
||||
public void resetGyro(){
|
||||
try {gyroscope.reset();} catch(Exception e){DriverStation.reportError("bye bye",true);
|
||||
}
|
||||
}
|
||||
/** Creates a new BasePilotable. */
|
||||
public BasePilotable() {
|
||||
droit.setInverted(true);
|
||||
|
@ -7,6 +7,7 @@ package frc.robot.subsystems;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||
import frc.robot.Constants;
|
||||
|
||||
public class Gratte extends SubsystemBase {
|
||||
@ -42,6 +43,9 @@ public class Gratte extends SubsystemBase {
|
||||
}
|
||||
@Override
|
||||
public void periodic() {
|
||||
// This method will be called once per scheduler run
|
||||
Shuffleboard.getTab("SmartDashBoard") .add("limithd",0.1);
|
||||
Shuffleboard.getTab("SmartDashBoard") .add("limitbd",0.1);
|
||||
Shuffleboard.getTab("SmartDashBoard") .add("limithg",0.1);
|
||||
Shuffleboard.getTab("SmartDashBoard") .add("limitbg",0.1);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
package frc.robot.subsystems;
|
||||
|
||||
import edu.wpi.first.cameraserver.CameraServer;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||
import org.photonvision.PhotonCamera;
|
||||
import org.photonvision.common.hardware.VisionLEDMode;
|
||||
import org.photonvision.targeting.PhotonTrackedTarget;
|
||||
@ -53,6 +55,7 @@ public class Limelight extends SubsystemBase {
|
||||
}
|
||||
@Override
|
||||
public void periodic() {
|
||||
// This method will be called once per scheduler run
|
||||
CameraServer.startAutomaticCapture();
|
||||
Shuffleboard.getTab("SmartDashBoard") .add("limelight",0.1);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.revrobotics.CANSparkMax;
|
||||
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
|
||||
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import frc.robot.Constants;
|
||||
|
||||
@ -31,6 +32,6 @@ public class BrasTelescopique extends SubsystemBase {
|
||||
}
|
||||
@Override
|
||||
public void periodic() {
|
||||
// This method will be called once per scheduler run
|
||||
Shuffleboard.getTab("SmartDashBoard") .add("photocell",0.1);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
package frc.robot.subsystems.bras;
|
||||
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import frc.robot.Constants;
|
||||
|
||||
@ -33,6 +34,6 @@ public class Pivot extends SubsystemBase {
|
||||
}
|
||||
@Override
|
||||
public void periodic() {
|
||||
// This method will be called once per scheduler run
|
||||
Shuffleboard.getTab("SmartDashBoard") .add("limitpivot",0.1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user