summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-01-16 12:51:47 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-01-16 12:51:47 -0500
commit75c2407dd85a69b8f80e9b376da1bfb9ed0bb173 (patch)
tree09ef3a14f252bc2fd4cb9e8deb45da677383aff8
parent636cf0465605d9dd482e1fb75f8b81e509703403 (diff)
(mostly) update to new WPIlib.
PIDController has some TODOs in there
-rw-r--r--src/org/mckenzierobotics/lib/robot/FeedForward.java2
-rw-r--r--src/org/mckenzierobotics/lib/robot/PIDController.java14
-rw-r--r--src/org/mckenzierobotics/lib/robot/RollingAvg.java19
-rw-r--r--src/org/usfirst/frc/team4272/robot2016/HwRobot.java8
4 files changed, 34 insertions, 9 deletions
diff --git a/src/org/mckenzierobotics/lib/robot/FeedForward.java b/src/org/mckenzierobotics/lib/robot/FeedForward.java
index a275366..a18dccc 100644
--- a/src/org/mckenzierobotics/lib/robot/FeedForward.java
+++ b/src/org/mckenzierobotics/lib/robot/FeedForward.java
@@ -64,7 +64,7 @@ public abstract class FeedForward implements PIDOutput {
}
public void update(double pidResult) {
- if (pid.isEnable()) {
+ if (pid.isEnabled()) {
double ffResult = calculate(pid.getSetpoint());
pidOutput.pidWrite(ffResult+pidResult);
} else {
diff --git a/src/org/mckenzierobotics/lib/robot/PIDController.java b/src/org/mckenzierobotics/lib/robot/PIDController.java
index dc2301a..e2f8087 100644
--- a/src/org/mckenzierobotics/lib/robot/PIDController.java
+++ b/src/org/mckenzierobotics/lib/robot/PIDController.java
@@ -60,14 +60,14 @@ public class PIDController extends edu.wpi.first.wpilibj.PIDController implement
public PIDController(double Kp, double Ki, double Kd, PIDSource source, PIDOutput output, boolean autodisable) {
super(Kp, Ki, Kd, source, output);
this.autodisable = autodisable;
- enabled = this.isEnable();
+ enabled = this.isEnabled();
this.source = source;
this.output = output;
}
public PIDController(double Kp, double Ki, double Kd, PIDSource source, PIDOutput output, double period, boolean autodisable) {
super(Kp, Ki, Kd, source, output, period);
this.autodisable = autodisable;
- enabled = this.isEnable();
+ enabled = this.isEnabled();
this.source = source;
this.output = output;
}
@@ -101,4 +101,14 @@ public class PIDController extends edu.wpi.first.wpilibj.PIDController implement
public void set(double output, byte syncGroup) {
setSetpoint(output);
}
+
+ public void setInverted(boolean isInverted) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean getInverted() {
+ // TODO Auto-generated method stub
+ return false;
+ }
}
diff --git a/src/org/mckenzierobotics/lib/robot/RollingAvg.java b/src/org/mckenzierobotics/lib/robot/RollingAvg.java
index fcbf8e4..d73f64e 100644
--- a/src/org/mckenzierobotics/lib/robot/RollingAvg.java
+++ b/src/org/mckenzierobotics/lib/robot/RollingAvg.java
@@ -30,6 +30,7 @@
package org.mckenzierobotics.lib.robot;
import edu.wpi.first.wpilibj.PIDSource;
+import edu.wpi.first.wpilibj.PIDSourceType;
import edu.wpi.first.wpilibj.PIDOutput;
/**
@@ -65,11 +66,25 @@ public class RollingAvg implements PIDSource, PIDOutput {
}
public double pidGet() {
- if (source!=null) return push(source.pidGet());
- return get();
+ if (source!=null)
+ return push(source.pidGet());
+ else
+ return get();
}
public void pidWrite(double output) {
push(output);
}
+
+ public void setPIDSourceType(PIDSourceType srcType) {
+ if (source!=null)
+ source.setPIDSourceType(srcType);
+ }
+
+ public PIDSourceType getPIDSourceType() {
+ if (source!=null)
+ return source.getPIDSourceType();
+ else
+ return null;
+ }
}
diff --git a/src/org/usfirst/frc/team4272/robot2016/HwRobot.java b/src/org/usfirst/frc/team4272/robot2016/HwRobot.java
index a1072dc..27e64d8 100644
--- a/src/org/usfirst/frc/team4272/robot2016/HwRobot.java
+++ b/src/org/usfirst/frc/team4272/robot2016/HwRobot.java
@@ -7,7 +7,7 @@ import org.usfirst.frc.team4272.robotlib.LimitSwitchedPIDOutput;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.PIDOutput;
-import edu.wpi.first.wpilibj.PIDSource.PIDSourceParameter;
+import edu.wpi.first.wpilibj.PIDSourceType;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Talon;
@@ -48,9 +48,9 @@ public class HwRobot {
private Relay rIntake = new Relay(/*Relay*/0, Relay.Direction.kBoth);
public HwRobot() {
- lDriveE.setPIDSourceParameter(PIDSourceParameter.kRate);
- rDriveE.setPIDSourceParameter(PIDSourceParameter.kRate);
- winchE.setPIDSourceParameter(PIDSourceParameter.kRate);
+ lDriveE.setPIDSourceType(PIDSourceType.kRate);
+ rDriveE.setPIDSourceType(PIDSourceType.kRate);
+ winchE.setPIDSourceType(PIDSourceType.kRate);
}
public void run(Control c) {