@@ -11570,12 +11570,14 @@ def test_replay_body_odom_bit(self):
1157011570 def GPSBlendingLog(self):
1157111571 '''Test GPS Blending'''
1157211572 '''ensure we get dataflash log messages for blended instance'''
11573+
1157311574 # configure:
1157411575 self.set_parameters({
1157511576 "GPS2_TYPE": 1,
1157611577 "SIM_GPS2_TYPE": 1,
1157711578 "SIM_GPS2_ENABLE": 1,
1157811579 "GPS_AUTO_SWITCH": 2,
11580+ "GPS3_TYPE": 27,
1157911581 })
1158011582 self.reboot_sitl()
1158111583
@@ -11621,6 +11623,48 @@ def GPSBlendingLog(self):
1162111623 if not seen_primary_change:
1162211624 raise NotAchievedException("Did not see primary change")
1162311625
11626+ # ensure we're seeing the second GPS:
11627+ tstart = self.get_sim_time()
11628+ while True:
11629+ if self.get_sim_time_cached() - tstart > 60:
11630+ raise NotAchievedException("Did not get good GPS2_RAW message")
11631+ m = self.assert_receive_message('GPS2_RAW', verbose=True)
11632+ if m.lat == 0:
11633+ continue
11634+ break
11635+
11636+ # create a log we can expect blended data to appear in:
11637+ self.change_mode('LOITER')
11638+ self.wait_ready_to_arm()
11639+ self.arm_vehicle()
11640+ self.delay_sim_time(5)
11641+ self.disarm_vehicle()
11642+
11643+ # inspect generated log for messages:
11644+ dfreader = self.dfreader_for_current_onboard_log()
11645+ wanted = set([0, 1, 2])
11646+ seen_primary_change = False
11647+ while True:
11648+ m = dfreader.recv_match(type=["GPS", "EV"]) # disarmed
11649+ if m is None:
11650+ break
11651+ mtype = m.get_type()
11652+ if mtype == 'GPS':
11653+ try:
11654+ wanted.remove(m.I)
11655+ except KeyError:
11656+ continue
11657+ elif mtype == 'EV':
11658+ if m.Id == 67: # GPS_PRIMARY_CHANGED
11659+ seen_primary_change = True
11660+ if len(wanted) == 0 and seen_primary_change:
11661+ break
11662+
11663+ if len(wanted):
11664+ raise NotAchievedException("Did not get all three GPS types")
11665+ if not seen_primary_change:
11666+ raise NotAchievedException("Did not see primary change")
11667+
1162411668 def GPSBlending(self):
1162511669 '''Test GPS Blending'''
1162611670 '''ensure we get dataflash log messages for blended instance'''
@@ -16265,6 +16309,81 @@ def ScriptParamRegistration(self):
1626516309 if pname in all_params:
1626616310 raise ValueError(f"{pname} in fetched-all-parameters when it should have gone away")
1626716311
16312+ def ManyGPS(self):
16313+ '''check many gps support'''
16314+ self.set_parameters({
16315+ 'GPS2_TYPE': 1,
16316+ 'GPS3_TYPE': 1,
16317+ 'GPS4_TYPE': 1,
16318+
16319+ 'SIM_GPS1_NUMSATS': 21,
16320+
16321+ 'SIM_GPS2_ENABLE': 1,
16322+ 'SIM_GPS2_NUMSATS': 22,
16323+
16324+ 'SIM_GPS3_TYPE': 1,
16325+ 'SIM_GPS3_ENABLE': 1,
16326+ 'SIM_GPS3_NUMSATS': 23,
16327+
16328+ 'SIM_GPS4_TYPE': 1,
16329+ 'SIM_GPS4_ENABLE': 1,
16330+ 'SIM_GPS4_NUMSATS': 24,
16331+
16332+ 'SERIAL5_PROTOCOL': 5,
16333+ 'SERIAL6_PROTOCOL': 5,
16334+ })
16335+ self.customise_SITL_commandline([
16336+ "--serial5=sim:gps:3:",
16337+ "--serial6=sim:gps:4:",
16338+ ])
16339+
16340+ tstart = self.get_sim_time()
16341+ i = 0
16342+ while i < 4:
16343+ if self.get_sim_time_cached() - tstart > 200:
16344+ raise NotAchievedException(f"Did not get GNSS message {i}")
16345+ m = self.assert_receive_message('GNSS')
16346+ if m.id != i:
16347+ continue
16348+ self.dump_message_verbose(m)
16349+ self.assert_message_field_values(m, {
16350+ 'satellites_visible': 20 + i + 1,
16351+ 'yaw': 0,
16352+ })
16353+ i += 1
16354+
16355+ self.start_subtest("GPS-for-yaw")
16356+ self.set_parameters({
16357+ "GPS3_TYPE": 17, # RTK base
16358+ "GPS3_POS_X": -0.5,
16359+ "GPS3_POS_Y": -0.5,
16360+ "SIM_GPS3_HDG": 4,
16361+ "SIM_GPS3_POS_X": -0.5,
16362+ "SIM_GPS3_POS_Y": -0.5,
16363+
16364+ "GPS4_TYPE": 18, # RTK rover
16365+ "SIM_GPS4_HDG": 2,
16366+ "GPS4_POS_X": 0.5,
16367+ "GPS4_POS_Y": 0.5,
16368+ "SIM_GPS4_POS_X": 0.5,
16369+ "SIM_GPS4_POS_Y": 0.5,
16370+ })
16371+ self.reboot_sitl()
16372+
16373+ tstart = self.get_sim_time()
16374+ while True:
16375+ if self.get_sim_time_cached() - tstart > 120:
16376+ raise NotAchievedException("Did not get GNSS yaw")
16377+
16378+ m = self.assert_receive_message('GNSS', verbose=True, timeout=120)
16379+
16380+ # if m.id != 4:
16381+ # continue
16382+
16383+ if m.yaw != 0 and m.yaw != 65535:
16384+ self.progress(f"GPS{m.id+1} provided yaw")
16385+ break
16386+
1626816387 def tests2b(self): # this block currently around 9.5mins here
1626916388 '''return list of all tests'''
1627016389 ret = ([
@@ -16368,6 +16487,7 @@ def tests2b(self): # this block currently around 9.5mins here
1636816487 self.SafetySwitch,
1636916488 self.RCProtocolFailsafe,
1637016489 self.BrakeZ,
16490+ self.ManyGPS,
1637116491 self.MAV_CMD_DO_FLIGHTTERMINATION,
1637216492 self.MAV_CMD_DO_LAND_START,
1637316493 self.MAV_CMD_DO_SET_GLOBAL_ORIGIN,
0 commit comments