mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
CC-18 Attitude: Change units to proper engineering ones. An accelKp=1 means
that it will completely follow the accel attitude each cycle and is way too high. Ki=1 means the gyro bias wil be correct by accels each cycle (way too high). git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2755 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
cfe295377c
commit
9f71f4121c
@ -135,9 +135,9 @@ static void AttitudeTask(void *parameters)
|
|||||||
|
|
||||||
if(xTaskGetTickCount() < 10000) {
|
if(xTaskGetTickCount() < 10000) {
|
||||||
// For first 5 seconds use accels to get gyro bias
|
// For first 5 seconds use accels to get gyro bias
|
||||||
accelKp = 1000;
|
accelKp = 1;
|
||||||
// Decrease the rate of gyro learning during init
|
// Decrease the rate of gyro learning during init
|
||||||
accelKi = 100 / (xTaskGetTickCount() / 2000);
|
accelKi = .1 / (xTaskGetTickCount() / 5000);
|
||||||
} else if (init == 0) {
|
} else if (init == 0) {
|
||||||
settingsUpdatedCb(AttitudeSettingsHandle());
|
settingsUpdatedCb(AttitudeSettingsHandle());
|
||||||
init = 1;
|
init = 1;
|
||||||
@ -178,7 +178,7 @@ static void updateSensors(AttitudeRawData * attitudeRaw)
|
|||||||
// Because most crafts wont get enough information from gravity to zero yaw gyro
|
// Because most crafts wont get enough information from gravity to zero yaw gyro
|
||||||
attitudeRaw->gyros[ATTITUDERAW_GYROS_Z] += gyro_correct_int[2];
|
attitudeRaw->gyros[ATTITUDERAW_GYROS_Z] += gyro_correct_int[2];
|
||||||
gyro_correct_int[2] += - attitudeRaw->gyros[ATTITUDERAW_GYROS_Z] *
|
gyro_correct_int[2] += - attitudeRaw->gyros[ATTITUDERAW_GYROS_Z] *
|
||||||
accelKi * UPDATE_RATE / 1000;
|
accelKi;
|
||||||
|
|
||||||
|
|
||||||
// Get the accel data
|
// Get the accel data
|
||||||
@ -242,15 +242,15 @@ static void updateAttitude(AttitudeRawData * attitudeRaw)
|
|||||||
accel_err[1] /= accel_mag;
|
accel_err[1] /= accel_mag;
|
||||||
accel_err[2] /= accel_mag;
|
accel_err[2] /= accel_mag;
|
||||||
|
|
||||||
// Accumulate integral of error. Scale here so that units are rad/s
|
// Accumulate integral of error. Scale here so that units are (rad/s) but Ki has units of s
|
||||||
gyro_correct_int[0] += accel_err[0] * accelKi * dT;
|
gyro_correct_int[0] += accel_err[0] * accelKi;
|
||||||
gyro_correct_int[1] += accel_err[1] * accelKi * dT;
|
gyro_correct_int[1] += accel_err[1] * accelKi;
|
||||||
//gyro_correct_int[2] += accel_err[2] * settings.AccelKI * dT;
|
//gyro_correct_int[2] += accel_err[2] * settings.AccelKI * dT;
|
||||||
|
|
||||||
// Correct rates based on error, integral component dealt with in updateSensors
|
// Correct rates based on error, integral component dealt with in updateSensors
|
||||||
gyro[0] += accel_err[0] * accelKp;
|
gyro[0] += accel_err[0] * accelKp / dT;
|
||||||
gyro[1] += accel_err[1] * accelKp;
|
gyro[1] += accel_err[1] * accelKp / dT;
|
||||||
gyro[2] += accel_err[2] * accelKp;
|
gyro[2] += accel_err[2] * accelKp / dT;
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // scoping variables to save memory
|
{ // scoping variables to save memory
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<object name="AttitudeSettings" singleinstance="true" settings="true">
|
<object name="AttitudeSettings" singleinstance="true" settings="true">
|
||||||
<description>Settings for the @ref Attitude module used on CopterControl</description>
|
<description>Settings for the @ref Attitude module used on CopterControl</description>
|
||||||
<field name="GyroGain" units="(rad/s)/lsb" type="float" elements="1" defaultvalue="0.42"/>
|
<field name="GyroGain" units="(rad/s)/lsb" type="float" elements="1" defaultvalue="0.42"/>
|
||||||
<field name="AccelKp" units="channel" type="float" elements="1" defaultvalue="100"/>
|
<field name="AccelKp" units="channel" type="float" elements="1" defaultvalue="0.01"/>
|
||||||
<field name="AccelKi" units="channel" type="float" elements="1" defaultvalue="5"/>
|
<field name="AccelKi" units="channel" type="float" elements="1" defaultvalue="0.0001"/>
|
||||||
<access gcs="readwrite" flight="readwrite"/>
|
<access gcs="readwrite" flight="readwrite"/>
|
||||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||||
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user