added hall effect sensor at the top of the loader
diff --git a/frc971/control_loops/index/index.cc b/frc971/control_loops/index/index.cc
index f8dbada..1d2c706 100644
--- a/frc971/control_loops/index/index.cc
+++ b/frc971/control_loops/index/index.cc
@@ -106,8 +106,8 @@
const /*static*/ double IndexMotor::kTransferRollerRadius = 1.25 * 0.0254 / 2;
/*static*/ const int IndexMotor::kGrabbingDelay = 5;
-/*static*/ const int IndexMotor::kLiftingDelay = 30;
-/*static*/ const int IndexMotor::kShootingDelay = 5;
+/*static*/ const int IndexMotor::kLiftingDelay = 2;
+/*static*/ const int IndexMotor::kShootingDelay = 10;
/*static*/ const int IndexMotor::kLoweringDelay = 20;
// TODO(aschuh): Tune these.
@@ -894,12 +894,17 @@
loader_up_ = true;
disc_clamped_ = true;
disc_ejected_ = false;
- if (loader_countdown_ > 0) {
- --loader_countdown_;
- break;
+ if (position->loader_top) {
+ if (loader_countdown_ > 0) {
+ --loader_countdown_;
+ } else {
+ loader_state_ = LoaderState::LIFTED;
+ }
} else {
- loader_state_ = LoaderState::LIFTED;
+ // Restart the countdown if it bounces back down or whatever.
+ loader_countdown_ = kLiftingDelay;
}
+ break;
case LoaderState::LIFTED:
LOG(DEBUG, "Loader LIFTED\n");
// Disc lifted. Time to eject it out.
diff --git a/frc971/control_loops/index/index.h b/frc971/control_loops/index/index.h
index a18d4c9..94db771 100644
--- a/frc971/control_loops/index/index.h
+++ b/frc971/control_loops/index/index.h
@@ -136,7 +136,8 @@
// Time that it takes to grab the disc in cycles.
static const int kGrabbingDelay;
- // Time that it takes to lift the loader in cycles.
+ // Time that it takes to finish lifting the loader after the sensor is
+ // triggered in cycles.
static const int kLiftingDelay;
// Time that it takes to shoot the disc in cycles.
static const int kShootingDelay;
diff --git a/frc971/control_loops/index/index_motor.q b/frc971/control_loops/index/index_motor.q
index c14d459..3956b18 100644
--- a/frc971/control_loops/index/index_motor.q
+++ b/frc971/control_loops/index/index_motor.q
@@ -44,6 +44,9 @@
// and a count of how many edges have been seen.
int32_t top_disc_negedge_count;
double top_disc_negedge_position;
+
+ // Whether the hall effect for the loader being at the top is triggered.
+ bool loader_top;
};
message Output {