From 1ccff12b541a23c06eab8a32dcafe0d76a6478ea Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 17 Aug 2012 14:21:43 +1000 Subject: [PATCH] SITL: added SIM_ENGINE_MUL this allows for simulated engine failures --- libraries/Desktop/support/sitl.cpp | 6 ++++++ libraries/SITL/SITL.cpp | 1 + libraries/SITL/SITL.h | 1 + 3 files changed, 8 insertions(+) diff --git a/libraries/Desktop/support/sitl.cpp b/libraries/Desktop/support/sitl.cpp index 069dbca932..efc39c930a 100644 --- a/libraries/Desktop/support/sitl.cpp +++ b/libraries/Desktop/support/sitl.cpp @@ -187,6 +187,12 @@ static void sitl_simulator_output(void) } if (!desktop_state.quadcopter) { + // add in engine multiplier + if (pwm[2] > 1000) { + pwm[2] = ((pwm[2]-1000) * sitl.engine_mul) + 1000; + if (pwm[2] > 2000) pwm[2] = 2000; + } + // 400kV motor, 16V sitl_motor_speed[0] = ((pwm[2]-1000)/1000.0) * 400 * 16 / 60.0; } else { diff --git a/libraries/SITL/SITL.cpp b/libraries/SITL/SITL.cpp index 31fc24d8a5..491f7253c5 100644 --- a/libraries/SITL/SITL.cpp +++ b/libraries/SITL/SITL.cpp @@ -23,6 +23,7 @@ const AP_Param::GroupInfo SITL::var_info[] PROGMEM = { AP_GROUPINFO("DRIFT_SPEED",5, SITL, drift_speed, 0.2), AP_GROUPINFO("DRIFT_TIME", 6, SITL, drift_time, 5), AP_GROUPINFO("GPS_DELAY", 7, SITL, gps_delay, 4), + AP_GROUPINFO("ENGINE_MUL", 8, SITL, engine_mul, 1), AP_GROUPEND }; diff --git a/libraries/SITL/SITL.h b/libraries/SITL/SITL.h index c1c7c1f14d..9f7e65488c 100644 --- a/libraries/SITL/SITL.h +++ b/libraries/SITL/SITL.h @@ -50,6 +50,7 @@ public: AP_Float drift_speed; // degrees/second/minute AP_Float drift_time; // period in minutes + AP_Float engine_mul; // engine multiplier AP_Int8 gps_disable; // disable simulated GPS AP_Int8 gps_delay; // delay in samples