Fixed y2017 tests.
The 5 ms timestep -> 5.05 ms timestep change didn't propegate fully
and the tests caught a bug. I need to go re-test this on a robot
before submitting.
The gear ratio also changed so disabled zeroing was moving too much.
Change-Id: I8add457559cc3b46a6664d4339717bfcb0271787
diff --git a/aos/common/controls/control_loop_test.h b/aos/common/controls/control_loop_test.h
index 88ccfa5..6fae706 100644
--- a/aos/common/controls/control_loop_test.h
+++ b/aos/common/controls/control_loop_test.h
@@ -25,7 +25,9 @@
// Sends out all of the required queue messages.
void SendMessages(bool enabled);
// Ticks time for a single control loop cycle.
- void TickTime() { ::aos::time::SetMockTime(current_time_ += kTimeTick); }
+ void TickTime(::std::chrono::nanoseconds dt = kTimeTick) {
+ ::aos::time::SetMockTime(current_time_ += dt);
+ }
// Simulates everything that happens during 1 loop time step.
void SimulateTimestep(bool enabled) {
diff --git a/y2017/control_loops/superstructure/shooter/shooter.cc b/y2017/control_loops/superstructure/shooter/shooter.cc
index 795a7d4..03abd99 100644
--- a/y2017/control_loops/superstructure/shooter/shooter.cc
+++ b/y2017/control_loops/superstructure/shooter/shooter.cc
@@ -67,10 +67,7 @@
// Compute the distance moved over that time period.
average_angular_velocity_ =
(history_[oldest_history_position] - history_[history_position_]) /
- (chrono::duration_cast<chrono::duration<double>>(
- ::aos::controls::kLoopFrequency)
- .count() *
- static_cast<double>(kHistoryLength - 1));
+ (0.00505 * static_cast<double>(kHistoryLength - 1));
// Ready if average angular velocity is close to the goal.
error_ = average_angular_velocity_ - loop_->next_R(2, 0);
diff --git a/y2017/control_loops/superstructure/superstructure_lib_test.cc b/y2017/control_loops/superstructure/superstructure_lib_test.cc
index 7906af4..513e2f2 100644
--- a/y2017/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2017/control_loops/superstructure/superstructure_lib_test.cc
@@ -492,7 +492,7 @@
superstructure_.Iterate();
superstructure_plant_.Simulate();
- TickTime();
+ TickTime(::std::chrono::microseconds(5050));
}
// Runs iterations until the specified amount of simulated time has elapsed.
@@ -948,7 +948,7 @@
superstructure_plant_.set_hood_voltage_offset(2.0);
- superstructure_plant_.set_turret_voltage_offset(-1.5);
+ superstructure_plant_.set_turret_voltage_offset(-1.0);
superstructure_plant_.set_indexer_voltage_offset(2.0);
RunForTime(chrono::seconds(1), false);
@@ -1082,12 +1082,13 @@
}
}
- // Make sure it took some time, but not too much to detect us not being stuck anymore.
+ // Make sure it took some time, but not too much to detect us not being stuck
+ // anymore.
const auto unstuck_detection_time = monotonic_clock::now();
EXPECT_TRUE(unstuck_detection_time - unstuck_start_time <
- chrono::milliseconds(200));
+ chrono::milliseconds(600));
EXPECT_TRUE(unstuck_detection_time - unstuck_start_time >
- chrono::milliseconds(40));
+ chrono::milliseconds(100));
// Verify that it actually moved.
superstructure_queue_.position.FetchLatest();
@@ -1155,7 +1156,7 @@
// anymore.
const auto unstuck_detection_time = monotonic_clock::now();
EXPECT_TRUE(unstuck_detection_time - unstuck_start_time <
- chrono::milliseconds(600));
+ chrono::milliseconds(1050));
EXPECT_TRUE(unstuck_detection_time - unstuck_start_time >
chrono::milliseconds(400));
LOG(INFO, "Unstuck time is %ldms",