2019-11-05 17:25:59 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
*
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
|
* distribution.
|
|
|
|
|
* 3. Neither the name PX4 nor the names of its contributors may be
|
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
|
* without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @file PreFlightCheck.hpp
|
|
|
|
|
*
|
|
|
|
|
* Check if flight is safely possible
|
|
|
|
|
* if not prevent it and inform the user.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <uORB/topics/safety.h>
|
|
|
|
|
#include <uORB/topics/vehicle_status_flags.h>
|
|
|
|
|
|
|
|
|
|
#include <uORB/topics/vehicle_status.h>
|
|
|
|
|
#include <drivers/drv_hrt.h>
|
|
|
|
|
|
|
|
|
|
class PreFlightCheck
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
PreFlightCheck() = default;
|
|
|
|
|
~PreFlightCheck() = default;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Runs a preflight check on all sensors to see if they are properly calibrated and healthy
|
|
|
|
|
*
|
|
|
|
|
* The function won't fail the test if optional sensors are not found, however,
|
|
|
|
|
* it will fail the test if optional sensors are found but not in working condition.
|
|
|
|
|
*
|
|
|
|
|
* @param mavlink_log_pub
|
|
|
|
|
* Mavlink output orb handle reference for feedback when a sensor fails
|
|
|
|
|
* @param checkMag
|
|
|
|
|
* true if the magneteometer should be checked
|
|
|
|
|
* @param checkAcc
|
|
|
|
|
* true if the accelerometers should be checked
|
|
|
|
|
* @param checkGyro
|
|
|
|
|
* true if the gyroscopes should be checked
|
|
|
|
|
* @param checkBaro
|
|
|
|
|
* true if the barometer should be checked
|
|
|
|
|
* @param checkAirspeed
|
|
|
|
|
* true if the airspeed sensor should be checked
|
|
|
|
|
* @param checkRC
|
|
|
|
|
* true if the Remote Controller should be checked
|
|
|
|
|
* @param checkGNSS
|
|
|
|
|
* true if the GNSS receiver should be checked
|
|
|
|
|
* @param checkPower
|
|
|
|
|
* true if the system power should be checked
|
|
|
|
|
**/
|
|
|
|
|
static bool preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status,
|
2019-12-23 23:38:10 -05:00
|
|
|
vehicle_status_flags_s &status_flags, const bool checkGNSS, bool reportFailures, const bool prearm,
|
|
|
|
|
const hrt_abstime &time_since_boot);
|
2019-11-05 17:25:59 +01:00
|
|
|
|
2019-12-23 23:38:10 -05:00
|
|
|
struct arm_requirements_t {
|
|
|
|
|
bool arm_authorization = false;
|
|
|
|
|
bool esc_check = false;
|
|
|
|
|
bool global_position = false;
|
|
|
|
|
bool mission = false;
|
|
|
|
|
};
|
2019-11-05 17:25:59 +01:00
|
|
|
|
2019-12-23 23:38:10 -05:00
|
|
|
static bool preArmCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_flags_s &status_flags,
|
2020-03-15 23:54:05 +01:00
|
|
|
const safety_s &safety, const arm_requirements_t &arm_requirements, vehicle_status_s &status,
|
2020-03-14 23:01:19 +01:00
|
|
|
bool report_fail = true);
|
2019-11-05 17:25:59 +01:00
|
|
|
|
|
|
|
|
private:
|
2020-04-02 12:46:28 +02:00
|
|
|
static bool magnetometerCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status, const uint8_t instance,
|
|
|
|
|
const bool optional, int32_t &device_id, const bool report_fail);
|
2019-11-05 17:25:59 +01:00
|
|
|
static bool magConsistencyCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status, const bool report_status);
|
|
|
|
|
static bool accelerometerCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status, const uint8_t instance,
|
|
|
|
|
const bool optional, const bool dynamic, int32_t &device_id, const bool report_fail);
|
|
|
|
|
static bool gyroCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status, const uint8_t instance,
|
|
|
|
|
const bool optional, int32_t &device_id, const bool report_fail);
|
|
|
|
|
static bool baroCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status, const uint8_t instance,
|
|
|
|
|
const bool optional, int32_t &device_id, const bool report_fail);
|
|
|
|
|
static bool imuConsistencyCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status, const bool report_status);
|
|
|
|
|
static bool airspeedCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status, const bool optional,
|
|
|
|
|
const bool report_fail, const bool prearm);
|
|
|
|
|
static int rcCalibrationCheck(orb_advert_t *mavlink_log_pub, bool report_fail, bool isVTOL);
|
|
|
|
|
static bool powerCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_s &status, const bool report_fail,
|
|
|
|
|
const bool prearm);
|
|
|
|
|
static bool ekf2Check(orb_advert_t *mavlink_log_pub, vehicle_status_s &vehicle_status, const bool optional,
|
|
|
|
|
const bool report_fail, const bool enforce_gps_required);
|
2020-09-01 14:25:58 -04:00
|
|
|
|
|
|
|
|
static bool ekf2CheckStates(orb_advert_t *mavlink_log_pub, const bool report_fail);
|
|
|
|
|
|
2019-11-05 17:25:59 +01:00
|
|
|
static bool failureDetectorCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_s &status, const bool report_fail,
|
|
|
|
|
const bool prearm);
|
2020-08-13 14:40:29 -04:00
|
|
|
|
2020-04-08 15:28:05 +02:00
|
|
|
static bool manualControlCheck(orb_advert_t *mavlink_log_pub, const bool report_fail);
|
2020-04-15 21:20:42 +02:00
|
|
|
static bool airframeCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_s &status);
|
2020-04-02 10:06:52 +02:00
|
|
|
static bool cpuResourceCheck(orb_advert_t *mavlink_log_pub, const bool report_fail);
|
2019-11-05 17:25:59 +01:00
|
|
|
};
|