blob: 3be86dafe272ecdbb86df8d1a54e9ee34d91269d [file] [log] [blame]
James Kuszmaul5398fae2020-02-17 16:44:03 -08001#include <queue>
2
3#include "gtest/gtest.h"
4
5#include "aos/controls/control_loop_test.h"
6#include "aos/events/logging/logger.h"
7#include "aos/network/team_number.h"
8#include "frc971/control_loops/drivetrain/drivetrain.h"
9#include "frc971/control_loops/drivetrain/drivetrain_test_lib.h"
10#include "frc971/control_loops/team_number_test_environment.h"
11#include "y2020/control_loops/drivetrain/drivetrain_base.h"
12#include "y2020/control_loops/drivetrain/localizer.h"
James Kuszmaul688a2b02020-02-19 18:26:33 -080013#include "y2020/control_loops/superstructure/superstructure_status_generated.h"
James Kuszmaul5398fae2020-02-17 16:44:03 -080014
15DEFINE_string(output_file, "",
16 "If set, logs all channels to the provided logfile.");
17
18// This file tests that the full 2020 localizer behaves sanely.
19
20namespace y2020 {
21namespace control_loops {
22namespace drivetrain {
23namespace testing {
24
25using frc971::control_loops::drivetrain::DrivetrainConfig;
26using frc971::control_loops::drivetrain::Goal;
27using frc971::control_loops::drivetrain::LocalizerControl;
28using frc971::vision::sift::ImageMatchResult;
29using frc971::vision::sift::ImageMatchResultT;
30using frc971::vision::sift::CameraPoseT;
31using frc971::vision::sift::CameraCalibrationT;
32using frc971::vision::sift::TransformationMatrixT;
33
34namespace {
35DrivetrainConfig<double> GetTest2020DrivetrainConfig() {
36 DrivetrainConfig<double> config = GetDrivetrainConfig();
37 return config;
38}
39
40// Copies an Eigen matrix into a row-major vector of the data.
41std::vector<float> MatrixToVector(const Eigen::Matrix<double, 4, 4> &H) {
42 std::vector<float> data;
43 for (int row = 0; row < 4; ++row) {
44 for (int col = 0; col < 4; ++col) {
45 data.push_back(H(row, col));
46 }
47 }
48 return data;
49}
50
51// Provides the location of the turret to use for simulation. Mostly we care
52// about providing a location that is not perfectly aligned with the robot's
53// origin.
54Eigen::Matrix<double, 4, 4> TurretRobotTransformation() {
55 Eigen::Matrix<double, 4, 4> H;
56 H.setIdentity();
James Kuszmaul688a2b02020-02-19 18:26:33 -080057 H.block<3, 1>(0, 3) << 1, 1.1, 0.9;
James Kuszmaul5398fae2020-02-17 16:44:03 -080058 return H;
59}
60
61// Provides the location of the camera on the turret.
62// TODO(james): Also simulate a fixed camera that is *not* on the turret.
63Eigen::Matrix<double, 4, 4> CameraTurretTransformation() {
64 Eigen::Matrix<double, 4, 4> H;
65 H.setIdentity();
66 H.block<3, 1>(0, 3) << 0.1, 0, 0;
67 // Introduce a bit of pitch to make sure that we're exercising all the code.
68 H.block<3, 3>(0, 0) =
James Kuszmaul688a2b02020-02-19 18:26:33 -080069 Eigen::AngleAxis<double>(0.1, Eigen::Vector3d::UnitY()) *
James Kuszmaul5398fae2020-02-17 16:44:03 -080070 H.block<3, 3>(0, 0);
71 return H;
72}
73
74// The absolute target location to use. Not meant to correspond with a
75// particular field target.
76// TODO(james): Make more targets.
James Kuszmaul688a2b02020-02-19 18:26:33 -080077std::vector<Eigen::Matrix<double, 4, 4>> TargetLocations() {
78 std::vector<Eigen::Matrix<double, 4, 4>> locations;
James Kuszmaul5398fae2020-02-17 16:44:03 -080079 Eigen::Matrix<double, 4, 4> H;
80 H.setIdentity();
81 H.block<3, 1>(0, 3) << 10.0, 0, 0;
James Kuszmaul688a2b02020-02-19 18:26:33 -080082 locations.push_back(H);
83 H.block<3, 1>(0, 3) << -10.0, 0, 0;
84 locations.push_back(H);
85 return locations;
James Kuszmaul5398fae2020-02-17 16:44:03 -080086}
87} // namespace
88
89namespace chrono = std::chrono;
90using frc971::control_loops::drivetrain::testing::DrivetrainSimulation;
91using frc971::control_loops::drivetrain::DrivetrainLoop;
92using frc971::control_loops::drivetrain::testing::GetTestDrivetrainConfig;
93using aos::monotonic_clock;
94
James Kuszmaul688a2b02020-02-19 18:26:33 -080095class LocalizedDrivetrainTest : public aos::testing::ControlLoopTest {
James Kuszmaul5398fae2020-02-17 16:44:03 -080096 protected:
97 // We must use the 2020 drivetrain config so that we don't have to deal
98 // with shifting:
99 LocalizedDrivetrainTest()
100 : aos::testing::ControlLoopTest(
101 aos::configuration::ReadConfig(
102 "y2020/control_loops/drivetrain/simulation_config.json"),
103 GetTest2020DrivetrainConfig().dt),
104 test_event_loop_(MakeEventLoop("test")),
105 drivetrain_goal_sender_(
106 test_event_loop_->MakeSender<Goal>("/drivetrain")),
107 drivetrain_goal_fetcher_(
108 test_event_loop_->MakeFetcher<Goal>("/drivetrain")),
109 localizer_control_sender_(
110 test_event_loop_->MakeSender<LocalizerControl>("/drivetrain")),
James Kuszmaul688a2b02020-02-19 18:26:33 -0800111 superstructure_status_sender_(
112 test_event_loop_->MakeSender<superstructure::Status>(
113 "/superstructure")),
James Kuszmaul5398fae2020-02-17 16:44:03 -0800114 drivetrain_event_loop_(MakeEventLoop("drivetrain")),
115 dt_config_(GetTest2020DrivetrainConfig()),
116 camera_sender_(
117 test_event_loop_->MakeSender<ImageMatchResult>("/camera")),
118 localizer_(drivetrain_event_loop_.get(), dt_config_),
119 drivetrain_(dt_config_, drivetrain_event_loop_.get(), &localizer_),
120 drivetrain_plant_event_loop_(MakeEventLoop("plant")),
121 drivetrain_plant_(drivetrain_plant_event_loop_.get(), dt_config_),
122 last_frame_(monotonic_now()) {
123 set_team_id(frc971::control_loops::testing::kTeamNumber);
124 SetStartingPosition({3.0, 2.0, 0.0});
125 set_battery_voltage(12.0);
126
127 if (!FLAGS_output_file.empty()) {
128 log_buffer_writer_ = std::make_unique<aos::logger::DetachedBufferWriter>(
129 FLAGS_output_file);
130 logger_event_loop_ = MakeEventLoop("logger");
131 logger_ = std::make_unique<aos::logger::Logger>(log_buffer_writer_.get(),
132 logger_event_loop_.get());
133 }
134
135 test_event_loop_->MakeWatcher(
136 "/drivetrain",
137 [this](const frc971::control_loops::drivetrain::Status &) {
138 // Needs to do camera updates right after we run the control loop.
139 if (enable_cameras_) {
140 SendDelayedFrames();
141 if (last_frame_ + std::chrono::milliseconds(100) <
142 monotonic_now()) {
143 CaptureFrames();
144 last_frame_ = monotonic_now();
145 }
146 }
James Kuszmaul688a2b02020-02-19 18:26:33 -0800147 });
148
149 test_event_loop_->AddPhasedLoop(
150 [this](int) {
151 // Also use the opportunity to send out turret messages.
152 UpdateTurretPosition();
153 auto builder = superstructure_status_sender_.MakeBuilder();
154 auto turret_builder =
155 builder
156 .MakeBuilder<frc971::control_loops::
157 PotAndAbsoluteEncoderProfiledJointStatus>();
158 turret_builder.add_position(turret_position_);
159 turret_builder.add_velocity(turret_velocity_);
160 auto turret_offset = turret_builder.Finish();
161 auto status_builder = builder.MakeBuilder<superstructure::Status>();
162 status_builder.add_turret(turret_offset);
163 builder.Send(status_builder.Finish());
164 },
165 chrono::milliseconds(5));
James Kuszmaul5398fae2020-02-17 16:44:03 -0800166
167 // Run for enough time to allow the gyro/imu zeroing code to run.
168 RunFor(std::chrono::seconds(10));
169 }
170
171 virtual ~LocalizedDrivetrainTest() override {}
172
173 void SetStartingPosition(const Eigen::Matrix<double, 3, 1> &xytheta) {
174 *drivetrain_plant_.mutable_state() << xytheta.x(), xytheta.y(),
175 xytheta(2, 0), 0.0, 0.0;
176 Eigen::Matrix<double, Localizer::HybridEkf::kNStates, 1> localizer_state;
177 localizer_state.setZero();
178 localizer_state.block<3, 1>(0, 0) = xytheta;
179 localizer_.Reset(monotonic_now(), localizer_state);
180 }
181
182 void VerifyNearGoal(double eps = 1e-3) {
183 drivetrain_goal_fetcher_.Fetch();
184 EXPECT_NEAR(drivetrain_goal_fetcher_->left_goal(),
185 drivetrain_plant_.GetLeftPosition(), eps);
186 EXPECT_NEAR(drivetrain_goal_fetcher_->right_goal(),
187 drivetrain_plant_.GetRightPosition(), eps);
188 }
189
James Kuszmaul688a2b02020-02-19 18:26:33 -0800190 ::testing::AssertionResult IsNear(double expected, double actual,
191 double epsilon) {
192 if (std::abs(expected - actual) < epsilon) {
193 return ::testing::AssertionSuccess();
194 } else {
195 return ::testing::AssertionFailure()
196 << "Expected " << expected << " but got " << actual
197 << " with a max difference of " << epsilon
198 << " and an actual difference of " << std::abs(expected - actual);
199 }
200 }
201 ::testing::AssertionResult VerifyEstimatorAccurate(double eps) {
James Kuszmaul5398fae2020-02-17 16:44:03 -0800202 const Eigen::Matrix<double, 5, 1> true_state = drivetrain_plant_.state();
James Kuszmaul688a2b02020-02-19 18:26:33 -0800203 ::testing::AssertionResult result(true);
204 if (!(result = IsNear(localizer_.x(), true_state(0), eps))) {
205 return result;
206 }
207 if (!(result = IsNear(localizer_.y(), true_state(1), eps))) {
208 return result;
209 }
210 if (!(result = IsNear(localizer_.theta(), true_state(2), eps))) {
211 return result;
212 }
213 if (!(result = IsNear(localizer_.left_velocity(), true_state(3), eps))) {
214 return result;
215 }
216 if (!(result = IsNear(localizer_.right_velocity(), true_state(4), eps))) {
217 return result;
218 }
219 return result;
James Kuszmaul5398fae2020-02-17 16:44:03 -0800220 }
221
222 // Goes through and captures frames on the camera(s), queueing them up to be
223 // sent by SendDelayedFrames().
224 void CaptureFrames() {
225 const frc971::control_loops::Pose robot_pose(
226 {drivetrain_plant_.GetPosition().x(),
227 drivetrain_plant_.GetPosition().y(), 0.0},
228 drivetrain_plant_.state()(2, 0));
229 std::unique_ptr<ImageMatchResultT> frame(new ImageMatchResultT());
230
James Kuszmaul688a2b02020-02-19 18:26:33 -0800231 for (const auto &H_target_field : TargetLocations()) {
James Kuszmaul5398fae2020-02-17 16:44:03 -0800232 std::unique_ptr<CameraPoseT> camera_target(new CameraPoseT());
233
234 camera_target->field_to_target.reset(new TransformationMatrixT());
James Kuszmaul688a2b02020-02-19 18:26:33 -0800235 camera_target->field_to_target->data = MatrixToVector(H_target_field);
236
237 Eigen::Matrix<double, 4, 4> H_camera_turret =
238 Eigen::Matrix<double, 4, 4>::Identity();
239 if (is_turreted_) {
240 H_camera_turret = frc971::control_loops::TransformationMatrixForYaw(
241 turret_position_) *
242 CameraTurretTransformation();
243 }
James Kuszmaul5398fae2020-02-17 16:44:03 -0800244
245 // TODO(james): Use non-zero turret angles.
246 camera_target->camera_to_target.reset(new TransformationMatrixT());
247 camera_target->camera_to_target->data = MatrixToVector(
248 (robot_pose.AsTransformationMatrix() * TurretRobotTransformation() *
James Kuszmaul688a2b02020-02-19 18:26:33 -0800249 H_camera_turret).inverse() *
250 H_target_field);
James Kuszmaul5398fae2020-02-17 16:44:03 -0800251
252 frame->camera_poses.emplace_back(std::move(camera_target));
253 }
254
255 frame->image_monotonic_timestamp_ns =
256 chrono::duration_cast<chrono::nanoseconds>(
257 monotonic_now().time_since_epoch())
258 .count();
259 frame->camera_calibration.reset(new CameraCalibrationT());
260 {
261 frame->camera_calibration->fixed_extrinsics.reset(
262 new TransformationMatrixT());
263 TransformationMatrixT *H_turret_robot =
264 frame->camera_calibration->fixed_extrinsics.get();
265 H_turret_robot->data = MatrixToVector(TurretRobotTransformation());
266 }
James Kuszmaul688a2b02020-02-19 18:26:33 -0800267
268 if (is_turreted_) {
James Kuszmaul5398fae2020-02-17 16:44:03 -0800269 frame->camera_calibration->turret_extrinsics.reset(
270 new TransformationMatrixT());
271 TransformationMatrixT *H_camera_turret =
272 frame->camera_calibration->turret_extrinsics.get();
273 H_camera_turret->data = MatrixToVector(CameraTurretTransformation());
274 }
275
276 camera_delay_queue_.emplace(monotonic_now(), std::move(frame));
277 }
278
279 // Actually sends out all the camera frames.
280 void SendDelayedFrames() {
281 const std::chrono::milliseconds camera_latency(150);
282 while (!camera_delay_queue_.empty() &&
283 std::get<0>(camera_delay_queue_.front()) <
284 monotonic_now() - camera_latency) {
285 auto builder = camera_sender_.MakeBuilder();
286 ASSERT_TRUE(builder.Send(ImageMatchResult::Pack(
287 *builder.fbb(), std::get<1>(camera_delay_queue_.front()).get())));
288 camera_delay_queue_.pop();
289 }
290 }
291
292 std::unique_ptr<aos::EventLoop> test_event_loop_;
293 aos::Sender<Goal> drivetrain_goal_sender_;
294 aos::Fetcher<Goal> drivetrain_goal_fetcher_;
295 aos::Sender<LocalizerControl> localizer_control_sender_;
James Kuszmaul688a2b02020-02-19 18:26:33 -0800296 aos::Sender<superstructure::Status> superstructure_status_sender_;
James Kuszmaul5398fae2020-02-17 16:44:03 -0800297
298 std::unique_ptr<aos::EventLoop> drivetrain_event_loop_;
299 const frc971::control_loops::drivetrain::DrivetrainConfig<double>
300 dt_config_;
301
302 aos::Sender<ImageMatchResult> camera_sender_;
303
304 Localizer localizer_;
305 DrivetrainLoop drivetrain_;
306
307 std::unique_ptr<aos::EventLoop> drivetrain_plant_event_loop_;
308 DrivetrainSimulation drivetrain_plant_;
309 monotonic_clock::time_point last_frame_;
310
311 // A queue of camera frames so that we can add a time delay to the data
312 // coming from the cameras.
313 std::queue<std::tuple<aos::monotonic_clock::time_point,
314 std::unique_ptr<ImageMatchResultT>>>
315 camera_delay_queue_;
316
317 void set_enable_cameras(bool enable) { enable_cameras_ = enable; }
James Kuszmaul688a2b02020-02-19 18:26:33 -0800318 void set_camera_is_turreted(bool turreted) { is_turreted_ = turreted; }
319
320 void set_turret(double position, double velocity) {
321 turret_position_ = position;
322 turret_velocity_ = velocity;
323 }
324
325 void SendGoal(double left, double right) {
326 auto builder = drivetrain_goal_sender_.MakeBuilder();
327
328 Goal::Builder drivetrain_builder = builder.MakeBuilder<Goal>();
329 drivetrain_builder.add_controller_type(
330 frc971::control_loops::drivetrain::ControllerType::MOTION_PROFILE);
331 drivetrain_builder.add_left_goal(left);
332 drivetrain_builder.add_right_goal(right);
333
334 EXPECT_TRUE(builder.Send(drivetrain_builder.Finish()));
335 }
James Kuszmaul5398fae2020-02-17 16:44:03 -0800336
337 private:
James Kuszmaul688a2b02020-02-19 18:26:33 -0800338 void UpdateTurretPosition() {
339 turret_position_ +=
340 turret_velocity_ *
341 aos::time::DurationInSeconds(monotonic_now() - last_turret_update_);
342 last_turret_update_ = monotonic_now();
343 }
344
James Kuszmaul5398fae2020-02-17 16:44:03 -0800345 bool enable_cameras_ = false;
James Kuszmaul688a2b02020-02-19 18:26:33 -0800346 // Whether to make the camera be on the turret or not.
347 bool is_turreted_ = true;
348
349 // The time at which we last incremented turret_position_.
350 monotonic_clock::time_point last_turret_update_ = monotonic_clock::min_time;
351 // Current turret position and velocity. These are set directly by the user in
352 // the test, and if velocity is non-zero, then we will automatically increment
353 // turret_position_ with every timestep.
354 double turret_position_ = 0.0; // rad
355 double turret_velocity_ = 0.0; // rad / sec
James Kuszmaul5398fae2020-02-17 16:44:03 -0800356
357 std::unique_ptr<aos::EventLoop> logger_event_loop_;
358 std::unique_ptr<aos::logger::DetachedBufferWriter> log_buffer_writer_;
359 std::unique_ptr<aos::logger::Logger> logger_;
360};
361
362// Tests that no camera updates, combined with a perfect model, results in no
363// error.
364TEST_F(LocalizedDrivetrainTest, NoCameraUpdate) {
365 SetEnabled(true);
366 set_enable_cameras(false);
James Kuszmaul688a2b02020-02-19 18:26:33 -0800367 EXPECT_TRUE(VerifyEstimatorAccurate(1e-7));
James Kuszmaul5398fae2020-02-17 16:44:03 -0800368
James Kuszmaul688a2b02020-02-19 18:26:33 -0800369 SendGoal(-1.0, 1.0);
James Kuszmaul5398fae2020-02-17 16:44:03 -0800370
James Kuszmaul5398fae2020-02-17 16:44:03 -0800371 RunFor(chrono::seconds(3));
372 VerifyNearGoal();
James Kuszmaul688a2b02020-02-19 18:26:33 -0800373 EXPECT_TRUE(VerifyEstimatorAccurate(5e-4));
James Kuszmaul5398fae2020-02-17 16:44:03 -0800374}
375
James Kuszmaul688a2b02020-02-19 18:26:33 -0800376// Tests that camera updates with a perfect models results in no errors.
James Kuszmaul5398fae2020-02-17 16:44:03 -0800377TEST_F(LocalizedDrivetrainTest, PerfectCameraUpdate) {
378 SetEnabled(true);
379 set_enable_cameras(true);
James Kuszmaul688a2b02020-02-19 18:26:33 -0800380 set_camera_is_turreted(true);
James Kuszmaul5398fae2020-02-17 16:44:03 -0800381
James Kuszmaul688a2b02020-02-19 18:26:33 -0800382 SendGoal(-1.0, 1.0);
James Kuszmaul5398fae2020-02-17 16:44:03 -0800383
James Kuszmaul5398fae2020-02-17 16:44:03 -0800384 RunFor(chrono::seconds(3));
385 VerifyNearGoal();
James Kuszmaul688a2b02020-02-19 18:26:33 -0800386 EXPECT_TRUE(VerifyEstimatorAccurate(5e-4));
James Kuszmaul5398fae2020-02-17 16:44:03 -0800387}
388
James Kuszmaul688a2b02020-02-19 18:26:33 -0800389// Tests that camera updates with a constant initial error in the position
James Kuszmaul5398fae2020-02-17 16:44:03 -0800390// results in convergence.
391TEST_F(LocalizedDrivetrainTest, InitialPositionError) {
392 SetEnabled(true);
393 set_enable_cameras(true);
James Kuszmaul688a2b02020-02-19 18:26:33 -0800394 set_camera_is_turreted(true);
James Kuszmaul5398fae2020-02-17 16:44:03 -0800395 drivetrain_plant_.mutable_state()->topRows(3) +=
396 Eigen::Vector3d(0.1, 0.1, 0.01);
James Kuszmaul5398fae2020-02-17 16:44:03 -0800397
James Kuszmaul688a2b02020-02-19 18:26:33 -0800398 // Confirm that some translational movement does get handled correctly.
399 SendGoal(-0.9, 1.0);
James Kuszmaul5398fae2020-02-17 16:44:03 -0800400
James Kuszmaul5398fae2020-02-17 16:44:03 -0800401 // Give the filters enough time to converge.
402 RunFor(chrono::seconds(10));
403 VerifyNearGoal(5e-3);
James Kuszmaul688a2b02020-02-19 18:26:33 -0800404 EXPECT_TRUE(VerifyEstimatorAccurate(1e-2));
405}
406
407// Tests that camera updates using a non-turreted camera work.
408TEST_F(LocalizedDrivetrainTest, InitialPositionErrorNoTurret) {
409 SetEnabled(true);
410 set_enable_cameras(true);
411 set_camera_is_turreted(false);
412 drivetrain_plant_.mutable_state()->topRows(3) +=
413 Eigen::Vector3d(0.1, 0.1, 0.01);
414
415 SendGoal(-1.0, 1.0);
416
417 // Give the filters enough time to converge.
418 RunFor(chrono::seconds(10));
419 VerifyNearGoal(5e-3);
420 EXPECT_TRUE(VerifyEstimatorAccurate(1e-2));
421}
422
423// Tests that we are able to handle a constant, non-zero turret angle.
424TEST_F(LocalizedDrivetrainTest, NonZeroTurret) {
425 SetEnabled(true);
426 set_enable_cameras(true);
427 set_camera_is_turreted(true);
428 set_turret(1.0, 0.0);
429 drivetrain_plant_.mutable_state()->topRows(3) +=
430 Eigen::Vector3d(0.1, 0.1, 0.0);
431
432 SendGoal(-1.0, 1.0);
433
434 // Give the filters enough time to converge.
435 RunFor(chrono::seconds(10));
436 VerifyNearGoal(5e-3);
437 EXPECT_TRUE(VerifyEstimatorAccurate(1e-3));
438}
439
440// Tests that we are able to handle a constant velocity turret.
441TEST_F(LocalizedDrivetrainTest, MovingTurret) {
442 SetEnabled(true);
443 set_enable_cameras(true);
444 set_camera_is_turreted(true);
445 set_turret(0.0, 0.2);
446 drivetrain_plant_.mutable_state()->topRows(3) +=
447 Eigen::Vector3d(0.1, 0.1, 0.0);
448
449 SendGoal(-1.0, 1.0);
450
451 // Give the filters enough time to converge.
452 RunFor(chrono::seconds(10));
453 VerifyNearGoal(5e-3);
454 EXPECT_TRUE(VerifyEstimatorAccurate(1e-3));
455}
456
457// Tests that we reject camera measurements when the turret is spinning too
458// fast.
459TEST_F(LocalizedDrivetrainTest, TooFastTurret) {
460 SetEnabled(true);
461 set_enable_cameras(true);
462 set_camera_is_turreted(true);
463 set_turret(0.0, -10.0);
464 const Eigen::Vector3d disturbance(0.1, 0.1, 0.0);
465 drivetrain_plant_.mutable_state()->topRows(3) += disturbance;
466
467 SendGoal(-1.0, 1.0);
468
469 RunFor(chrono::seconds(10));
470 EXPECT_FALSE(VerifyEstimatorAccurate(1e-3));
471 // If we remove the disturbance, we should now be correct.
472 drivetrain_plant_.mutable_state()->topRows(3) -= disturbance;
473 VerifyNearGoal(5e-3);
474 EXPECT_TRUE(VerifyEstimatorAccurate(1e-3));
475}
476
477// Tests that we don't reject camera measurements when the turret is spinning
478// too fast but we aren't using a camera attached to the turret.
479TEST_F(LocalizedDrivetrainTest, TooFastTurretDoesntAffectFixedCamera) {
480 SetEnabled(true);
481 set_enable_cameras(true);
482 set_camera_is_turreted(false);
483 set_turret(0.0, -10.0);
484 const Eigen::Vector3d disturbance(0.1, 0.1, 0.0);
485 drivetrain_plant_.mutable_state()->topRows(3) += disturbance;
486
487 SendGoal(-1.0, 1.0);
488
489 RunFor(chrono::seconds(10));
490 VerifyNearGoal(5e-3);
491 EXPECT_TRUE(VerifyEstimatorAccurate(1e-3));
James Kuszmaul5398fae2020-02-17 16:44:03 -0800492}
493
494} // namespace testing
495} // namespace drivetrain
496} // namespace control_loops
497} // namespace y2020