mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 06:23:33 +08:00
refactor vehicle_status_flags: rename to failsafe_flags
This commit is contained in:
@@ -178,7 +178,7 @@ void Report::reset()
|
||||
void Report::prepare(uint8_t vehicle_type)
|
||||
{
|
||||
// Get mode requirements before running any checks (in particular the mode checks require them)
|
||||
mode_util::getModeRequirements(vehicle_type, _status_flags);
|
||||
mode_util::getModeRequirements(vehicle_type, _failsafe_flags);
|
||||
}
|
||||
|
||||
NavModes Report::getModeGroup(uint8_t nav_state) const
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <uORB/topics/health_report.h>
|
||||
#include <uORB/topics/vehicle_status.h>
|
||||
#include <uORB/topics/vehicle_status_flags.h>
|
||||
#include <uORB/topics/failsafe_flags.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -188,11 +188,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
Report(vehicle_status_flags_s &status_flags, hrt_abstime min_reporting_interval = 2_s)
|
||||
: _min_reporting_interval(min_reporting_interval), _status_flags(status_flags) { }
|
||||
Report(failsafe_flags_s &failsafe_flags, hrt_abstime min_reporting_interval = 2_s)
|
||||
: _min_reporting_interval(min_reporting_interval), _failsafe_flags(failsafe_flags) { }
|
||||
~Report() = default;
|
||||
|
||||
vehicle_status_flags_s &failsafeFlags() { return _status_flags; }
|
||||
failsafe_flags_s &failsafeFlags() { return _failsafe_flags; }
|
||||
|
||||
orb_advert_t *mavlink_log_pub() { return _mavlink_log_pub; }
|
||||
|
||||
@@ -255,7 +255,7 @@ public:
|
||||
const HealthResults &healthResults() const { return _results[_current_result].health; }
|
||||
const ArmingCheckResults &armingCheckResults() const { return _results[_current_result].arming_checks; }
|
||||
|
||||
bool modePreventsArming(uint8_t nav_state) const { return _status_flags.mode_req_prevent_arming & (1u << nav_state); }
|
||||
bool modePreventsArming(uint8_t nav_state) const { return _failsafe_flags.mode_req_prevent_arming & (1u << nav_state); }
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -346,7 +346,7 @@ private:
|
||||
Results _results[2]; ///< Previous and current results to check for changes
|
||||
int _current_result{0};
|
||||
|
||||
vehicle_status_flags_s &_status_flags;
|
||||
failsafe_flags_s &_failsafe_flags;
|
||||
|
||||
orb_advert_t *_mavlink_log_pub{nullptr}; ///< mavlink log publication for legacy reporting
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/topics/health_report.h>
|
||||
#include <uORB/topics/vehicle_status_flags.h>
|
||||
#include <uORB/topics/failsafe_flags.h>
|
||||
|
||||
#include "checks/accelerometerCheck.hpp"
|
||||
#include "checks/airspeedCheck.hpp"
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
*/
|
||||
bool modePreventsArming(uint8_t nav_state) const { return _reporter.modePreventsArming(nav_state); }
|
||||
|
||||
const vehicle_status_flags_s &failsafeFlags() const { return _failsafe_flags; }
|
||||
const failsafe_flags_s &failsafeFlags() const { return _failsafe_flags; }
|
||||
|
||||
protected:
|
||||
void updateParams() override;
|
||||
@@ -107,10 +107,10 @@ private:
|
||||
Report _reporter;
|
||||
orb_advert_t _mavlink_log_pub{nullptr};
|
||||
|
||||
vehicle_status_flags_s _failsafe_flags{};
|
||||
failsafe_flags_s _failsafe_flags{};
|
||||
|
||||
uORB::Publication<health_report_s> _health_report_pub{ORB_ID(health_report)};
|
||||
uORB::Publication<vehicle_status_flags_s> _failsafe_flags_pub{ORB_ID(vehicle_status_flags)};
|
||||
uORB::Publication<failsafe_flags_s> _failsafe_flags_pub{ORB_ID(failsafe_flags)};
|
||||
|
||||
// all checks
|
||||
AccelerometerChecks _accelerometer_checks;
|
||||
|
||||
@@ -63,8 +63,8 @@ public:
|
||||
|
||||
TEST_F(ReporterTest, basic_no_checks)
|
||||
{
|
||||
vehicle_status_flags_s status_flags{};
|
||||
Report reporter{status_flags, 0_s};
|
||||
failsafe_flags_s failsafe_flags{};
|
||||
Report reporter{failsafe_flags, 0_s};
|
||||
ASSERT_FALSE(reporter.canArm(vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION));
|
||||
|
||||
reporter.reset();
|
||||
@@ -83,8 +83,8 @@ TEST_F(ReporterTest, basic_no_checks)
|
||||
|
||||
TEST_F(ReporterTest, basic_fail_all_modes)
|
||||
{
|
||||
vehicle_status_flags_s status_flags{};
|
||||
Report reporter{status_flags, 0_s};
|
||||
failsafe_flags_s failsafe_flags{};
|
||||
Report reporter{failsafe_flags, 0_s};
|
||||
|
||||
// ensure arming is always denied with a NavModes::All failure
|
||||
for (uint8_t nav_state = 0; nav_state < vehicle_status_s::NAVIGATION_STATE_MAX; ++nav_state) {
|
||||
@@ -101,8 +101,8 @@ TEST_F(ReporterTest, basic_fail_all_modes)
|
||||
|
||||
TEST_F(ReporterTest, arming_checks_mode_category)
|
||||
{
|
||||
vehicle_status_flags_s status_flags{};
|
||||
Report reporter{status_flags, 0_s};
|
||||
failsafe_flags_s failsafe_flags{};
|
||||
Report reporter{failsafe_flags, 0_s};
|
||||
|
||||
// arming must still be possible for non-relevant failures
|
||||
reporter.reset();
|
||||
@@ -130,8 +130,8 @@ TEST_F(ReporterTest, arming_checks_mode_category)
|
||||
|
||||
TEST_F(ReporterTest, arming_checks_mode_category2)
|
||||
{
|
||||
vehicle_status_flags_s status_flags{};
|
||||
Report reporter{status_flags, 0_s};
|
||||
failsafe_flags_s failsafe_flags{};
|
||||
Report reporter{failsafe_flags, 0_s};
|
||||
|
||||
// A matching mode category must deny arming
|
||||
reporter.reset();
|
||||
@@ -153,8 +153,8 @@ TEST_F(ReporterTest, arming_checks_mode_category2)
|
||||
|
||||
TEST_F(ReporterTest, reporting)
|
||||
{
|
||||
vehicle_status_flags_s status_flags{};
|
||||
Report reporter{status_flags, 0_s};
|
||||
failsafe_flags_s failsafe_flags{};
|
||||
Report reporter{failsafe_flags, 0_s};
|
||||
|
||||
uORB::Subscription event_sub{ORB_ID(event)};
|
||||
event_sub.subscribe();
|
||||
@@ -247,8 +247,8 @@ TEST_F(ReporterTest, reporting)
|
||||
|
||||
TEST_F(ReporterTest, reporting_multiple)
|
||||
{
|
||||
vehicle_status_flags_s status_flags{};
|
||||
Report reporter{status_flags, 0_s};
|
||||
failsafe_flags_s failsafe_flags{};
|
||||
Report reporter{failsafe_flags, 0_s};
|
||||
|
||||
uORB::Subscription event_sub{ORB_ID(event)};
|
||||
event_sub.subscribe();
|
||||
|
||||
@@ -670,7 +670,7 @@ void EstimatorChecks::gpsNoLongerValid(const Context &context, Report &reporter)
|
||||
|
||||
void EstimatorChecks::setModeRequirementFlags(const Context &context, bool pre_flt_fail_innov_heading,
|
||||
bool pre_flt_fail_innov_vel_horiz,
|
||||
const vehicle_local_position_s &lpos, const sensor_gps_s &vehicle_gps_position, vehicle_status_flags_s &failsafe_flags)
|
||||
const vehicle_local_position_s &lpos, const sensor_gps_s &vehicle_gps_position, failsafe_flags_s &failsafe_flags)
|
||||
{
|
||||
// The following flags correspond to mode requirements, and are reported in the corresponding mode checks
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ private:
|
||||
void gpsNoLongerValid(const Context &context, Report &reporter) const;
|
||||
void setModeRequirementFlags(const Context &context, bool pre_flt_fail_innov_heading, bool pre_flt_fail_innov_vel_horiz,
|
||||
const vehicle_local_position_s &lpos, const sensor_gps_s &vehicle_gps_position,
|
||||
vehicle_status_flags_s &failsafe_flags);
|
||||
failsafe_flags_s &failsafe_flags);
|
||||
|
||||
bool checkPosVelValidity(const hrt_abstime &now, const bool data_valid, const float data_accuracy,
|
||||
const float required_accuracy,
|
||||
|
||||
Reference in New Issue
Block a user