File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -367,8 +367,18 @@ bool AP_Arming_Copter::gps_checks(bool display_failure)
367367 fence_requires_gps = (copter.fence .get_enabled_fences () & (AC_FENCE_TYPE_CIRCLE | AC_FENCE_TYPE_POLYGON)) > 0 ;
368368#endif
369369
370+ // check if we only require position and the EKF thinks we are ok
371+ const auto &ahrs = AP::ahrs ();
372+ char failure_msg[100 ] = {};
373+ if (copter.flightmode ->requires_position () && copter.position_ok () && !ahrs.pre_arm_check (true , failure_msg, sizeof (failure_msg))) {
374+ check_failed (display_failure, " AHRS: %s" , failure_msg);
375+ return false ;
376+ }
377+
370378 // check if flight mode requires GPS
371- bool mode_requires_gps = copter.flightmode ->requires_GPS () || fence_requires_gps || (copter.simple_mode == Copter::SimpleMode::SUPERSIMPLE);
379+ bool mode_requires_gps = copter.flightmode ->requires_GPS () || fence_requires_gps || (copter.simple_mode == Copter::SimpleMode::SUPERSIMPLE)
380+ // skip GPS checks if we only require position and our position is ok
381+ || (copter.flightmode ->requires_position () && !copter.position_ok ());
372382
373383 // call parent gps checks
374384 if (mode_requires_gps) {
@@ -647,7 +657,7 @@ bool AP_Arming_Copter::arm_checks(AP_Arming::Method method)
647657 return false ;
648658 }
649659
650- if (!ahrs.ensure_origin_is_set ()) {
660+ if (copter. flightmode -> requires_position () && !ahrs.ensure_origin_is_set ()) {
651661 check_failed (true , " No origin set" );
652662 return false ;
653663 }
Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ class Mode {
126126 virtual void exit () {};
127127 virtual void run () = 0;
128128 virtual bool requires_GPS () const = 0;
129+ virtual bool requires_position () const { return requires_GPS (); }
129130 virtual bool has_manual_throttle () const = 0;
130131 virtual bool allows_arming (AP_Arming::Method method) const = 0;
131132 virtual bool is_autopilot () const = 0;
@@ -991,6 +992,7 @@ class ModeFlowHold : public Mode {
991992 void run (void ) override ;
992993
993994 bool requires_GPS () const override { return false ; }
995+ bool requires_position () const override { return true ; }
994996 bool has_manual_throttle () const override { return false ; }
995997 bool allows_arming (AP_Arming::Method method) const override { return true ; };
996998 bool is_autopilot () const override { return false ; }
@@ -1324,7 +1326,8 @@ class ModeLoiter : public Mode {
13241326 bool init (bool ignore_checks) override ;
13251327 void run () override ;
13261328
1327- bool requires_GPS () const override { return true ; }
1329+ bool requires_GPS () const override { return false ; }
1330+ bool requires_position () const override { return true ; }
13281331 bool has_manual_throttle () const override { return false ; }
13291332 bool allows_arming (AP_Arming::Method method) const override { return true ; };
13301333 bool is_autopilot () const override { return false ; }
You can’t perform that action at this time.
0 commit comments