more changes from Davis
diff --git a/frc971/control_loops/angle_adjust/angle_adjust_lib_test.cc b/frc971/control_loops/angle_adjust/angle_adjust_lib_test.cc
index 620d784..51cd641 100644
--- a/frc971/control_loops/angle_adjust/angle_adjust_lib_test.cc
+++ b/frc971/control_loops/angle_adjust/angle_adjust_lib_test.cc
@@ -224,23 +224,23 @@
VerifyNearGoal();
}
-// Tests that loosing the encoder for a second triggers a re-zero.
+// Tests that losing the encoder for 11 seconds triggers a re-zero.
TEST_F(AngleAdjustTest, RezeroWithMissingPos) {
my_angle_adjust_loop_.goal.MakeWithBuilder().goal(0.4).Send();
- for (int i = 0; i < 800; ++i) {
+ for (int i = 0; i < 1800; ++i) {
// After 3 seconds, simulate the encoder going missing.
// This should trigger a re-zero. To make sure it works, change the goal as
// well.
- if (i < 300 || i > 400) {
+ if (i < 300 || i > 1400) {
angle_adjust_motor_plant_.SendPositionMessage();
} else {
- if (i > 310) {
+ if (i > 1310) {
// Should be re-zeroing now.
EXPECT_TRUE(angle_adjust_motor_.is_uninitialized());
}
my_angle_adjust_loop_.goal.MakeWithBuilder().goal(0.5).Send();
}
- if (i == 430) {
+ if (i == 1430) {
EXPECT_TRUE(angle_adjust_motor_.is_zeroing() ||
angle_adjust_motor_.is_moving_off());
}
diff --git a/frc971/control_loops/zeroed_joint.h b/frc971/control_loops/zeroed_joint.h
index a756d35..468dc13 100644
--- a/frc971/control_loops/zeroed_joint.h
+++ b/frc971/control_loops/zeroed_joint.h
@@ -276,19 +276,21 @@
if (position == NULL) {
LOG(WARNING, "no new pos given\n");
error_count_++;
- } else {
- error_count_ = 0;
}
if (error_count_ >= 4) {
output_enabled = false;
LOG(WARNING, "err_count is %d so disabling\n", error_count_);
- } else if ((::aos::time::Time::Now() - last_good_time_) > kRezeroTime) {
- LOG(WARNING, "err_count is %d so forcing a re-zero (or 1st time)\n",
- error_count_);
- state_ = UNINITIALIZED;
+
+ if ((::aos::time::Time::Now() - last_good_time_) > kRezeroTime) {
+ LOG(WARNING, "err_count is %d (or 1st time) so forcing a re-zero\n",
+ error_count_);
+ state_ = UNINITIALIZED;
+ loop_->Reset();
+ }
}
- if (position) {
+ if (position != NULL) {
last_good_time_ = ::aos::time::Time::Now();
+ error_count_ = 0;
}
// Compute the absolute position of the wrist.