-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKicking.java
132 lines (112 loc) · 4.1 KB
/
Kicking.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package demoman;
import edu.wpi.first.wpilibj.*;
/*
* Team 3181 Robotics
* Project: Breakaway
* Codename: Demoman
* (The Chargin Scottsman)
* Filename: Kicking.java
*/
/**
* All the kicking functions are housed here.
*
* @author eric
*
*/
public class Kicking {
// IMPORTANT!!! The kickerLatchSwitch is WIRED BACKWARDS!!!!
//
public static Timer latchTimer = new Timer();
public static Timer kickTimer = new Timer();
public static boolean canKick = true;
/**
* Kick the ball. ONLY CALL THIS FUNCTION IF YOU ACTUALLY WANT TO KICK GODDAMMIT.
* Uses a thread to retract. If the thread isn't working check out Kicking.java.bak
* to view the previous solution without messing with the SVN.
*
*/
public static void kickBall()
{
// Make sure the reset sequence has finished
if (!canKick)
{
return;
}
// Should already be off, but make sure we aren't trying to retract
Hardware.solenoids[0].set(false);
// Release the hounds....
Hardware.solenoids[4].set(true);
// And start the cycle
canKick = false;
kickTimer.start();
}
public static void pressureMaintenance()
{
//--- post kick maintenance ---
// 1.5 seconds after fire:
if (kickTimer.get() > 0.5)
{
// Open the gates! Let the kicker in!
Hardware.solenoids[4].set(true);
//for slow kicker option not mechanically implimented
if (Hardware.DS.getDigitalInput(8)) {
Hardware.solenoids[2].set(true);
}
}
// 1.7 seconds after fire:
if (kickTimer.get() > 0.85)
{
// Start retracting
Hardware.solenoids[0].set(true);
//kickTimer.stop();
//kickTimer.reset();
//for slow kicker option not mechanically implimented
if (Hardware.DS.getDigitalInput(8)) {
Hardware.solenoids[2].set(false);
}
}
//--- limit switch stuff ---
if (1 == 2)
{
// Kicker is out, DI = 1
}
else
{
// Kicker is in, DI = 0
// Since the limit switch isn't working properly, wait
// until you can be pretty damn sure the kicker is in
// before you do stuff.
if (kickTimer.get() > 2.35 && kickTimer.get() < 3.0)
{
// It's been one second since the kicker returned
// Keep the pressure on, but drop the latch
Hardware.solenoids[0].set(true);
Hardware.solenoids[4].set(false);
} else if (kickTimer.get() >= 3.0) {
// It's been 1.5 seconds since the kicker returned
// Turn the pressure off
Hardware.solenoids[0].set(false);
Hardware.solenoids[4].set(false);
// Reset the timer, we've done all we need
kickTimer.stop();
kickTimer.reset();
// And the cycle is complete
canKick = true;
} else {
//for slow kicker option not mechanically implimented
if (Hardware.DS.getDigitalInput(8)) {
Hardware.solenoids[2].set(true);
}
// Kicker is in, but one second hasn't passed yet
latchTimer.start();
}
}
}
public static void pressureInit()
{
kickTimer.stop();
kickTimer.reset();
latchTimer.stop();
latchTimer.reset();
}
}