@@ -2768,6 +2768,50 @@ def CopterMission(self):
2768
2768
2769
2769
self .progress ("Auto mission completed: passed!" )
2770
2770
2771
+ # def loc_from_received_GLOBAL_POSITION_INT(self):
2772
+ # '''return a mavutil.location created from a received GLOBAL_POSITION_INT'''
2773
+ # x = mavutil.location(m.lat/1e7, m.lon/1e7, m.alt/1e3, 0)
2774
+
2775
+ def set_origin (self , loc , timeout = 60 ):
2776
+ '''set the GPS global origin to loc'''
2777
+ tstart = self .get_sim_time ()
2778
+ while True :
2779
+ if self .get_sim_time_cached () - tstart > timeout :
2780
+ raise AutoTestTimeoutException ("Did not get non-zero lat" )
2781
+ target_system = 1
2782
+ self .mav .mav .set_gps_global_origin_send (
2783
+ target_system ,
2784
+ int (loc .lat * 1e7 ),
2785
+ int (loc .lng * 1e7 ),
2786
+ int (loc .alt * 1e3 )
2787
+ )
2788
+ gpi = self .assert_receive_message ('GLOBAL_POSITION_INT' )
2789
+ self .progress ("gpi=%s" % str (gpi ))
2790
+ if gpi .lat != 0 :
2791
+ break
2792
+
2793
+ def FarOrigin (self ):
2794
+ '''fly a mission far from the vehicle origin'''
2795
+ # Fly mission #1
2796
+ self .set_parameters ({
2797
+ "SIM_GPS_DISABLE" : 1 ,
2798
+ })
2799
+ self .reboot_sitl ()
2800
+ nz = mavutil .location (- 43.730171 , 169.983118 , 1466.3 , 270 )
2801
+ self .set_origin (nz )
2802
+ self .set_parameters ({
2803
+ "SIM_GPS_DISABLE" : 0 ,
2804
+ })
2805
+ self .progress ("# Load copter_mission" )
2806
+ # load the waypoint count
2807
+ num_wp = self .load_mission ("copter_mission.txt" , strict = False )
2808
+ if not num_wp :
2809
+ raise NotAchievedException ("load copter_mission failed" )
2810
+
2811
+ self .fly_loaded_mission (num_wp )
2812
+
2813
+ self .progress ("Auto mission completed: passed!" )
2814
+
2771
2815
def fly_loaded_mission (self , num_wp ):
2772
2816
'''fly mission loaded on vehicle. FIXME: get num_wp from vehicle'''
2773
2817
self .progress ("test: Fly a mission from 1 to %u" % num_wp )
@@ -11388,6 +11432,7 @@ def tests2b(self): # this block currently around 9.5mins here
11388
11432
self .CompassMot ,
11389
11433
self .AutoRTL ,
11390
11434
self .EK3_OGN_HGT_MASK ,
11435
+ self .FarOrigin ,
11391
11436
])
11392
11437
return ret
11393
11438
0 commit comments