Permalink
Browse files

merged branch feature-conveyor-pause into develop (forgot to pull before

branching ~Zane)
  • Loading branch information...
2 parents 0af78f0 + 665c1e8 commit acf2ee3f2953ccd20b577636cd3e16fcbaf92de3 @zqiu zqiu committed with No Movy Apr 16, 2012
Showing with 23 additions and 17 deletions.
  1. +15 −1 src/edu/stuy/JoeBot.java
  2. +4 −16 src/edu/stuy/commands/ConveyAutomatic.java
  3. +4 −0 src/edu/stuy/subsystems/Conveyor.java
View
16 src/edu/stuy/JoeBot.java
@@ -6,11 +6,14 @@
/*----------------------------------------------------------------------------*/
package edu.stuy;
+
+import edu.wpi.first.wpilibj.Timer;
import edu.stuy.commands.Autonomous;
import edu.stuy.commands.CommandBase;
import edu.stuy.commands.MoveCamera;
import edu.stuy.commands.TusksRetract;
import edu.stuy.subsystems.Flywheel;
+import edu.stuy.subsystems.Conveyor;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.camera.AxisCamera;
@@ -28,6 +31,9 @@
public class JoeBot extends IterativeRobot {
Command autonomousCommand;
+
+ public static final double BALL_STATIONARY_TIME = 0.5;
+
// Thread ariel;
/**
@@ -94,6 +100,14 @@ public void teleopPeriodic() {
CommandBase.oi.updateLights();
updateSmartDashboard();
+
+
+ Conveyor conv = CommandBase.conveyor;
+ // Has the ball settled at the top?
+ conv.curBallAtTop = CommandBase.conveyor.ballAtTop();
+ if (conv.curBallAtTop && conv.startBallDelayTime < 0) conv.startBallDelayTime = Timer.getFPGATimestamp();
+ conv.ballWaitTime = (conv.startBallDelayTime > 0) ? Timer.getFPGATimestamp() - conv.startBallDelayTime : -1;
+ conv.ballSettled = conv.startBallDelayTime < 0 || conv.ballWaitTime > BALL_STATIONARY_TIME;
}
// We use SmartDashboard to monitor bot information.
@@ -130,4 +144,4 @@ private void updateSmartDashboard() {
SmartDashboard.putDouble("Left joystick", -CommandBase.oi.getLeftStick().getY());
SmartDashboard.putDouble("Right joystick", -CommandBase.oi.getRightStick().getY());
}
-}
+}
View
20 src/edu/stuy/commands/ConveyAutomatic.java
@@ -4,8 +4,6 @@
*/
package edu.stuy.commands;
-import edu.wpi.first.wpilibj.Timer;
-
/**
*
* @author Kevin Wang
@@ -17,15 +15,11 @@
* Prevents ball from being shot with extra energy due to the conveyor.
* Longer / shorter conveyor runs can kill our consistency.
*/
- public static final double BALL_STATIONARY_TIME = 0.5;
-
boolean hasTimeout = false;
double timeout;
- double startBallDelayTime = -1;
-
public ConveyAutomatic() {
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
@@ -45,23 +39,17 @@ protected void initialize() {
// Called repeatedly when this Command is scheduled to run
protected void execute() {
- // Has the ball settled at the top?
- boolean curBallAtTop = conveyor.ballAtTop();
- if (curBallAtTop && startBallDelayTime < 0) startBallDelayTime = Timer.getFPGATimestamp();
- double ballWaitTime = (startBallDelayTime > 0) ? Timer.getFPGATimestamp() - startBallDelayTime : -1;
- boolean ballSettled = startBallDelayTime < 0 || ballWaitTime > BALL_STATIONARY_TIME;
-
-
+
if (flywheel.isSpeedGood() && flywheel.isSpinning() && // flywheel's at correct speed
flywheel.isSpeedSettled() && // flywheel's been stable at correct speed for long enough
- ballSettled) { // conveyor's not accelerating ball
+ conveyor.ballSettled) { // conveyor's not accelerating ball
conveyor.convey();
// Restart ball delay, only after ball exits the top sensor zone
// Without this check, this algorithm would continuously halt the
// ball as it passes through the sensor's line of sight
- if (!curBallAtTop) {
- startBallDelayTime = -1;
+ if (!conveyor.curBallAtTop) {
+ conveyor.startBallDelayTime = -1;
}
}
else {
View
4 src/edu/stuy/subsystems/Conveyor.java
@@ -22,6 +22,10 @@
public static final double FORWARD = 1;
public static final double BACKWARD = -1;
+ public static double ballWaitTime;
+ public static boolean ballSettled;
+ public static boolean curBallAtTop;
+ public double startBallDelayTime = -1;
// Put methods for controlling this subsystem
// here. Call these from Commands.

0 comments on commit acf2ee3

Please sign in to comment.