mirror of
https://github.com/Team4388/2023WayOfTheRobot.git
synced 2026-06-09 08:38:02 -06:00
added more arm command stuff
This commit is contained in:
@@ -4,58 +4,43 @@
|
|||||||
|
|
||||||
package frc4388.robot.commands;
|
package frc4388.robot.commands;
|
||||||
|
|
||||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
import org.opencv.osgi.OpenCVInterface;
|
||||||
|
|
||||||
import frc4388.robot.subsystems.Arm;
|
import frc4388.robot.subsystems.Arm;
|
||||||
import frc4388.robot.subsystems.Claw;
|
import frc4388.robot.subsystems.Claw;
|
||||||
|
|
||||||
public class ArmCommand extends PelvicInflammatoryDisease {
|
public class ArmCommand extends PelvicInflammatoryDisease {
|
||||||
private Arm arm;
|
private final Arm arm;
|
||||||
private Claw claw;
|
private final Claw claw;
|
||||||
private boolean toggle;
|
private final boolean toggle;
|
||||||
|
private final double target;
|
||||||
|
|
||||||
/** Creates a new ArmCommand. */
|
/** Creates a new ArmCommand. */
|
||||||
public ArmCommand(Arm arm, Claw claw, boolean open) {
|
public ArmCommand(Arm arm, Claw claw, double target, boolean open) {
|
||||||
// Use addRequirements() here to declare subsystem dependencies.
|
super(0.6, 0, 0, 0, 0);
|
||||||
super(0.6, 0, 0, 0);
|
this.arm = arm;
|
||||||
this.arm = arm;
|
this.claw = claw;
|
||||||
this.claw = claw;
|
|
||||||
this.toggle = open;
|
this.toggle = open;
|
||||||
|
this.target = target;
|
||||||
addRequirements(arm, claw);
|
addRequirements(arm, claw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArmCommand(Arm arm, Claw claw) {
|
public ArmCommand(Arm arm, Claw claw, double target) {
|
||||||
this(arm, claw, claw.isClawOpen());
|
this(arm, claw, target, 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
|
@Override
|
||||||
public double getError() {
|
public double getError() {
|
||||||
// TODO Auto-generated method stub
|
return (arm.getArmRotation() - target) / 360;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runWithOutput(double output) {
|
public void runWithOutput(double output) {
|
||||||
// TODO Auto-generated method stub
|
arm.setRotVel(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {
|
||||||
|
claw.setClaw(toggle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class AutoBalance extends PelvicInflammatoryDisease {
|
|||||||
|
|
||||||
/** Creates a new AutoBalanceTF2. */
|
/** Creates a new AutoBalanceTF2. */
|
||||||
public AutoBalance(RobotGyro gyro, SwerveDrive drive) {
|
public AutoBalance(RobotGyro gyro, SwerveDrive drive) {
|
||||||
super(0.6, 0, 0, 0);
|
super(0.6, 0, 0, 0, 0);
|
||||||
|
|
||||||
this.gyro = gyro;
|
this.gyro = gyro;
|
||||||
this.drive = drive;
|
this.drive = drive;
|
||||||
|
|||||||
@@ -8,16 +8,19 @@ import edu.wpi.first.wpilibj2.command.CommandBase;
|
|||||||
import frc4388.utility.Gains;
|
import frc4388.utility.Gains;
|
||||||
|
|
||||||
public abstract class PelvicInflammatoryDisease extends CommandBase {
|
public abstract class PelvicInflammatoryDisease extends CommandBase {
|
||||||
protected Gains gains;
|
protected Gains gains;
|
||||||
private double output = 0;
|
private double output = 0;
|
||||||
|
private double tolerance = 0;
|
||||||
|
|
||||||
/** Creates a new PelvicInflammatoryDisease. */
|
/** Creates a new PelvicInflammatoryDisease. */
|
||||||
public PelvicInflammatoryDisease(double kp, double ki, double kd, double kf) {
|
public PelvicInflammatoryDisease(double kp, double ki, double kd, double kf, double tolerance) {
|
||||||
gains = new Gains(kp, ki, kd, kf, 0);
|
gains = new Gains(kp, ki, kd, kf, 0);
|
||||||
|
this.tolerance = tolerance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PelvicInflammatoryDisease(Gains gains) {
|
public PelvicInflammatoryDisease(Gains gains, double tolerance) {
|
||||||
this.gains = gains;
|
this.gains = gains;
|
||||||
|
this.tolerance = tolerance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** produces the error from the setpoint */
|
/** produces the error from the setpoint */
|
||||||
@@ -48,11 +51,9 @@ public abstract class PelvicInflammatoryDisease extends CommandBase {
|
|||||||
runWithOutput(output);
|
runWithOutput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
|
||||||
@Override
|
|
||||||
public void end(boolean interrupted) {}
|
|
||||||
|
|
||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() { return false; }
|
public boolean isFinished() {
|
||||||
|
return Math.abs(getError()) < tolerance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user