From 67ff2e58b8a90b8c8740554c899e5d046bd56e5a Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Wed, 11 Jun 2014 01:11:18 +0200 Subject: [PATCH] OP-1351 now use Newton's law of cooling to simulate temperature rise --- .../calibration/thermal/thermalcalibrationhelper.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/calibration/thermal/thermalcalibrationhelper.cpp b/ground/openpilotgcs/src/plugins/config/calibration/thermal/thermalcalibrationhelper.cpp index a4a4342e5..90dcbbcd8 100644 --- a/ground/openpilotgcs/src/plugins/config/calibration/thermal/thermalcalibrationhelper.cpp +++ b/ground/openpilotgcs/src/plugins/config/calibration/thermal/thermalcalibrationhelper.cpp @@ -31,6 +31,8 @@ #include #include "version_info/version_info.h" +#include + // #define SIMULATE namespace OpenPilot { @@ -263,8 +265,14 @@ float ThermalCalibrationHelper::getTemperature() { #ifdef SIMULATE float t = m_startTime.msecsTo(QTime::currentTime()) / 1000.0f; - // simulate a temperature rise from 20°C to 40°C - return 40 - 20 / (t + 1); + // Simulate a temperature rise using Newton's law of cooling + // See http://en.wikipedia.org/wiki/Newton%27s_law_of_cooling#Newton.27s_law_of_cooling + // Initial temp : 20 + // Final temp : 40 + // Made up time constant (t0) : 10.0 + // For a plot of the function, see http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiI0MC0yMCplXigteC8xMCkiLCJjb2xvciI6IiMwMDAwMDAifSx7InR5cGUiOjEwMDAsIndpbmRvdyI6WyItOTIuMjAzMjYzMTkzMzY4ODMiLCI5Ni45NzE2MzQ3NzU0MDAwOCIsIi00NC4zNzkzODMzMjU1NzY3NTQiLCI3Mi4wMzU5Mzg1MDEzNTc5OSJdfV0- + double t0 = 10.0; + return 40.0 - 20.0 * exp(-t / t0); #else return baroSensor->getTemperature();