From ac3200fd325f94438a2f9b4c38487d708d6f94a7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 30 Jun 2015 10:51:43 +1000 Subject: [PATCH] AP_InertialSensor: make max_abs_offsets a single float, not a vector --- libraries/AP_InertialSensor/AP_InertialSensor.cpp | 10 +++++----- libraries/AP_InertialSensor/AP_InertialSensor.h | 4 ++-- .../AP_InertialSensor/AP_InertialSensor_Backend.cpp | 4 ++-- .../AP_InertialSensor/AP_InertialSensor_Backend.h | 2 +- .../AP_InertialSensor/AP_InertialSensor_LSM9DS0.cpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libraries/AP_InertialSensor/AP_InertialSensor.cpp b/libraries/AP_InertialSensor/AP_InertialSensor.cpp index 9d87bf24d4..7744dc6c90 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor.cpp @@ -302,7 +302,7 @@ AP_InertialSensor::AP_InertialSensor() : _accel_clip_count[i] = 0; #endif - _accel_max_abs_offsets[i] = Vector3f(3.5f, 3.5f, 3.5f); + _accel_max_abs_offsets[i] = 3.5f; } memset(_delta_velocity_valid,0,sizeof(_delta_velocity_valid)); memset(_delta_angle_valid,0,sizeof(_delta_angle_valid)); @@ -987,7 +987,7 @@ bool AP_InertialSensor::_check_sample_range(const Vector3f accel_sample[6], enum bool AP_InertialSensor::_calibrate_accel(const Vector3f accel_sample[6], Vector3f& accel_offsets, Vector3f& accel_scale, - Vector3f& max_abs_offsets, + float max_abs_offsets, enum Rotation rotation) { int16_t i; @@ -1046,9 +1046,9 @@ bool AP_InertialSensor::_calibrate_accel(const Vector3f accel_sample[6], } if (accel_offsets.is_nan() || - fabsf(accel_offsets.x) > max_abs_offsets.x || - fabsf(accel_offsets.y) > max_abs_offsets.y || - fabsf(accel_offsets.z) > max_abs_offsets.z) { + fabsf(accel_offsets.x) > max_abs_offsets || + fabsf(accel_offsets.y) > max_abs_offsets || + fabsf(accel_offsets.z) > max_abs_offsets) { success = false; } diff --git a/libraries/AP_InertialSensor/AP_InertialSensor.h b/libraries/AP_InertialSensor/AP_InertialSensor.h index c0a14cdd51..19d53d407d 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor.h +++ b/libraries/AP_InertialSensor/AP_InertialSensor.h @@ -251,7 +251,7 @@ private: bool _calibrate_accel(const Vector3f accel_sample[6], Vector3f& accel_offsets, Vector3f& accel_scale, - Vector3f& max_abs_offsets, + float max_abs_offsets, enum Rotation rotation); bool _check_sample_range(const Vector3f accel_sample[6], enum Rotation rotation, AP_InertialSensor_UserInteract* interact); @@ -297,7 +297,7 @@ private: AP_Vector3f _gyro_offset[INS_MAX_INSTANCES]; // accelerometer max absolute offsets to be used for calibration - Vector3f _accel_max_abs_offsets[INS_MAX_INSTANCES]; + float _accel_max_abs_offsets[INS_MAX_INSTANCES]; // temperatures for an instance if available float _temperature[INS_MAX_INSTANCES]; diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_Backend.cpp b/libraries/AP_InertialSensor/AP_InertialSensor_Backend.cpp index 1d66890515..068f79bd1b 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_Backend.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor_Backend.cpp @@ -79,9 +79,9 @@ void AP_InertialSensor_Backend::_publish_accel(uint8_t instance, const Vector3f } void AP_InertialSensor_Backend::_set_accel_max_abs_offset(uint8_t instance, - const Vector3f offset) + float max_offset) { - _imu._accel_max_abs_offsets[instance] = offset; + _imu._accel_max_abs_offsets[instance] = max_offset; } // set accelerometer error_count diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_Backend.h b/libraries/AP_InertialSensor/AP_InertialSensor_Backend.h index 9d1a6b2d9b..081b9fc9c0 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_Backend.h +++ b/libraries/AP_InertialSensor/AP_InertialSensor_Backend.h @@ -74,7 +74,7 @@ protected: void _publish_accel(uint8_t instance, const Vector3f &accel, bool rotate_and_correct = true); // set accelerometer max absolute offset for calibration - void _set_accel_max_abs_offset(uint8_t instance, const Vector3f offset); + void _set_accel_max_abs_offset(uint8_t instance, float offset); // publish a temperature value void _publish_temperature(uint8_t instance, float temperature); diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_LSM9DS0.cpp b/libraries/AP_InertialSensor/AP_InertialSensor_LSM9DS0.cpp index 66713a96aa..b01ff757e2 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_LSM9DS0.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor_LSM9DS0.cpp @@ -483,7 +483,7 @@ bool AP_InertialSensor_LSM9DS0::_init_sensor() _gyro_instance = _imu.register_gyro(); _accel_instance = _imu.register_accel(); - _set_accel_max_abs_offset(_accel_instance, Vector3f(5.0f, 5.0f, 5.0f)); + _set_accel_max_abs_offset(_accel_instance, 5.0f); #if LSM9DS0_DEBUG _dump_registers();