1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

CC-26: Add accel bias term. Note it's units are LSB, not m/s^s

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2895 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2011-02-26 22:21:44 +00:00 committed by peabody124
parent 21a31df392
commit ea390d0b90
2 changed files with 10 additions and 0 deletions

View File

@ -84,6 +84,7 @@ static void settingsUpdatedCb(UAVObjEvent * objEv);
static float accelKi = 0;
static float accelKp = 0;
static float gyroGain = 0.42;
static int16_t accelbias[3];
/**
* Initialise the module, called on startup
@ -215,6 +216,9 @@ static void updateSensors(AttitudeRawData * attitudeRaw)
} while ( (i < 32) && (samples_remaining > 0) );
attitudeRaw->gyrotemp[0] = samples_remaining;
attitudeRaw->gyrotemp[1] = i;
x -= accelbias[0];
y -= accelbias[1];
z -= accelbias[2];
attitudeRaw->accels[ATTITUDERAW_ACCELS_X] = ((float)x * 0.004f * 9.81f) / i;
attitudeRaw->accels[ATTITUDERAW_ACCELS_Y] = ((float)y * 0.004f * 9.81f) / i;
attitudeRaw->accels[ATTITUDERAW_ACCELS_Z] = ((float)z * 0.004f * 9.81f) / i;
@ -311,6 +315,11 @@ static void settingsUpdatedCb(UAVObjEvent * objEv) {
accelKp = attitudeSettings.AccelKp;
accelKi = attitudeSettings.AccelKi;
gyroGain = attitudeSettings.GyroGain;
accelbias[0] = attitudeSettings.AccelBias[ATTITUDESETTINGS_ACCELBIAS_X];
accelbias[1] = attitudeSettings.AccelBias[ATTITUDESETTINGS_ACCELBIAS_Y];
accelbias[2] = attitudeSettings.AccelBias[ATTITUDESETTINGS_ACCELBIAS_Z];
}
/**
* @}

View File

@ -1,6 +1,7 @@
<xml>
<object name="AttitudeSettings" singleinstance="true" settings="true">
<description>Settings for the @ref Attitude module used on CopterControl</description>
<field name="AccelBias" units="lsb" type="int16" elementnames="X,Y,Z" defaultvalue="0"/>
<field name="GyroGain" units="(rad/s)/lsb" type="float" elements="1" defaultvalue="0.42"/>
<field name="AccelKp" units="channel" type="float" elements="1" defaultvalue="0.01"/>
<field name="AccelKi" units="channel" type="float" elements="1" defaultvalue="0.0001"/>