mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +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:
parent
40e7bf5c59
commit
bf98fe14c3
@ -55,8 +55,6 @@ PlotData::PlotData(QString p_uavObject, QString p_uavField)
|
|||||||
scalePower = 0;
|
scalePower = 0;
|
||||||
interpolationSamples = 1;
|
interpolationSamples = 1;
|
||||||
interpolationSum = 0.0f;
|
interpolationSum = 0.0f;
|
||||||
correctionSum = 0.0f;
|
|
||||||
correctionCount = 0;
|
|
||||||
yMinimum = 0;
|
yMinimum = 0;
|
||||||
yMaximum = 0;
|
yMaximum = 0;
|
||||||
|
|
||||||
@ -97,23 +95,12 @@ bool SequencialPlotData::append(UAVObject* obj)
|
|||||||
if (field) {
|
if (field) {
|
||||||
|
|
||||||
//Shift data forward and put the new value at the front
|
//Shift data forward and put the new value at the front
|
||||||
|
yDataHistory->append( valueAsDouble(obj, field) * pow(10, scalePower));
|
||||||
// calculate interpolated (smoothed) value
|
interpolationSum += valueAsDouble(obj, field) * pow(10, scalePower);
|
||||||
double currentValue = valueAsDouble(obj, field) * pow(10, scalePower);
|
|
||||||
yDataHistory->append( currentValue );
|
|
||||||
interpolationSum += currentValue;
|
|
||||||
if(yDataHistory->size() > interpolationSamples) {
|
if(yDataHistory->size() > interpolationSamples) {
|
||||||
interpolationSum -= yDataHistory->first();
|
interpolationSum -= yDataHistory->first();
|
||||||
yDataHistory->pop_front();
|
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());
|
yData->append(interpolationSum/yDataHistory->size());
|
||||||
if (yData->size() > m_xWindowSize) {
|
if (yData->size() > m_xWindowSize) {
|
||||||
yData->pop_front();
|
yData->pop_front();
|
||||||
@ -140,22 +127,12 @@ bool ChronoPlotData::append(UAVObject* obj)
|
|||||||
//Put the new value at the front
|
//Put the new value at the front
|
||||||
QDateTime NOW = QDateTime::currentDateTime();
|
QDateTime NOW = QDateTime::currentDateTime();
|
||||||
|
|
||||||
// calculate interpolated (smoothed) value
|
yDataHistory->append( valueAsDouble(obj, field) * pow(10, scalePower));
|
||||||
double currentValue = valueAsDouble(obj, field) * pow(10, scalePower);
|
interpolationSum += valueAsDouble(obj, field) * pow(10, scalePower);
|
||||||
yDataHistory->append( currentValue );
|
|
||||||
interpolationSum += currentValue;
|
|
||||||
if(yDataHistory->size() > interpolationSamples) {
|
if(yDataHistory->size() > interpolationSamples) {
|
||||||
interpolationSum -= yDataHistory->first();
|
interpolationSum -= yDataHistory->first();
|
||||||
yDataHistory->pop_front();
|
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 valueX = NOW.toTime_t() + NOW.time().msec() / 1000.0;
|
||||||
double valueY = interpolationSum/yDataHistory->size();
|
double valueY = interpolationSum/yDataHistory->size();
|
||||||
|
@ -74,8 +74,6 @@ public:
|
|||||||
int scalePower; //This is the power to which each value must be raised
|
int scalePower; //This is the power to which each value must be raised
|
||||||
int interpolationSamples;
|
int interpolationSamples;
|
||||||
double interpolationSum;
|
double interpolationSum;
|
||||||
double correctionSum;
|
|
||||||
int correctionCount;
|
|
||||||
double yMinimum;
|
double yMinimum;
|
||||||
double yMaximum;
|
double yMaximum;
|
||||||
double m_xWindowSize;
|
double m_xWindowSize;
|
||||||
|
@ -162,7 +162,7 @@
|
|||||||
<item row="9" column="0">
|
<item row="9" column="0">
|
||||||
<widget class="QLabel" name="label_10">
|
<widget class="QLabel" name="label_10">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Display smoothed interpolation:</string>
|
<string>Smooth Interpolation:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -294,7 +294,7 @@ Update</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="LoggingEnable">
|
<widget class="QCheckBox" name="LoggingEnable">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Log data to csv file (not interpolated)</string>
|
<string>Log data to csv file</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user