f00e62e1984bb4dc49b682bc2b911c118f8c27b2
1 package org
.usfirst
.frc
.team3501
.robot
.commands
.intakearm
;
3 import org
.usfirst
.frc
.team3501
.robot
.Robot
;
5 import edu
.wpi
.first
.wpilibj
.command
.Command
;
7 public class MoveIntakeArmToAngle
extends Command
{
8 private double currentAngle
;
9 private double targetAngle
;
10 private double targetSpeed
;
11 private double calculatedSpeed
;
12 private double SENSITIVITY_THRESHOLD
= 0.1;
14 public MoveIntakeArmToAngle(double angle
, double speed
) {
15 requires(Robot
.intakeArm
);
22 protected void initialize() {
24 // set the arm speed to the calculated angle
25 Robot
.intakeArm
.setArmSpeed(getCalculatedSpeed());
30 protected void execute() {
31 // set the arm speed to the calculated angle
32 Robot
.intakeArm
.setArmSpeed(calculatedSpeed
);
35 private double getError() {
36 // targetAngle - currentAngle = error
37 return Robot
.intakeArm
.getArmAngle() - targetAngle
;
40 private double getCalculatedSpeed() {
41 // if the arm has to move up -- the speed will be +
42 // if the arm has to move down -- the speed will be -
44 return (getError() / targetAngle
) * targetSpeed
;
48 protected boolean isFinished() {
49 // if the arm's angle is close enough to the target value return true
51 return (Math
.abs(getError()) <= SENSITIVITY_THRESHOLD
);
55 protected void end() {
56 Robot
.intakeArm
.stop();
60 protected void interrupted() {