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

OP-1149 Move accel/gyro calibration setting to a separate object, to be reused also for CC3D

This commit is contained in:
Alessio Morale 2013-12-26 16:55:57 +01:00
parent 558e2e1437
commit 7ac2f9f87f
5 changed files with 46 additions and 36 deletions

View File

@ -55,6 +55,7 @@
#include <attitudestate.h>
#include <attitudesettings.h>
#include <revocalibration.h>
#include <accelgyrosettings.h>
#include <flightstatus.h>
#include <taskinfo.h>
@ -78,6 +79,7 @@ static void settingsUpdatedCb(UAVObjEvent *objEv);
// Private variables
static xTaskHandle sensorsTaskHandle;
RevoCalibrationData cal;
AccelGyroSettingsData agcal;
// These values are initialized by settings but can be updated by the attitude algorithm
@ -116,12 +118,13 @@ int32_t SensorsInitialize(void)
MagSensorInitialize();
RevoCalibrationInitialize();
AttitudeSettingsInitialize();
AccelGyroSettingsInitialize();
rotate = 0;
RevoCalibrationConnectCallback(&settingsUpdatedCb);
AttitudeSettingsConnectCallback(&settingsUpdatedCb);
AccelGyroSettingsConnectCallback(&settingsUpdatedCb);
return 0;
}
@ -437,32 +440,32 @@ static void SensorsTask(__attribute__((unused)) void *parameters)
static void settingsUpdatedCb(__attribute__((unused)) UAVObjEvent *objEv)
{
RevoCalibrationGet(&cal);
AccelGyroSettingsGet(&agcal);
mag_bias[0] = cal.mag_bias.X;
mag_bias[1] = cal.mag_bias.Y;
mag_bias[2] = cal.mag_bias.Z;
mag_scale[0] = cal.mag_scale.X;
mag_scale[1] = cal.mag_scale.Y;
mag_scale[2] = cal.mag_scale.Z;
accel_bias[0] = cal.accel_bias.X;
accel_bias[1] = cal.accel_bias.Y;
accel_bias[2] = cal.accel_bias.Z;
accel_scale[0] = cal.accel_scale.X;
accel_scale[1] = cal.accel_scale.Y;
accel_scale[2] = cal.accel_scale.Z;
gyro_staticbias[0] = cal.gyro_bias.X;
gyro_staticbias[1] = cal.gyro_bias.Y;
gyro_staticbias[2] = cal.gyro_bias.Z;
gyro_scale[0] = cal.gyro_scale.X;
gyro_scale[1] = cal.gyro_scale.Y;
gyro_scale[2] = cal.gyro_scale.Z;
gyro_temp_coeff[0] = cal.gyro_temp_coeff.X;
gyro_temp_coeff[1] = cal.gyro_temp_coeff.Y;
gyro_temp_coeff[2] = cal.gyro_temp_coeff.Z;
gyro_temp_coeff[3] = cal.gyro_temp_coeff.Z2;
accel_temp_coeff[0] = cal.accel_temp_coeff.X;
accel_temp_coeff[1] = cal.accel_temp_coeff.Y;
accel_temp_coeff[2] = cal.accel_temp_coeff.Z;
accel_bias[0] = agcal.accel_bias.X;
accel_bias[1] = agcal.accel_bias.Y;
accel_bias[2] = agcal.accel_bias.Z;
accel_scale[0] = agcal.accel_scale.X;
accel_scale[1] = agcal.accel_scale.Y;
accel_scale[2] = agcal.accel_scale.Z;
gyro_staticbias[0] = agcal.gyro_bias.X;
gyro_staticbias[1] = agcal.gyro_bias.Y;
gyro_staticbias[2] = agcal.gyro_bias.Z;
gyro_scale[0] = agcal.gyro_scale.X;
gyro_scale[1] = agcal.gyro_scale.Y;
gyro_scale[2] = agcal.gyro_scale.Z;
gyro_temp_coeff[0] = agcal.gyro_temp_coeff.X;
gyro_temp_coeff[1] = agcal.gyro_temp_coeff.Y;
gyro_temp_coeff[2] = agcal.gyro_temp_coeff.Z;
gyro_temp_coeff[3] = agcal.gyro_temp_coeff.Z2;
accel_temp_coeff[0] = agcal.accel_temp_coeff.X;
accel_temp_coeff[1] = agcal.accel_temp_coeff.Y;
accel_temp_coeff[2] = agcal.accel_temp_coeff.Z;
AttitudeSettingsData attitudeSettings;
AttitudeSettingsGet(&attitudeSettings);

View File

@ -19,6 +19,7 @@
# These are the UAVObjects supposed to be build as part of the OpenPilot target
# (all architectures)
UAVOBJSRCFILENAMES =
UAVOBJSRCFILENAMES += accelgyrosettings
UAVOBJSRCFILENAMES += accessorydesired
UAVOBJSRCFILENAMES += actuatorcommand
UAVOBJSRCFILENAMES += actuatordesired

View File

@ -24,6 +24,7 @@
# (all architectures)
UAVOBJSRCFILENAMES =
UAVOBJSRCFILENAMES += accelgyrosettings
UAVOBJSRCFILENAMES += accessorydesired
UAVOBJSRCFILENAMES += actuatorcommand
UAVOBJSRCFILENAMES += actuatordesired

View File

@ -0,0 +1,16 @@
<xml>
<object name="AccelGyroSettings" singleinstance="true" settings="true" category="Sensors">
<description>Settings for Accelerometer and Gyroscope calibration </description>
<!-- Sensor calibration -->
<field name="accel_bias" units="m/s" type="float" elementnames="X,Y,Z" defaultvalue="0,0,0"/>
<field name="accel_scale" units="gain" type="float" elementnames="X,Y,Z" defaultvalue="1,1,1"/>
<field name="accel_temp_coeff" units="" type="float" elementnames="X,Y,Z" defaultvalue="0"/>
<field name="gyro_bias" units="deg/s" type="float" elementnames="X,Y,Z" defaultvalue="0,0,0"/>
<field name="gyro_scale" units="gain" type="float" elementnames="X,Y,Z" defaultvalue="1,1,1"/>
<field name="gyro_temp_coeff" units="" type="float" elementnames="X,Y,Z,Z2" defaultvalue="0"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="manual" period="0"/>
</object>
</xml>

View File

@ -1,23 +1,12 @@
<xml>
<object name="RevoCalibration" singleinstance="true" settings="true" category="Sensors">
<description>Settings for the INS to control the algorithm and what is updated</description>
<!-- Sensor calibration -->
<field name="accel_bias" units="m/s" type="float" elementnames="X,Y,Z" defaultvalue="0,0,0"/>
<field name="accel_scale" units="gain" type="float" elementnames="X,Y,Z" defaultvalue="1,1,1"/>
<field name="accel_temp_coeff" units="" type="float" elementnames="X,Y,Z" defaultvalue="0"/>
<field name="gyro_bias" units="deg/s" type="float" elementnames="X,Y,Z" defaultvalue="0,0,0"/>
<field name="gyro_scale" units="gain" type="float" elementnames="X,Y,Z" defaultvalue="1,1,1"/>
<field name="gyro_temp_coeff" units="" type="float" elementnames="X,Y,Z,Z2" defaultvalue="0"/>
<field name="mag_bias" units="mGau" type="float" elementnames="X,Y,Z" defaultvalue="0,0,0"/>
<field name="mag_scale" units="gain" type="float" elementnames="X,Y,Z" defaultvalue="1"/>
<!-- These settings are related to how the sensors are post processed -->
<!-- TODO: reimplement, put elsewhere (later) -->
<field name="BiasCorrectedRaw" units="" type="enum" elements="1" options="FALSE,TRUE" defaultvalue="TRUE"/>
<field name="MagBiasNullingRate" units="" type="float" elements="1" defaultvalue="0"/>
<!-- These settings are related to how the sensors are post processed -->
<!-- TODO: reimplement, put elsewhere (later) -->
<field name="BiasCorrectedRaw" units="" type="enum" elements="1" options="FALSE,TRUE" defaultvalue="TRUE"/>
<field name="MagBiasNullingRate" units="" type="float" elements="1" defaultvalue="0"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>