42 #include <mathlib/mathlib.h> 48 float max_start_temperature,
int gyro_subs[],
int num_gyros)
51 for (
int i = 0; i < num_gyros; ++i) {
65 for (
unsigned s = 0; s < 3; s++) {
77 bool finished = data.hot_soaked;
83 return finished ? 0 : 1;
96 data.sensor_sample_filt[0] = gyro_data.
x;
97 data.sensor_sample_filt[1] = gyro_data.
y;
98 data.sensor_sample_filt[2] = gyro_data.
z;
106 if (!data.cold_soaked) {
114 data.cold_soaked =
true;
115 data.low_temp = data.sensor_sample_filt[3];
116 data.high_temp = data.low_temp;
127 if (data.sensor_sample_filt[3] > data.high_temp) {
128 data.high_temp = data.sensor_sample_filt[3];
129 data.hot_soak_sat = 0;
137 data.hot_soaked =
true;
141 TC_DEBUG(
"\nGyro: %.20f,%.20f,%.20f,%.20f, %.6f, %.6f, %.6f\n\n", (
double)data.sensor_sample_filt[0],
142 (
double)data.sensor_sample_filt[1],
143 (
double)data.sensor_sample_filt[2], (
double)data.sensor_sample_filt[3], (
double)data.low_temp, (
double)data.high_temp,
144 (
double)(data.high_temp - data.low_temp));
148 double relative_temperature = (double)data.sensor_sample_filt[3] - (
double)data.ref_temp;
149 data.P[0].update(relative_temperature, (
double)data.sensor_sample_filt[0]);
150 data.P[1].update(relative_temperature, (
double)data.sensor_sample_filt[1]);
151 data.P[2].update(relative_temperature, (
double)data.sensor_sample_filt[2]);
165 if (result != PX4_OK) {
166 PX4_ERR(
"unable to reset TC_G_ENABLE (%i)", result);
174 if (!data.hot_soaked || data.tempcal_complete) {
178 double res[3][4] = {};
179 data.P[0].fit(res[0]);
180 PX4_INFO(
"Result Gyro %d Axis 0: %.20f %.20f %.20f %.20f", sensor_index, (
double)res[0][0], (
double)res[0][1],
183 data.P[1].fit(res[1]);
184 PX4_INFO(
"Result Gyro %d Axis 1: %.20f %.20f %.20f %.20f", sensor_index, (
double)res[1][0], (
double)res[1][1],
187 data.P[2].fit(res[2]);
188 PX4_INFO(
"Result Gyro %d Axis 2: %.20f %.20f %.20f %.20f", sensor_index, (
double)res[2][0], (
double)res[2][1],
191 data.tempcal_complete =
true;
199 for (
unsigned axis_index = 0; axis_index < 3; axis_index++) {
200 for (
unsigned coef_index = 0; coef_index <= 3; coef_index++) {
201 sprintf(str,
"TC_G%d_X%d_%d", sensor_index, 3 - coef_index, axis_index);
202 param = (float)res[axis_index][coef_index];
205 if (result != PX4_OK) {
206 PX4_ERR(
"unable to reset %s", str);
int _sensor_subs[SENSOR_COUNT_MAX]
int orb_copy(const struct orb_metadata *meta, int handle, void *buffer)
__EXPORT int param_set_no_notification(param_t param, const void *val)
Set the value of a parameter, but do not notify the system about the change.
float _min_temperature_rise
minimum difference in temperature before the process finishes
#define TC_ERROR_INITIAL_TEMP_TOO_HIGH
starting temperature was above the configured allowed temperature
class TemperatureCalibrationCommon Common base class for all sensor types, contains shared code & dat...
TemperatureCalibrationGyro(float min_temperature_rise, float min_start_temperature, float max_start_temperature, int gyro_subs[], int num_gyros)
unsigned _num_sensor_instances
High-resolution timer with callouts and timekeeping.
int set_parameter(const char *format_str, unsigned index, const void *value)
set a system parameter (without system notification) and print an error if it fails ...
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
virtual int update_sensor_instance(PerSensorData &data, int sensor_sub)
update a single sensor instance
__EXPORT param_t param_find(const char *name)
Look up a parameter by name.
int orb_check(int handle, bool *updated)
float _max_start_temperature
maximum temperature above which the process does not start and an error is declared ...
float _min_start_temperature
minimum temperature before the process starts
#define TC_DEBUG(fmt,...)
int finish_sensor_instance(PerSensorData &data, int sensor_index)
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
PerSensorData _data[SENSOR_COUNT_MAX]