1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Revert "GCS/Scope: Make smooth interpolation (and internal sum) be long term correct despite limited floating point accuracy, but keep constant overhead"

This reverts commit 78278683cc.
This commit is contained in:
James Cotton 2011-12-12 23:36:43 -06:00
parent 40e7bf5c59
commit bf98fe14c3
3 changed files with 6 additions and 31 deletions

View File

@ -55,8 +55,6 @@ PlotData::PlotData(QString p_uavObject, QString p_uavField)
scalePower = 0;
interpolationSamples = 1;
interpolationSum = 0.0f;
correctionSum = 0.0f;
correctionCount = 0;
yMinimum = 0;
yMaximum = 0;
@ -97,23 +95,12 @@ bool SequencialPlotData::append(UAVObject* obj)
if (field) {
//Shift data forward and put the new value at the front
// calculate interpolated (smoothed) value
double currentValue = valueAsDouble(obj, field) * pow(10, scalePower);
yDataHistory->append( currentValue );
interpolationSum += currentValue;
yDataHistory->append( valueAsDouble(obj, field) * pow(10, scalePower));
interpolationSum += valueAsDouble(obj, field) * pow(10, scalePower);
if(yDataHistory->size() > interpolationSamples) {
interpolationSum -= yDataHistory->first();
yDataHistory->pop_front();
}
// make sure to correct the sum every interpolationSamples steps to prevent it
// from running away due to flouting point rounding errors
correctionSum += currentValue;
if (++correctionCount >= interpolationSamples) {
interpolationSum = correctionSum;
correctionSum = 0.0f;
correctionCount = 0;
}
yData->append(interpolationSum/yDataHistory->size());
if (yData->size() > m_xWindowSize) {
yData->pop_front();
@ -140,22 +127,12 @@ bool ChronoPlotData::append(UAVObject* obj)
//Put the new value at the front
QDateTime NOW = QDateTime::currentDateTime();
// calculate interpolated (smoothed) value
double currentValue = valueAsDouble(obj, field) * pow(10, scalePower);
yDataHistory->append( currentValue );
interpolationSum += currentValue;
yDataHistory->append( valueAsDouble(obj, field) * pow(10, scalePower));
interpolationSum += valueAsDouble(obj, field) * pow(10, scalePower);
if(yDataHistory->size() > interpolationSamples) {
interpolationSum -= yDataHistory->first();
yDataHistory->pop_front();
}
// make sure to correct the sum every interpolationSamples steps to prevent it
// from running away due to flouting point rounding errors
correctionSum += currentValue;
if (++correctionCount >= interpolationSamples) {
interpolationSum = correctionSum;
correctionSum = 0.0f;
correctionCount = 0;
}
double valueX = NOW.toTime_t() + NOW.time().msec() / 1000.0;
double valueY = interpolationSum/yDataHistory->size();

View File

@ -74,8 +74,6 @@ public:
int scalePower; //This is the power to which each value must be raised
int interpolationSamples;
double interpolationSum;
double correctionSum;
int correctionCount;
double yMinimum;
double yMaximum;
double m_xWindowSize;

View File

@ -162,7 +162,7 @@
<item row="9" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Display smoothed interpolation:</string>
<string>Smooth Interpolation:</string>
</property>
</widget>
</item>
@ -294,7 +294,7 @@ Update</string>
<item>
<widget class="QCheckBox" name="LoggingEnable">
<property name="text">
<string>Log data to csv file (not interpolated)</string>
<string>Log data to csv file</string>
</property>
</widget>
</item>