mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 23:53:33 +08:00
sensor_calibration: refactor and centralize calibration slot logic
- centralize logic for selecting a preferred calibration slot - automatically use existing calibration slot if it exists, otherwise find first available slot, with a preference for a requested index - existing commander calibration methods rewrite all calibration slots to match current sensor ordering
This commit is contained in:
@@ -243,8 +243,6 @@ void GyroCalibration::Run()
|
||||
return;
|
||||
}
|
||||
|
||||
_gyro_calibration[gyro].set_calibration_index(gyro);
|
||||
|
||||
const Vector3f old_offset{_gyro_calibration[gyro].offset()};
|
||||
|
||||
if (_gyro_calibration[gyro].set_offset(_gyro_mean[gyro].mean())) {
|
||||
@@ -252,7 +250,7 @@ void GyroCalibration::Run()
|
||||
|
||||
calibration_updated = true;
|
||||
|
||||
PX4_INFO("gyro %d (%" PRIu32 ") updating calibration, [%.4f, %.4f, %.4f] -> [%.4f, %.4f, %.4f] %.1f°C",
|
||||
PX4_INFO("gyro %d (%" PRIu32 ") updating offsets [%.3f, %.3f, %.3f]->[%.3f, %.3f, %.3f] %.1f degC",
|
||||
gyro, _gyro_calibration[gyro].device_id(),
|
||||
(double)old_offset(0), (double)old_offset(1), (double)old_offset(2),
|
||||
(double)_gyro_mean[gyro].mean()(0), (double)_gyro_mean[gyro].mean()(1), (double)_gyro_mean[gyro].mean()(2),
|
||||
@@ -269,7 +267,7 @@ void GyroCalibration::Run()
|
||||
|
||||
for (int gyro = 0; gyro < _sensor_gyro_subs.size(); gyro++) {
|
||||
if (_gyro_calibration[gyro].device_id() != 0) {
|
||||
if (_gyro_calibration[gyro].ParametersSave()) {
|
||||
if (_gyro_calibration[gyro].ParametersSave(gyro)) {
|
||||
param_save = true;
|
||||
}
|
||||
}
|
||||
@@ -312,7 +310,7 @@ int GyroCalibration::print_status()
|
||||
{
|
||||
for (int gyro = 0; gyro < _sensor_gyro_subs.size(); gyro++) {
|
||||
if (_gyro_calibration[gyro].device_id() != 0) {
|
||||
PX4_INFO_RAW("gyro %d (%" PRIu32 "), [%.5f, %.5f, %.5f] var: [%.9f, %.9f, %.9f] %.1f°C (count %d)\n",
|
||||
PX4_INFO_RAW("gyro %d (%" PRIu32 "), [%.5f, %.5f, %.5f] var: [%.9f, %.9f, %.9f] %.1f degC (count %d)\n",
|
||||
gyro, _gyro_calibration[gyro].device_id(),
|
||||
(double)_gyro_mean[gyro].mean()(0), (double)_gyro_mean[gyro].mean()(1), (double)_gyro_mean[gyro].mean()(2),
|
||||
(double)_gyro_mean[gyro].variance()(0), (double)_gyro_mean[gyro].variance()(1), (double)_gyro_mean[gyro].variance()(2),
|
||||
|
||||
Reference in New Issue
Block a user