From c275e7c61d2698467ad39512ee9d8da094161c2f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 19 Sep 2016 07:45:24 +1000 Subject: [PATCH] SITL: added SIM_SPEEDUP parameter allows changing speed of simulation while running --- libraries/SITL/SIM_Aircraft.cpp | 5 +++++ libraries/SITL/SIM_Aircraft.h | 1 + libraries/SITL/SITL.cpp | 1 + libraries/SITL/SITL.h | 1 + 4 files changed, 8 insertions(+) diff --git a/libraries/SITL/SIM_Aircraft.cpp b/libraries/SITL/SIM_Aircraft.cpp index f337c02cf7..af64dae0af 100644 --- a/libraries/SITL/SIM_Aircraft.cpp +++ b/libraries/SITL/SIM_Aircraft.cpp @@ -360,6 +360,11 @@ void Aircraft::fill_fdm(struct sitl_fdm &fdm) fdm.longitude = smoothing.location.lng * 1.0e-7; fdm.altitude = smoothing.location.alt * 1.0e-2; } + + if (last_speedup != sitl->speedup && sitl->speedup > 0) { + set_speedup(sitl->speedup); + last_speedup = sitl->speedup; + } } uint64_t Aircraft::get_wall_time_us() const diff --git a/libraries/SITL/SIM_Aircraft.h b/libraries/SITL/SIM_Aircraft.h index f0bec7456c..5119deb9df 100644 --- a/libraries/SITL/SIM_Aircraft.h +++ b/libraries/SITL/SIM_Aircraft.h @@ -147,6 +147,7 @@ protected: const char *autotest_dir; const char *frame; bool use_time_sync = true; + float last_speedup = -1; enum { GROUND_BEHAVIOR_NONE=0, diff --git a/libraries/SITL/SITL.cpp b/libraries/SITL/SITL.cpp index ce6216f632..be312eadc5 100644 --- a/libraries/SITL/SITL.cpp +++ b/libraries/SITL/SITL.cpp @@ -83,6 +83,7 @@ const AP_Param::GroupInfo SITL::var_info[] = { AP_GROUPINFO("MAG_ALY_HGT", 49, SITL, mag_anomaly_hgt, 1.0f), AP_GROUPINFO("PIN_MASK", 50, SITL, pin_mask, 0), AP_GROUPINFO("ADSB_TX", 51, SITL, adsb_tx, 0), + AP_GROUPINFO("SPEEDUP", 52, SITL, speedup, -1), AP_GROUPEND }; diff --git a/libraries/SITL/SITL.h b/libraries/SITL/SITL.h index 912164f76e..5c3e4fd381 100644 --- a/libraries/SITL/SITL.h +++ b/libraries/SITL/SITL.h @@ -104,6 +104,7 @@ public: AP_Int8 flow_delay; // optflow data delay AP_Int8 terrain_enable; // enable using terrain for height AP_Int8 pin_mask; // for GPIO emulation + AP_Float speedup; // simulation speedup // wind control float wind_speed_active;