36 #define TC_PRINT_DEBUG 0 38 #define TC_DEBUG(fmt, ...) printf(fmt, ##__VA_ARGS__); 40 #define TC_DEBUG(fmt, ...) 43 #include <px4_platform_common/log.h> 44 #include <mathlib/mathlib.h> 49 #define SENSOR_COUNT_MAX 3 52 #define TC_ERROR_INITIAL_TEMP_TOO_HIGH 110 53 #define TC_ERROR_COMMUNICATION 112
93 inline int set_parameter(
const char *format_str,
unsigned index,
const void *value);
105 (void)sprintf(param_str, format_str, index);
109 PX4_ERR(
"unable to reset %s (%i)", param_str, result);
119 template <
int Dim,
int PolyfitOrder>
133 int num_not_complete = 0;
135 if (_num_sensor_instances == 0) {
139 for (
unsigned uorb_index = 0; uorb_index < _num_sensor_instances; uorb_index++) {
140 int status = update_sensor_instance(
_data[uorb_index], _sensor_subs[uorb_index]);
146 num_not_complete +=
status;
149 if (num_not_complete > 0) {
153 for (
unsigned uorb_index = 0; uorb_index < _num_sensor_instances; uorb_index++) {
154 float cur_diff =
_data[uorb_index].high_temp -
_data[uorb_index].low_temp;
156 if (cur_diff < min_diff) {
170 float sensor_sample_filt[Dim + 1];
172 unsigned hot_soak_sat = 0;
175 bool cold_soaked =
false;
177 bool hot_soaked =
false;
178 bool tempcal_complete =
false;
179 float low_temp = 0.f;
180 float high_temp = 0.f;
181 float ref_temp = 0.f;
191 virtual int update_sensor_instance(PerSensorData &
data,
int sensor_sub) = 0;
193 unsigned _num_sensor_instances{0};
Base class for temperature calibration types with abstract methods (for all different sensor types) ...
static struct vehicle_status_s status
#define TC_ERROR_COMMUNICATION
no sensors found
__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
class TemperatureCalibrationCommon Common base class for all sensor types, contains shared code & dat...
virtual void reset_calibration()=0
reset all driver-level calibration parameters
static int32_t device_id[max_accel_sens]
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 ...
Global flash based parameter store.
TemperatureCalibrationBase(float min_temperature_rise, float min_start_temperature, float max_start_temperature)
virtual int finish()=0
do final fitting & write the parameters.
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
TemperatureCalibrationCommon(float min_temperature_rise, float min_start_temperature, float max_start_temperature)
virtual ~TemperatureCalibrationBase()
constexpr _Tp min(_Tp a, _Tp b)
__EXPORT param_t param_find(const char *name)
Look up a parameter by name.
float _max_start_temperature
maximum temperature above which the process does not start and an error is declared ...
virtual int update()=0
check & update new sensor data.
float _min_start_temperature
minimum temperature before the process starts
static struct mpu9x50_data _data
IMU measurement data.