mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 08:31:36 +08:00
mavsdk tests: use tester sleep_for function
the previously used std::this_thread::sleep_for is with respect to host system time which is different from autopilot time if: - speed factor != 1 - something runs slower than realtime regardless of speed factor - debugging or otherwise interrupting PX4 control code tester.sleep_for (which already existed) correctly sleeps w.r.t. px4/simulation time.
This commit is contained in:
@@ -164,24 +164,6 @@ public:
|
||||
CHECK(_param->set_param_int(param, value) == Param::Result::Success);
|
||||
}
|
||||
|
||||
protected:
|
||||
mavsdk::Param *getParams() const { return _param.get();}
|
||||
mavsdk::Telemetry *getTelemetry() const { return _telemetry.get();}
|
||||
mavsdk::ManualControl *getManualControl() const { return _manual_control.get();}
|
||||
MavlinkPassthrough *getMavlinkPassthrough() const { return _mavlink_passthrough.get();}
|
||||
std::shared_ptr<System> get_system() { return _mavsdk.systems().at(0);}
|
||||
mavsdk::geometry::CoordinateTransformation get_coordinate_transformation();
|
||||
bool ground_truth_horizontal_position_close_to(const Telemetry::GroundTruth &target_pos, float acceptance_radius_m);
|
||||
|
||||
const Telemetry::GroundTruth &getHome()
|
||||
{
|
||||
// Check if home was stored before it is accessed
|
||||
CHECK(_home.absolute_altitude_m != NAN);
|
||||
CHECK(_home.latitude_deg != NAN);
|
||||
CHECK(_home.longitude_deg != NAN);
|
||||
return _home;
|
||||
}
|
||||
|
||||
template<typename Rep, typename Period>
|
||||
void sleep_for(std::chrono::duration<Rep, Period> duration)
|
||||
{
|
||||
@@ -207,6 +189,24 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
mavsdk::Param *getParams() const { return _param.get();}
|
||||
mavsdk::Telemetry *getTelemetry() const { return _telemetry.get();}
|
||||
mavsdk::ManualControl *getManualControl() const { return _manual_control.get();}
|
||||
MavlinkPassthrough *getMavlinkPassthrough() const { return _mavlink_passthrough.get();}
|
||||
std::shared_ptr<System> get_system() { return _mavsdk.systems().at(0);}
|
||||
mavsdk::geometry::CoordinateTransformation get_coordinate_transformation();
|
||||
bool ground_truth_horizontal_position_close_to(const Telemetry::GroundTruth &target_pos, float acceptance_radius_m);
|
||||
|
||||
const Telemetry::GroundTruth &getHome()
|
||||
{
|
||||
// Check if home was stored before it is accessed
|
||||
CHECK(_home.absolute_altitude_m != NAN);
|
||||
CHECK(_home.latitude_deg != NAN);
|
||||
CHECK(_home.longitude_deg != NAN);
|
||||
return _home;
|
||||
}
|
||||
|
||||
private:
|
||||
mavsdk::Mission::MissionItem create_mission_item(
|
||||
const mavsdk::geometry::CoordinateTransformation::LocalCoordinate &local_coordinate,
|
||||
@@ -282,7 +282,6 @@ private:
|
||||
}
|
||||
|
||||
|
||||
|
||||
mavsdk::Mavsdk _mavsdk{};
|
||||
std::unique_ptr<mavsdk::Action> _action{};
|
||||
std::unique_ptr<mavsdk::Failure> _failure{};
|
||||
|
||||
Reference in New Issue
Block a user