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 {
diff --git a/frc971/input/gyro_board_data.h b/frc971/input/gyro_board_data.h
index 10135e3..3650e96 100644
--- a/frc971/input/gyro_board_data.h
+++ b/frc971/input/gyro_board_data.h
@@ -41,6 +41,7 @@
uint8_t angle_adjust_bottom_hall_effect : 1;
uint8_t top_disc : 1;
uint8_t bottom_disc : 1;
+ uint8_t loader_top : 1;
};
uint32_t digitals;
};
diff --git a/frc971/input/gyro_board_reader.cc b/frc971/input/gyro_board_reader.cc
index 06e760c..de60cb1 100644
--- a/frc971/input/gyro_board_reader.cc
+++ b/frc971/input/gyro_board_reader.cc
@@ -224,6 +224,7 @@
.bottom_disc_negedge_wait_position(index_translate(
data->capture_bottom_fall_delay))
.bottom_disc_negedge_wait_count(bottom_fall_delay_count_)
+ .loader_top(data->loader_top)
.Send();
}
diff --git a/gyro_board/src/usb/analog.c b/gyro_board/src/usb/analog.c
index 6e26e84..c9d6752 100644
--- a/gyro_board/src/usb/analog.c
+++ b/gyro_board/src/usb/analog.c
@@ -512,7 +512,6 @@
packet->capture_top_rise = capture_top_rise;
packet->top_rise_count = top_rise_count;
-
packet->capture_top_fall = capture_top_fall;
packet->top_fall_count = top_fall_count;
packet->top_disc = !digital(2);
@@ -522,6 +521,8 @@
packet->bottom_fall_count = bottom_fall_count;
packet->bottom_disc = !digital(1);
+ packet->loader_top = !digital(5);
+
packet->capture_shooter_angle_rise = capture_shooter_angle_rise;
packet->shooter_angle_rise_count = shooter_angle_rise_count;
packet->angle_adjust_bottom_hall_effect = !digital(4);
diff --git a/gyro_board/src/usb/analog.h b/gyro_board/src/usb/analog.h
index b72218b..8dc0963 100644
--- a/gyro_board/src/usb/analog.h
+++ b/gyro_board/src/usb/analog.h
@@ -38,6 +38,7 @@
uint8_t angle_adjust_bottom_hall_effect : 1;
uint8_t top_disc : 1;
uint8_t bottom_disc : 1;
+ uint8_t loader_top : 1;
};
uint32_t digitals;
};