mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 10:03:35 +08:00
accelerometer_calibration: simplify & fix if temp compensation is enabled
if compensation enabled, scale & offsets for the drivers should be reset, but actually only the params were reset and accel_scale was still applied to the driver via ioctl.
This commit is contained in:
@@ -349,40 +349,29 @@ int do_accel_calibration(orb_advert_t *mavlink_log_pub)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the calibration values used the driver are at default settings
|
// Ensure the calibration values used the driver are at default settings
|
||||||
float driver_offset = 0.0f;
|
accel_scale.x_offset = 0.f;
|
||||||
float driver_scale = 1.0f;
|
accel_scale.y_offset = 0.f;
|
||||||
(void)sprintf(str, "CAL_ACC%u_XOFF", uorb_index);
|
accel_scale.z_offset = 0.f;
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(driver_offset)));
|
accel_scale.x_scale = 1.f;
|
||||||
(void)sprintf(str, "CAL_ACC%u_YOFF", uorb_index);
|
accel_scale.y_scale = 1.f;
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(driver_offset)));
|
accel_scale.z_scale = 1.f;
|
||||||
(void)sprintf(str, "CAL_ACC%u_ZOFF", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(driver_offset)));
|
|
||||||
(void)sprintf(str, "CAL_ACC%u_XSCALE", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(driver_scale)));
|
|
||||||
(void)sprintf(str, "CAL_ACC%u_YSCALE", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(driver_scale)));
|
|
||||||
(void)sprintf(str, "CAL_ACC%u_ZSCALE", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(driver_scale)));
|
|
||||||
(void)sprintf(str, "CAL_ACC%u_ID", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(device_id[uorb_index])));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
(void)sprintf(str, "CAL_ACC%u_XOFF", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.x_offset)));
|
|
||||||
(void)sprintf(str, "CAL_ACC%u_YOFF", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.y_offset)));
|
|
||||||
(void)sprintf(str, "CAL_ACC%u_ZOFF", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.z_offset)));
|
|
||||||
(void)sprintf(str, "CAL_ACC%u_XSCALE", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.x_scale)));
|
|
||||||
(void)sprintf(str, "CAL_ACC%u_YSCALE", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.y_scale)));
|
|
||||||
(void)sprintf(str, "CAL_ACC%u_ZSCALE", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.z_scale)));
|
|
||||||
(void)sprintf(str, "CAL_ACC%u_ID", uorb_index);
|
|
||||||
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(device_id[uorb_index])));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)sprintf(str, "CAL_ACC%u_XOFF", uorb_index);
|
||||||
|
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.x_offset)));
|
||||||
|
(void)sprintf(str, "CAL_ACC%u_YOFF", uorb_index);
|
||||||
|
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.y_offset)));
|
||||||
|
(void)sprintf(str, "CAL_ACC%u_ZOFF", uorb_index);
|
||||||
|
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.z_offset)));
|
||||||
|
(void)sprintf(str, "CAL_ACC%u_XSCALE", uorb_index);
|
||||||
|
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.x_scale)));
|
||||||
|
(void)sprintf(str, "CAL_ACC%u_YSCALE", uorb_index);
|
||||||
|
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.y_scale)));
|
||||||
|
(void)sprintf(str, "CAL_ACC%u_ZSCALE", uorb_index);
|
||||||
|
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(accel_scale.z_scale)));
|
||||||
|
(void)sprintf(str, "CAL_ACC%u_ID", uorb_index);
|
||||||
|
failed |= (PX4_OK != param_set_no_notification(param_find(str), &(device_id[uorb_index])));
|
||||||
|
|
||||||
if (failed) {
|
if (failed) {
|
||||||
calibration_log_critical(mavlink_log_pub, CAL_ERROR_SET_PARAMS_MSG, uorb_index);
|
calibration_log_critical(mavlink_log_pub, CAL_ERROR_SET_PARAMS_MSG, uorb_index);
|
||||||
return PX4_ERROR;
|
return PX4_ERROR;
|
||||||
|
|||||||
Reference in New Issue
Block a user