Skip to content

Commit 55a6f23

Browse files
committed
autotest: add test for tracker pointing at a vehicle
Feed AUTO mode a vehicle position at a series of bearings from the tracker and check it points at each one and holds there. The vehicle reports the tracker's own pressure so the tracker should hold zero pitch throughout.
1 parent 22c950d commit 55a6f23

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

‎Tools/autotest/antennatracker.py‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,59 @@ def ServoRangeLimits(self):
207207
if not 44 < pitch < 46:
208208
raise NotAchievedException(f"Tracker pitch {pitch:.1f} not held at limit")
209209

210+
def Tracking(self):
211+
'''check the tracker points at a vehicle sending its position'''
212+
self.change_mode("AUTO")
213+
self.wait_ready_to_arm()
214+
215+
m = self.assert_receive_message('GLOBAL_POSITION_INT')
216+
tracker_loc = Location(m.lat * 1.0e-7, m.lon * 1.0e-7, m.alt * 1.0e-3, AltFrame.ABSOLUTE)
217+
# the vehicle reports the tracker's own pressure, so the
218+
# tracker sees no altitude difference and should pitch to zero
219+
m = self.assert_receive_message('SCALED_PRESSURE')
220+
vehicle_press_abs = m.press_abs
221+
vehicle_temperature = m.temperature
222+
223+
vehicle_loc = None
224+
last_sent = 0
225+
226+
def send_vehicle_position(mav, m):
227+
nonlocal last_sent
228+
now = self.get_sim_time_cached()
229+
if vehicle_loc is None or now - last_sent < 0.1:
230+
return
231+
last_sent = now
232+
self.mav.mav.global_position_int_send(
233+
int(now * 1000), # time_boot_ms
234+
int(vehicle_loc.lat * 1e7),
235+
int(vehicle_loc.lng * 1e7),
236+
int(vehicle_loc.get_alt_m(AltFrame.ABSOLUTE) * 1000),
237+
0, # relative_alt
238+
0, # vx
239+
0, # vy
240+
0, # vz
241+
65535 # hdg
242+
)
243+
self.mav.mav.scaled_pressure_send(
244+
int(now * 1000), # time_boot_ms
245+
vehicle_press_abs,
246+
0, # press_diff
247+
vehicle_temperature
248+
)
249+
250+
self.context_push()
251+
self.install_message_hook_context(send_vehicle_position)
252+
253+
# the simulated tracker's yaw range is centred on west and
254+
# spans 170 degrees either way, so keep the vehicle to the west
255+
for (north, east) in (0, -20), (20, -20), (-20, -20), (30, -40), (-30, -40):
256+
desyaw = math.degrees(math.atan2(east, north))
257+
self.start_subtest(f"Vehicle {north}m north {east}m east (bearing {desyaw:.0f})")
258+
vehicle_loc = self.offset_location_ne(tracker_loc, north, east)
259+
self.wait_attitude(despitch=0, desyaw=desyaw, tolerance=2, timeout=120, minimum_duration=5)
260+
261+
self.context_pop()
262+
210263
def MAV_CMD_MISSION_START(self):
211264
'''test MAV_CMD_MISSION_START mavlink command'''
212265
for method in self.run_cmd, self.run_cmd_int:
@@ -336,5 +389,6 @@ def tests(self):
336389
self.StationaryGlobalPositionIntAlt,
337390
self.UndrivenServosHoldPosition,
338391
self.ServoRangeLimits,
392+
self.Tracking,
339393
])
340394
return ret

0 commit comments

Comments
 (0)