2023-03-06 18:36:32 -07:00
|
|
|
// 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 frc4388.robot.subsystems.Arm;
|
|
|
|
|
import frc4388.robot.subsystems.Claw;
|
|
|
|
|
|
|
|
|
|
public class ArmCommand extends PelvicInflammatoryDisease {
|
2023-03-14 10:47:17 -06:00
|
|
|
private final Arm arm;
|
|
|
|
|
private final Claw claw;
|
|
|
|
|
private final boolean toggle;
|
|
|
|
|
private final double target;
|
2023-03-06 18:36:32 -07:00
|
|
|
|
|
|
|
|
/** Creates a new ArmCommand. */
|
2023-03-14 10:47:17 -06:00
|
|
|
public ArmCommand(Arm arm, Claw claw, double target, boolean open) {
|
|
|
|
|
super(0.6, 0, 0, 0, 0);
|
|
|
|
|
this.arm = arm;
|
|
|
|
|
this.claw = claw;
|
2023-03-06 18:36:32 -07:00
|
|
|
this.toggle = open;
|
2023-03-14 10:47:17 -06:00
|
|
|
this.target = target;
|
2023-03-06 18:36:32 -07:00
|
|
|
addRequirements(arm, claw);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-14 10:47:17 -06:00
|
|
|
public ArmCommand(Arm arm, Claw claw, double target) {
|
|
|
|
|
this(arm, claw, target, claw.isClawOpen());
|
2023-03-06 18:36:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2023-03-14 10:47:17 -06:00
|
|
|
public double getError() {
|
|
|
|
|
return (arm.getArmRotation() - target) / 360;
|
2023-03-06 18:36:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2023-03-14 10:47:17 -06:00
|
|
|
public void runWithOutput(double output) {
|
|
|
|
|
arm.setRotVel(output);
|
2023-03-06 18:36:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2023-03-14 10:47:17 -06:00
|
|
|
public void end(boolean interrupted) {
|
|
|
|
|
claw.setClaw(toggle);
|
2023-03-06 18:36:32 -07:00
|
|
|
}
|
|
|
|
|
}
|