From 3454220c3558da46a4bac913bbe58642a52dc679 Mon Sep 17 00:00:00 2001 From: Aarav Date: Mon, 6 Mar 2023 18:36:32 -0700 Subject: [PATCH] I, Aarav Shah, endorse war crimes in various 3rd world countries --- .../java/frc4388/robot/RobotContainer.java | 14 ++++- src/main/java/frc4388/robot/RobotMap.java | 5 ++ .../frc4388/robot/commands/ArmCommand.java | 61 +++++++++++++++++++ .../java/frc4388/robot/subsystems/Claw.java | 3 +- 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 src/main/java/frc4388/robot/commands/ArmCommand.java diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index 1444e27..e8bb7de 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -8,6 +8,7 @@ package frc4388.robot; import edu.wpi.first.wpilibj.PWM; +import edu.wpi.first.wpilibj.Servo; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.InstantCommand; @@ -17,6 +18,7 @@ import frc4388.robot.Constants.*; import frc4388.robot.commands.AutoBalance; import frc4388.robot.commands.JoystickPlayback; import frc4388.robot.subsystems.Arm; +import frc4388.robot.subsystems.Claw; import frc4388.robot.subsystems.SwerveDrive; import frc4388.robot.commands.JoystickRecorder; import frc4388.robot.commands.PlaybackChooser; @@ -43,6 +45,8 @@ public class RobotContainer { public final Arm m_robotArm = new Arm(m_robotMap.pivot, m_robotMap.tele, m_robotMap.pivotEncoder); + public final Claw m_robotClaw = new Claw(m_robotMap.servo); + /* Controllers */ private final DeadbandedXboxController m_driverXbox = new DeadbandedXboxController(OIConstants.XBOX_DRIVER_ID); private final DeadbandedXboxController m_operatorXbox = new DeadbandedXboxController(OIConstants.XBOX_OPERATOR_ID); @@ -135,14 +139,22 @@ public class RobotContainer { // * Operator Buttons + // TODO: use the claw subsystem new JoystickButton(getDeadbandedOperatorController(), XboxController.X_BUTTON) .onTrue(new InstantCommand(() -> { servo.setRaw(servo_open ? 1000 : 2000); servo_open = !servo_open; })); + + new JoystickButton(getDeadbandedOperatorController(), XboxController.X_BUTTON) + .onTrue(new InstantCommand(() -> m_robotClaw.setClaw(servo_open))); + servo_open = !servo_open; new JoystickButton(getDeadbandedOperatorController(), XboxController.A_BUTTON) - .onTrue(new InstantCommand(() -> m_robotArm.resetTeleSoftLimit())); + .onTrue(new InstantCommand(() -> m_robotArm.resetTeleSoftLimit(), m_robotArm)); + + new JoystickButton(getDeadbandedOperatorController(), XboxController.LEFT_BUMPER_BUTTON) + .onTrue(new InstantCommand(() -> {}, m_robotArm, m_robotSwerveDrive /* claw */)); } /** diff --git a/src/main/java/frc4388/robot/RobotMap.java b/src/main/java/frc4388/robot/RobotMap.java index 362b401..60ce4f5 100644 --- a/src/main/java/frc4388/robot/RobotMap.java +++ b/src/main/java/frc4388/robot/RobotMap.java @@ -12,6 +12,7 @@ import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX; import com.ctre.phoenix.sensors.CANCoder; import com.ctre.phoenix.sensors.WPI_Pigeon2; +import edu.wpi.first.wpilibj.PWM; import frc4388.robot.Constants.ArmConstants; import frc4388.robot.Constants.SwerveDriveConstants; import frc4388.robot.subsystems.SwerveModule; @@ -160,4 +161,8 @@ public class RobotMap { tele.configForwardSoftLimitEnable(false); tele.configReverseSoftLimitEnable(false); } + + // claw stuff (i will punch someone) + PWM servo = new PWM(0); + } diff --git a/src/main/java/frc4388/robot/commands/ArmCommand.java b/src/main/java/frc4388/robot/commands/ArmCommand.java new file mode 100644 index 0000000..6afe6b4 --- /dev/null +++ b/src/main/java/frc4388/robot/commands/ArmCommand.java @@ -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 frc4388.robot.commands; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc4388.robot.subsystems.Arm; +import frc4388.robot.subsystems.Claw; + +public class ArmCommand extends PelvicInflammatoryDisease { + private Arm arm; + private Claw claw; + private boolean toggle; + + /** Creates a new ArmCommand. */ + public ArmCommand(Arm arm, Claw claw, boolean open) { + // Use addRequirements() here to declare subsystem dependencies. + super(0.6, 0, 0, 0); + this.arm = arm; + this.claw = claw; + this.toggle = open; + addRequirements(arm, claw); + } + + public ArmCommand(Arm arm, Claw claw) { + this(arm, claw, claw.isClawOpen()); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + super.initialize(); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() {} + + // 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; + } + + @Override + public double getError() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void runWithOutput(double output) { + // TODO Auto-generated method stub + + } +} diff --git a/src/main/java/frc4388/robot/subsystems/Claw.java b/src/main/java/frc4388/robot/subsystems/Claw.java index 37793b1..6f1199a 100644 --- a/src/main/java/frc4388/robot/subsystems/Claw.java +++ b/src/main/java/frc4388/robot/subsystems/Claw.java @@ -1,7 +1,8 @@ package frc4388.robot.subsystems; import edu.wpi.first.wpilibj.PWM; +import edu.wpi.first.wpilibj2.command.SubsystemBase; -public class Claw { +public class Claw extends SubsystemBase { private PWM m_clawMotor; private boolean m_open = false;