@@ -7573,19 +7573,6 @@ def AC_Avoidance_Fence(self):
7573
7573
self .set_parameter ("FENCE_ENABLE" , 1 )
7574
7574
self .check_avoidance_corners ()
7575
7575
7576
- def global_position_int_for_location (self , loc , time_boot , heading = 0 ):
7577
- return self .mav .mav .global_position_int_encode (
7578
- int (time_boot * 1000 ), # time_boot_ms
7579
- int (loc .lat * 1e7 ),
7580
- int (loc .lng * 1e7 ),
7581
- int (loc .alt * 1000 ), # alt in mm
7582
- 20 , # relative alt - urp.
7583
- vx = 0 ,
7584
- vy = 0 ,
7585
- vz = 0 ,
7586
- hdg = heading
7587
- )
7588
-
7589
7576
def ModeFollow (self ):
7590
7577
'''Fly follow mode'''
7591
7578
foll_ofs_x = 30 # metres
@@ -7616,16 +7603,26 @@ def ModeFollow(self):
7616
7603
(expected_loc .lat , expected_loc .lng ))
7617
7604
self .progress ("expected_loc: %s" % str (expected_loc ))
7618
7605
7606
+ origin = self .poll_message ('GPS_GLOBAL_ORIGIN' )
7607
+
7619
7608
last_sent = 0
7620
7609
tstart = self .get_sim_time ()
7621
7610
while True :
7622
7611
now = self .get_sim_time_cached ()
7623
7612
if now - tstart > 60 :
7624
7613
raise NotAchievedException ("Did not FOLLOW" )
7625
7614
if now - last_sent > 0.5 :
7626
- gpi = self .global_position_int_for_location (new_loc ,
7627
- now ,
7628
- heading = heading )
7615
+ gpi = self .mav .mav .global_position_int_encode (
7616
+ int (now * 1000 ), # time_boot_ms
7617
+ int (new_loc .lat * 1e7 ),
7618
+ int (new_loc .lng * 1e7 ),
7619
+ int (new_loc .alt * 1000 ), # alt in mm
7620
+ int (new_loc .alt * 1000 - origin .altitude ), # relative alt - urp.
7621
+ vx = 0 ,
7622
+ vy = 0 ,
7623
+ vz = 0 ,
7624
+ hdg = heading
7625
+ )
7629
7626
gpi .pack (self .mav .mav )
7630
7627
self .mav .mav .send (gpi )
7631
7628
self .mav .recv_match (type = 'GLOBAL_POSITION_INT' , blocking = True )
0 commit comments