Commit | Line | Data |
---|---|---|
9b93bff0 CZ |
1 | package org.usfirst.frc.team3501.robot.commands; |
2 | ||
3 | import org.usfirst.frc.team3501.robot.Constants; | |
4 | ||
5 | import edu.wpi.first.wpilibj.command.Command; | |
6 | ||
7 | /** | |
8 | * | |
9 | */ | |
10 | public class MoveDefenseArmVertical extends Command { | |
11 | ||
12 | double horizontalLimit, height; | |
13 | ||
14 | public MoveDefenseArmVertical(double horizontalLimit, double height) { | |
15 | // requires(); | |
16 | this.horizontalLimit = horizontalLimit; | |
17 | this.height = height; | |
18 | } | |
19 | ||
20 | // Called just before this Command runs the first time | |
21 | @Override | |
22 | protected void initialize() { | |
23 | } | |
24 | ||
25 | // Called repeatedly when this Command is scheduled to run | |
26 | @Override | |
27 | protected void execute() { | |
28 | double armAngle; | |
29 | armAngle = square(horizontalLimit) + square(height) | |
30 | + square(Constants.DefenseArm.ARM_LENGTH) | |
31 | - square(Constants.DefenseArm.HAND_LENGTH); | |
32 | armAngle /= 2 * Math.sqrt(square(horizontalLimit) + square(height)) | |
33 | * Constants.DefenseArm.ARM_LENGTH; | |
34 | armAngle = Math.acos(armAngle); | |
35 | armAngle = Math.atan(height / horizontalLimit) - armAngle; | |
36 | ||
37 | double handAngle; | |
38 | handAngle = square(horizontalLimit) + square(height) | |
39 | + square(Constants.DefenseArm.HAND_LENGTH) | |
40 | - square(Constants.DefenseArm.ARM_LENGTH); | |
41 | handAngle /= 2 * Math.sqrt(square(horizontalLimit) + square(height)) | |
42 | * Constants.DefenseArm.HAND_LENGTH; | |
43 | handAngle = Math.acos(handAngle); | |
44 | handAngle = handAngle + 90 - Math.atan(horizontalLimit / height); | |
45 | } | |
46 | ||
47 | // Make this return true when this Command no longer needs to run execute() | |
48 | @Override | |
49 | protected boolean isFinished() { | |
50 | return false; | |
51 | } | |
52 | ||
53 | // Called once after isFinished returns true | |
54 | @Override | |
55 | protected void end() { | |
56 | } | |
57 | ||
58 | public double square(double num) { | |
59 | return num * num; | |
60 | } | |
61 | ||
62 | // Called when another command which requires one or more of the same | |
63 | // subsystems is scheduled to run | |
64 | @Override | |
65 | protected void interrupted() { | |
66 | } | |
67 | } |