@@ -3145,6 +3145,56 @@ def set_origin(self, loc, timeout=60):
3145
3145
if gpi.lat != 0:
3146
3146
break
3147
3147
3148
+ def MAV_CMD_DO_SET_GLOBAL_ORIGIN(self):
3149
+ '''test MAV_CMD_DO_SET_GLOBAL_ORIGIN command'''
3150
+ # disable the GPS so we don't get origin that way:
3151
+ # don't run this test if command not available:
3152
+ try:
3153
+ mavutil.mavlink.MAV_CMD_DO_SET_GLOBAL_ORIGIN
3154
+ except AttributeError:
3155
+ return
3156
+
3157
+ self.set_parameters({
3158
+ "SIM_GPS1_ENABLE": 0,
3159
+ "GPS1_TYPE": 0,
3160
+ })
3161
+ self.context_collect('STATUSTEXT')
3162
+ self.reboot_sitl()
3163
+ self.run_cmd_int(
3164
+ mavutil.mavlink.MAV_CMD_DO_SET_GLOBAL_ORIGIN,
3165
+ p5=0,
3166
+ p6=0,
3167
+ p7=0,
3168
+ want_result=mavutil.mavlink.MAV_RESULT_DENIED
3169
+ )
3170
+ self.run_cmd_int(
3171
+ mavutil.mavlink.MAV_CMD_DO_SET_GLOBAL_ORIGIN,
3172
+ p5=0,
3173
+ p6=int(214*1e7),
3174
+ p7=0,
3175
+ want_result=mavutil.mavlink.MAV_RESULT_DENIED
3176
+ )
3177
+ # we must wait until we are using EKF3 as DCM does not allow
3178
+ # set_origin:
3179
+ self.wait_statustext("EKF3 active", check_context=True)
3180
+ origin_lat = -23.322332
3181
+ origin_lng = 123.45678
3182
+ origin_alt = 23.67 # metres
3183
+ self.run_cmd_int(
3184
+ mavutil.mavlink.MAV_CMD_DO_SET_GLOBAL_ORIGIN,
3185
+ p5=int(origin_lat*1e7),
3186
+ p6=int(origin_lng*1e7),
3187
+ p7=origin_alt
3188
+ )
3189
+ ggo = self.poll_message('GPS_GLOBAL_ORIGIN')
3190
+ self.assert_message_field_values(ggo, {
3191
+ "latitude": int(origin_lat*1e7),
3192
+ "longitude": int(origin_lng*1e7),
3193
+ "altitude": int(origin_alt*1000), # m -> mm
3194
+ })
3195
+
3196
+ self.reboot_sitl()
3197
+
3148
3198
def FarOrigin(self):
3149
3199
'''fly a mission far from the vehicle origin'''
3150
3200
# Fly mission #1
@@ -13705,6 +13755,7 @@ def tests2b(self): # this block currently around 9.5mins here
13705
13755
self.BrakeZ,
13706
13756
self.MAV_CMD_DO_FLIGHTTERMINATION,
13707
13757
self.MAV_CMD_DO_LAND_START,
13758
+ self.MAV_CMD_DO_SET_GLOBAL_ORIGIN,
13708
13759
self.MAV_CMD_SET_EKF_SOURCE_SET,
13709
13760
self.MAV_CMD_NAV_TAKEOFF,
13710
13761
self.MAV_CMD_NAV_TAKEOFF_command_int,
0 commit comments