Skip to content

Commit 74f4da4

Browse files
committed
autotest: ModeFollow: correct relative altitude being fed to autopilot
1 parent a6f7b26 commit 74f4da4

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

Tools/autotest/arducopter.py

+13-16
Original file line numberDiff line numberDiff line change
@@ -7573,19 +7573,6 @@ def AC_Avoidance_Fence(self):
75737573
self.set_parameter("FENCE_ENABLE", 1)
75747574
self.check_avoidance_corners()
75757575

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-
75897576
def ModeFollow(self):
75907577
'''Fly follow mode'''
75917578
foll_ofs_x = 30 # metres
@@ -7616,16 +7603,26 @@ def ModeFollow(self):
76167603
(expected_loc.lat, expected_loc.lng))
76177604
self.progress("expected_loc: %s" % str(expected_loc))
76187605

7606+
origin = self.poll_message('GPS_GLOBAL_ORIGIN')
7607+
76197608
last_sent = 0
76207609
tstart = self.get_sim_time()
76217610
while True:
76227611
now = self.get_sim_time_cached()
76237612
if now - tstart > 60:
76247613
raise NotAchievedException("Did not FOLLOW")
76257614
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+
)
76297626
gpi.pack(self.mav.mav)
76307627
self.mav.mav.send(gpi)
76317628
self.mav.recv_match(type='GLOBAL_POSITION_INT', blocking=True)

0 commit comments

Comments
 (0)