I made these changes basically for sonar develpoment but could be interresting for anybody.
So my idea was to normalize the baro altitude value, with a compensation.
Now my code sets up baro alt to zero on every arming, to reduce temperature-drift. So when armed, baroalt became zero, and baroalt values will be measured from ground level. So that will be comperable to sonaralt values!
Here are my changes:
in multiwii.ino, define these values:
Code: Select all
static int32_t BaroAlt0;
static int32_t BaroOff = 0;
static uint8_t BaroSet = 0;
then add this inside void loop (I added this after defined spektrum, but don't know where would be the best...):
Code: Select all
#if BARO
if (armed == 1) {
if (BaroSet == 0) {
BaroOff = BaroAlt0;
BaroSet = 1;
}
}
else {BaroSet = 0;}
#endif
and finally, modify the MS5611 code to this:
Code: Select all
...
BaroAlt0 = (1.0f - pow(pressure/101325.0f, 0.190295f)) * 4433000.0f; //centimeter
BaroAlt = BaroAlt0 - BaroOff;
...
or BMP085 code to this:
Code: Select all
...
BaroAlt0 = (1.0f - pow(pressure/101325.0f, 0.190295f)) * 4433000.0f; //centimeter
BaroAlt = BaroAlt0 - BaroOff;
...
Now, alt value will be measured from ground level when flying....
Please note that these canges will not effect altitude hold algorithm. At least they don't should!!! I tested this code in three flights with alt hold enabled, worked great!!!
Here is a sample log about a short take-off in my livingroom:

BR
Adrian