Skip to content

Commit ae23134

Browse files
author
James Hagborg
committed
Merge branch 'vision-redesign' of github.com:teamhyper/hyperLib into vision-redesign
2 parents 7a99857 + c3e9ef2 commit ae23134

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

src/main/java/org/usfirst/frc/team69/util/CommandBuilder.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,16 @@ public CommandBuilder sequential(Command command) {
6565
* @param command
6666
* The command to add in sequence
6767
* @param timeout
68-
* The timeout, in seconds
68+
* The timeout, in seconds. if negative, no timeout is used.
6969
* @return This CommandBuilder object
7070
*/
7171
public CommandBuilder sequential(Command command, double timeout) {
72-
m_cmdGroup.addSequential(command, timeout);
72+
if(timeout >= 0.0) {
73+
m_cmdGroup.addSequential(command, timeout);
74+
} else {
75+
m_cmdGroup.addSequential(command);
76+
}
77+
7378
return this;
7479
}
7580

@@ -100,11 +105,15 @@ public CommandBuilder parallel(Command command) {
100105
* @param command
101106
* The command to add in parallel
102107
* @param timeout
103-
* The timeout, in seconds
108+
* The timeout, in seconds. if negative, no timeout is used.
104109
* @return This CommandBuilder object
105110
*/
106111
public CommandBuilder parallel(Command command, double timeout) {
107-
m_cmdGroup.addParallel(command, timeout);
112+
if(timeout >= 0.0) {
113+
m_cmdGroup.addParallel(command, timeout);
114+
} else {
115+
m_cmdGroup.addParallel(command);
116+
}
108117
return this;
109118
}
110119

src/main/java/org/usfirst/frc/team69/util/pid/PrefPIDController.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public class PrefPIDController extends PIDController {
3333
private double m_defP, m_defI, m_defD, m_defF;
3434
private double m_defTolerance = -1; // -1 indicates no tolerance
3535
private double m_defMinOutput = -1, m_defMaxOutput = 1;
36+
37+
private PIDSource m_source;
3638

3739
private final String m_prefString;
3840

@@ -132,6 +134,7 @@ public PrefPIDController(String prefString, double Kp, double Ki, double Kd,
132134
m_defD = Kd;
133135
m_defF = Kf;
134136
m_prefString = prefString;
137+
m_source = source;
135138

136139
createKeysIfEmpty();
137140
updatePreferences();
@@ -231,6 +234,44 @@ public void setOutputRange(double min, double max) {
231234

232235
updatePreferences();
233236
}
237+
/**
238+
* Gets the tolerance of the PID
239+
*
240+
* @return the tolerance of this PID
241+
*/
242+
public double getTolerance() {
243+
return m_defTolerance;
244+
}
245+
246+
/**
247+
* Is the system above the given target
248+
*
249+
* @param target
250+
* setpoint to check if the PID system is above
251+
*
252+
* @param reverse
253+
* is the system reversed
254+
*
255+
* @return is the system above the given target
256+
*/
257+
public boolean isAbove(double target, boolean reverse) {
258+
return (reverse ? m_source.pidGet() <= target+m_defTolerance : m_source.pidGet() >= target-m_defTolerance);
259+
}
260+
/**
261+
* Is the system below the given target
262+
*
263+
* @param target
264+
* setpoint to check if the PID system is below
265+
*
266+
* @param reverse
267+
* is the system reversed
268+
*
269+
* @return is the system below the given target
270+
*/
271+
public boolean isBelow(double target, boolean reverse) {
272+
return (reverse ? m_source.pidGet() >= target-m_defTolerance : m_source.pidGet() <= target+m_defTolerance);
273+
}
274+
234275

235276
private void updatePreferences() {
236277
Preferences pref = Preferences.getInstance();

src/main/java/org/usfirst/frc/team69/util/port/Port.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
*/
2525
public enum Type {
26-
PWM, DIO, ANALOG, RELAY, PCM, CAN
26+
PWM, DIO, ANALOG, RELAY, PCM, CAN, USB
2727
}
2828

2929
/**

0 commit comments

Comments
 (0)