summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-02-20 23:24:59 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2017-02-20 23:24:59 -0500
commit52c3d5326184336bd6e43c0b55e47d4b17142e37 (patch)
tree07a5bc5e073fe482bb94be58c12d324f17695dad
parent0e5a0cb990007976cc17e23b54c9960c38ae398d (diff)
Write Autonomous.
-rw-r--r--src/org/usfirst/frc/team4272/robot2016/Autonomous.java38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/org/usfirst/frc/team4272/robot2016/Autonomous.java b/src/org/usfirst/frc/team4272/robot2016/Autonomous.java
index 7b2194c..39b792d 100644
--- a/src/org/usfirst/frc/team4272/robot2016/Autonomous.java
+++ b/src/org/usfirst/frc/team4272/robot2016/Autonomous.java
@@ -1,26 +1,46 @@
package org.usfirst.frc.team4272.robot2016;
-import edu.wpi.first.wpilibj.Timer;
-import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
-
public class Autonomous {
- private final Timer time = new Timer();
private final HwRobot robot;
public Autonomous(HwRobot robot) {
this.robot = robot;
- time.reset();
- time.start();
+ robot.lDriveE.reset();
+ robot.rDriveE.reset();
}
public Control run(Control c) {
+ double lDist = robot.lDriveE.getDistance();
+ double rDist = robot.rDriveE.getDistance();
+
+ double speed = 0.6;
+ double thresh = 10;
+ double target = 15;
+ double max = 16;
+ if (lDist < thresh) {
+ c.lDrive = speed;
+ } else if (lDist < max) {
+ c.lDrive = speed*Math.sqrt((target-lDist)/(target-thresh));
+ } else {
+ c.lDrive = 0;
+ }
- if (time.get() < 15) {
+ if (rDist < thresh) {
+ c.rDrive = speed;
+ } else if (rDist < max) {
+ c.rDrive = speed*Math.sqrt((target-rDist)/(target-thresh));
+ } else {
+ c.rDrive = 0;
}
- else {
+
+ if (Math.abs(lDist - rDist) > 0.25) {
+ if (lDist > rDist) {
+ c.lDrive *= 0.2;
+ } else {
+ c.rDrive *= 0.2;
+ }
}
- SmartDashboard.putNumber("autoTime", time.get());
return c;
}