62 if (time_since_boot < 2_s) {
64 reportFailures =
false;
67 const bool hil_enabled = (status.
hil_state == vehicle_status_s::HIL_STATE_ON);
69 bool checkSensors = !hil_enabled;
70 const bool checkRC = (status.
rc_input_mode == vehicle_status_s::RC_IN_MODE_DEFAULT);
71 const bool checkDynamic = !hil_enabled;
73 const bool checkFailureDetector =
true;
75 bool checkAirspeed =
false;
91 bool prime_found =
false;
93 int32_t prime_id = -1;
96 int32_t sys_has_mag = 1;
99 bool mag_fail_reported =
false;
104 const bool report_fail = (reportFailures && !failed && !mag_fail_reported);
108 if (magnometerCheck(mavlink_log_pub, status, i, !required, device_id, report_fail)) {
110 if ((prime_id > 0) && (device_id == prime_id)) {
117 mag_fail_reported =
true;
122 if (sys_has_mag == 1) {
125 if (reportFailures && !failed) {
129 set_health_flags(subsystem_info_s::SUBSYSTEM_TYPE_MAG,
false,
true,
false, status);
134 if (!magConsistencyCheck(mavlink_log_pub, status, (reportFailures && !failed))) {
142 bool prime_found =
false;
143 int32_t prime_id = -1;
146 bool accel_fail_reported =
false;
151 const bool report_fail = (reportFailures && !failed && !accel_fail_reported);
155 if (accelerometerCheck(mavlink_log_pub, status, i, !required, checkDynamic, device_id, report_fail)) {
157 if ((prime_id > 0) && (device_id == prime_id)) {
164 accel_fail_reported =
true;
171 if (reportFailures && !failed) {
175 set_health_flags(subsystem_info_s::SUBSYSTEM_TYPE_ACC,
false,
true,
false, status);
182 bool prime_found =
false;
183 int32_t prime_id = -1;
186 bool gyro_fail_reported =
false;
191 const bool report_fail = (reportFailures && !failed && !gyro_fail_reported);
195 if (gyroCheck(mavlink_log_pub, status, i, !required, device_id, report_fail)) {
197 if ((prime_id > 0) && (device_id == prime_id)) {
204 gyro_fail_reported =
true;
211 if (reportFailures && !failed) {
215 set_health_flags(subsystem_info_s::SUBSYSTEM_TYPE_GYRO,
false,
true,
false, status);
224 int32_t prime_id = -1;
227 int32_t sys_has_baro = 1;
230 bool baro_fail_reported =
false;
235 const bool report_fail = (reportFailures && !failed && !baro_fail_reported);
239 if (baroCheck(mavlink_log_pub, status, i, !required, device_id, report_fail)) {
240 if ((prime_id > 0) && (device_id == prime_id)) {
247 baro_fail_reported =
true;
267 if (!imuConsistencyCheck(mavlink_log_pub, status, (reportFailures && !failed))) {
274 int32_t optional = 0;
277 if (!airspeedCheck(mavlink_log_pub, status, (
bool)optional, reportFailures && !failed, prearm) && !(
bool)optional) {
284 if (rcCalibrationCheck(mavlink_log_pub, reportFailures && !failed, status.
is_vtol) !=
OK) {
285 if (reportFailures) {
304 if (!powerCheck(mavlink_log_pub, status, (reportFailures && !failed), prearm)) {
311 int32_t estimator_type = -1;
313 if (status.
vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING && !status.
is_vtol) {
321 if (estimator_type == 2) {
323 bool report_ekf_fail = (time_since_boot > 10_s);
325 if (!ekf2Check(mavlink_log_pub, status,
false, reportFailures && report_ekf_fail && !failed, checkGNSS)) {
331 if (checkFailureDetector) {
332 if (!failureDetectorCheck(mavlink_log_pub, status, (reportFailures && !failed), prearm)) {
343 bool calibration_found =
false;
349 while (!calibration_found) {
350 sprintf(s, param_template, instance);
359 int32_t calibration_devid = -1;
361 if (
param_get(parm, &calibration_devid) == PX4_OK) {
364 if (device_id == calibration_devid) {
365 calibration_found =
true;
373 return calibration_found;
__EXPORT param_t param_find_no_notification(const char *name)
Look up a parameter by name.
#define VEHICLE_TYPE_FIXED_WING
#define PARAM_INVALID
Handle returned when a parameter cannot be found.
static orb_advert_t * mavlink_log_pub
#define mavlink_log_critical(_pub, _text,...)
Send a mavlink critical message and print to console.
static constexpr unsigned max_mandatory_accel_count
static constexpr unsigned max_optional_gyro_count
static struct vehicle_status_s status
bool condition_power_input_valid
__EXPORT int param_get(param_t param, void *val)
Copy the value of a parameter.
static struct vehicle_status_flags_s status_flags
bool circuit_breaker_engaged_power_check
static int32_t device_id[max_accel_sens]
High-resolution timer with callouts and timekeeping.
void set_health_flags(uint64_t subsystem_type, bool present, bool enabled, bool ok, vehicle_status_s &status)
Global flash based parameter store.
static bool preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status, vehicle_status_flags_s &status_flags, const bool checkGNSS, bool reportFailures, const bool prearm, const hrt_abstime &time_since_boot)
Runs a preflight check on all sensors to see if they are properly calibrated and healthy.
static constexpr unsigned max_mandatory_baro_count
bool rc_signal_found_once
bool rc_calibration_valid
static constexpr unsigned max_optional_baro_count
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
__EXPORT param_t param_find(const char *name)
Look up a parameter by name.
Contains helper functions to efficiently set the system health flags from commander and preflight che...
static constexpr unsigned max_mandatory_mag_count
bool condition_calibration_enabled
static bool check_calibration(const char *param_template, const int32_t device_id)
static constexpr unsigned max_optional_accel_count
bool circuit_breaker_engaged_airspd_check
static constexpr unsigned max_mandatory_gyro_count
static constexpr unsigned max_optional_mag_count
Check if flight is safely possible if not prevent it and inform the user.
bool condition_system_hotplug_timeout
uint32_t param_t
Parameter handle.