message: integration_tests: make hover test more robust
diff: @@ -43,7 +43,7 @@ void takeoff_and_hover_at_altitude(float altitude_m)
  LogInfo() << "Waiting for system to be ready";
  ASSERT_TRUE(poll_condition_with_timeout(
  - [&telemetry]() { return telemetry->health_all_ok(); }, std::chrono::seconds(10)));
  + [telemetry]() { return telemetry->health_all_ok(); }, std::chrono::seconds(10)));
  auto action = std::make_shared<Action>(system);
  Action::Result action_ret = action->arm();
  @@ -57,12 +57,16 @@ void takeoff_and_hover_at_altitude(float altitude_m)
  action_ret = action->takeoff();
  EXPECT_EQ(action_ret, Action::Result::Success);
  - // TODO: The wait time should not be hard-coded because the
  - // simulation might run faster.
  + EXPECT_TRUE(poll_condition_with_timeout(
  + [telemetry]() { return telemetry->flight_mode() == Telemetry::FlightMode::Takeoff; },
  + std::chrono::seconds(10)));
  +
  + EXPECT_TRUE(poll_condition_with_timeout(
  + [telemetry]() { return telemetry->flight_mode() == Telemetry::FlightMode::Hold; },
  + std::chrono::seconds(10)));
  - // We wait 2s / m plus a margin of 5s.
  - const int wait_time_s = static_cast<int>(altitude_m * 2.0f + 5.0f);
  - std::this_thread::sleep_for(std::chrono::seconds(wait_time_s));
  + // We need to wait a bit until it stabilizes.
  + std::this_thread::sleep_for(std::chrono::seconds(2));
  EXPECT_GT(telemetry->position().relative_altitude_m, altitude_m - 0.25f);
  EXPECT_LT(telemetry->position().relative_altitude_m, altitude_m + 0.25f);
  @@ -71,7 +75,7 @@ void takeoff_and_hover_at_altitude(float altitude_m)
  EXPECT_EQ(action_ret, Action::Result::Success);
  EXPECT_TRUE(poll_condition_with_timeout(
  - [&telemetry]() { return !telemetry->in_air(); }, std::chrono::seconds(wait_time_s)));
  + [telemetry]() { return !telemetry->in_air(); }, std::chrono::seconds(10)));
  action_ret = action->disarm();
  EXPECT_EQ(action_ret, Action::Result::Success);
  