mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 15:33:33 +08:00
sensors: preserve all valid calibration parameters even if sensor currently missing
- mark calibration slots active for first N sensors found - calibration procedure don't bother resetting unused slots
This commit is contained in:
@@ -59,6 +59,11 @@ void Accelerometer::set_device_id(uint32_t device_id, bool external)
|
||||
if (_device_id != device_id || _external != external) {
|
||||
set_external(external);
|
||||
_device_id = device_id;
|
||||
|
||||
if (_device_id != 0) {
|
||||
_calibration_index = FindCalibrationIndex(SensorString(), _device_id);
|
||||
}
|
||||
|
||||
ParametersUpdate();
|
||||
SensorCorrectionsUpdate(true);
|
||||
}
|
||||
@@ -161,13 +166,6 @@ void Accelerometer::set_rotation(Rotation rotation)
|
||||
|
||||
void Accelerometer::ParametersUpdate()
|
||||
{
|
||||
if (_device_id == 0) {
|
||||
Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
_calibration_index = FindCalibrationIndex(SensorString(), _device_id);
|
||||
|
||||
if (_calibration_index >= 0) {
|
||||
|
||||
// CAL_ACCx_ROT
|
||||
@@ -234,6 +232,7 @@ void Accelerometer::Reset()
|
||||
|
||||
_offset.zero();
|
||||
_scale = Vector3f{1.f, 1.f, 1.f};
|
||||
|
||||
_thermal_offset.zero();
|
||||
|
||||
_priority = _external ? DEFAULT_EXTERNAL_PRIORITY : DEFAULT_PRIORITY;
|
||||
|
||||
@@ -59,6 +59,11 @@ void Gyroscope::set_device_id(uint32_t device_id, bool external)
|
||||
if (_device_id != device_id || _external != external) {
|
||||
set_external(external);
|
||||
_device_id = device_id;
|
||||
|
||||
if (_device_id != 0) {
|
||||
_calibration_index = FindCalibrationIndex(SensorString(), _device_id);
|
||||
}
|
||||
|
||||
ParametersUpdate();
|
||||
SensorCorrectionsUpdate(true);
|
||||
}
|
||||
@@ -146,13 +151,6 @@ void Gyroscope::set_rotation(Rotation rotation)
|
||||
|
||||
void Gyroscope::ParametersUpdate()
|
||||
{
|
||||
if (_device_id == 0) {
|
||||
Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
_calibration_index = FindCalibrationIndex(SensorString(), _device_id);
|
||||
|
||||
if (_calibration_index >= 0) {
|
||||
|
||||
// CAL_GYROx_ROT
|
||||
@@ -215,6 +213,7 @@ void Gyroscope::Reset()
|
||||
}
|
||||
|
||||
_offset.zero();
|
||||
|
||||
_thermal_offset.zero();
|
||||
|
||||
_priority = _external ? DEFAULT_EXTERNAL_PRIORITY : DEFAULT_PRIORITY;
|
||||
|
||||
@@ -59,6 +59,11 @@ void Magnetometer::set_device_id(uint32_t device_id, bool external)
|
||||
if (_device_id != device_id || _external != external) {
|
||||
set_external(external);
|
||||
_device_id = device_id;
|
||||
|
||||
if (_device_id != 0) {
|
||||
_calibration_index = FindCalibrationIndex(SensorString(), _device_id);
|
||||
}
|
||||
|
||||
ParametersUpdate();
|
||||
}
|
||||
}
|
||||
@@ -146,13 +151,6 @@ void Magnetometer::set_rotation(Rotation rotation)
|
||||
|
||||
void Magnetometer::ParametersUpdate()
|
||||
{
|
||||
if (_device_id == 0) {
|
||||
Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
_calibration_index = FindCalibrationIndex(SensorString(), _device_id);
|
||||
|
||||
if (_calibration_index >= 0) {
|
||||
|
||||
// CAL_MAGx_ROT
|
||||
|
||||
Reference in New Issue
Block a user