Browse Source

AP_InertialSensor: support saving tempcal params persistently

c415-sdk
Andrew Tridgell 4 years ago committed by Peter Barker
parent
commit
1ddc21c9bb
  1. 11
      libraries/AP_InertialSensor/AP_InertialSensor.h
  2. 37
      libraries/AP_InertialSensor/AP_InertialSensor_tempcal.cpp

11
libraries/AP_InertialSensor/AP_InertialSensor.h

@ -433,6 +433,14 @@ public: @@ -433,6 +433,14 @@ public:
void handle_external(const AP_ExternalAHRS::ins_data_message_t &pkt);
#endif
#if HAL_INS_TEMPERATURE_CAL_ENABLE
/*
get a string representation of parameters that should be made
persistent across changes of firmware type
*/
void get_persistent_params(ExpandingString &str) const;
#endif
private:
// load backend drivers
bool _add_backend(AP_InertialSensor_Backend *backend);
@ -737,6 +745,9 @@ public: @@ -737,6 +745,9 @@ public:
AP_Enum<Enable> enable;
// get persistent params for this instance
void get_persistent_params(ExpandingString &str) const;
private:
AP_Float temp_max;
AP_Float temp_min;

37
libraries/AP_InertialSensor/AP_InertialSensor_tempcal.cpp

@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
#include <GCS_MAVLink/GCS.h>
#include <AP_Logger/AP_Logger.h>
#include <AP_Common/ExpandingString.h>
// this scale factor ensures params are easy to work with in GUI parameter editors
#define SCALE_FACTOR 1.0e6
@ -421,4 +422,40 @@ uint8_t AP_InertialSensor::TCal::instance(void) const @@ -421,4 +422,40 @@ uint8_t AP_InertialSensor::TCal::instance(void) const
return AP::ins().tcal_instance(*this);
}
/*
get a string representation of parameters for this calibration set
*/
void AP_InertialSensor::TCal::get_persistent_params(ExpandingString &str) const
{
if (enable != TCal::Enable::Enabled) {
return;
}
const uint8_t imu = instance()+1;
str.printf("INS_TCAL%u_ENABLE=1\n", imu);
str.printf("INS_TCAL%u_TMIN=%.1f\n", imu, temp_min.get());
str.printf("INS_TCAL%u_TMAX=%.1f\n", imu, temp_max.get());
for (uint8_t k=0; k<3; k++) {
const Vector3f &acc = accel_coeff[k].get();
const Vector3f &gyr = gyro_coeff[k].get();
str.printf("INS_TCAL%u_ACC%u_X=%.1f\n", imu, k+1, acc.x);
str.printf("INS_TCAL%u_ACC%u_Y=%.1f\n", imu, k+1, acc.y);
str.printf("INS_TCAL%u_ACC%u_Z=%.1f\n", imu, k+1, acc.z);
str.printf("INS_TCAL%u_GYR%u_X=%.1f\n", imu, k+1, gyr.x);
str.printf("INS_TCAL%u_GYR%u_Y=%.1f\n", imu, k+1, gyr.y);
str.printf("INS_TCAL%u_GYR%u_Z=%.1f\n", imu, k+1, gyr.z);
}
}
/*
get a string representation of parameters that should be made
persistent across changes of firmware type
*/
void AP_InertialSensor::get_persistent_params(ExpandingString &str) const
{
for (auto &tc : tcal) {
tc.get_persistent_params(str);
}
}
#endif // HAL_INS_TEMPERATURE_CAL_ENABLE

Loading…
Cancel
Save