mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 16:03:34 +08:00
accel & gyro calibration helpers
This commit is contained in:
@@ -50,4 +50,4 @@ px4_add_library(PreFlightCheck
|
||||
checks/cpuResourceCheck.cpp
|
||||
)
|
||||
target_include_directories(PreFlightCheck PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(PreFlightCheck PUBLIC ArmAuthorization HealthFlags)
|
||||
target_link_libraries(PreFlightCheck PUBLIC ArmAuthorization HealthFlags sensor_calibration)
|
||||
|
||||
@@ -301,38 +301,3 @@ bool PreFlightCheck::preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_statu
|
||||
/* Report status */
|
||||
return !failed;
|
||||
}
|
||||
|
||||
bool PreFlightCheck::check_calibration(const char *param_template, const int32_t device_id)
|
||||
{
|
||||
bool calibration_found = false;
|
||||
|
||||
char s[20];
|
||||
int instance = 0;
|
||||
|
||||
/* old style transition: check param values */
|
||||
while (!calibration_found) {
|
||||
sprintf(s, param_template, instance);
|
||||
const param_t parm = param_find_no_notification(s);
|
||||
|
||||
/* if the calibration param is not present, abort */
|
||||
if (parm == PARAM_INVALID) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* if param get succeeds */
|
||||
int32_t calibration_devid = -1;
|
||||
|
||||
if (param_get(parm, &calibration_devid) == PX4_OK) {
|
||||
|
||||
/* if the devid matches, exit early */
|
||||
if (device_id == calibration_devid) {
|
||||
calibration_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
instance++;
|
||||
}
|
||||
|
||||
return calibration_found;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
const bool report_fail, const bool enforce_gps_required);
|
||||
static bool failureDetectorCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_s &status, const bool report_fail,
|
||||
const bool prearm);
|
||||
static bool check_calibration(const char *param_template, const int32_t device_id);
|
||||
|
||||
static bool manualControlCheck(orb_advert_t *mavlink_log_pub, const bool report_fail);
|
||||
static bool airframeCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_s &status);
|
||||
static bool cpuResourceCheck(orb_advert_t *mavlink_log_pub, const bool report_fail);
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
#include <HealthFlags.h>
|
||||
#include <math.h>
|
||||
#include <px4_defines.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
#include <lib/sensor_calibration/Utilities.hpp>
|
||||
#include <lib/systemlib/mavlink_log.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/sensor_accel.h>
|
||||
#include <uORB/topics/subsystem_info.h>
|
||||
@@ -65,7 +66,7 @@ bool PreFlightCheck::accelerometerCheck(orb_advert_t *mavlink_log_pub, vehicle_s
|
||||
|
||||
device_id = accel.get().device_id;
|
||||
|
||||
calibration_valid = check_calibration("CAL_ACC%u_ID", device_id);
|
||||
calibration_valid = (calibration::FindCalibrationIndex("ACC", device_id) >= 0);
|
||||
|
||||
if (!calibration_valid) {
|
||||
if (report_fail) {
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <HealthFlags.h>
|
||||
#include <px4_defines.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
#include <lib/sensor_calibration/Utilities.hpp>
|
||||
#include <lib/systemlib/mavlink_log.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/sensor_gyro.h>
|
||||
#include <uORB/topics/subsystem_info.h>
|
||||
@@ -64,7 +65,7 @@ bool PreFlightCheck::gyroCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &
|
||||
|
||||
device_id = gyro.get().device_id;
|
||||
|
||||
calibration_valid = check_calibration("CAL_GYRO%u_ID", device_id);
|
||||
calibration_valid = (calibration::FindCalibrationIndex("GYRO", device_id) >= 0);
|
||||
|
||||
if (!calibration_valid) {
|
||||
if (report_fail) {
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <HealthFlags.h>
|
||||
#include <px4_defines.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
#include <lib/sensor_calibration/Utilities.hpp>
|
||||
#include <lib/systemlib/mavlink_log.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/sensor_mag.h>
|
||||
#include <uORB/topics/subsystem_info.h>
|
||||
@@ -64,7 +65,7 @@ bool PreFlightCheck::magnetometerCheck(orb_advert_t *mavlink_log_pub, vehicle_st
|
||||
|
||||
device_id = magnetometer.get().device_id;
|
||||
|
||||
calibration_valid = check_calibration("CAL_MAG%u_ID", device_id);
|
||||
calibration_valid = (calibration::FindCalibrationIndex("MAG", device_id) >= 0);
|
||||
|
||||
if (!calibration_valid) {
|
||||
if (report_fail) {
|
||||
|
||||
Reference in New Issue
Block a user