Skip to content

Commit 42e5506

Browse files
committed
autotest: add test for MAV_CMD_DO_SET_GLOBAL_ORIGIN
1 parent 5867a3b commit 42e5506

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

Tools/autotest/arducopter.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,6 +3145,56 @@ def set_origin(self, loc, timeout=60):
31453145
if gpi.lat != 0:
31463146
break
31473147

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+
31483198
def FarOrigin(self):
31493199
'''fly a mission far from the vehicle origin'''
31503200
# Fly mission #1
@@ -13705,6 +13755,7 @@ def tests2b(self): # this block currently around 9.5mins here
1370513755
self.BrakeZ,
1370613756
self.MAV_CMD_DO_FLIGHTTERMINATION,
1370713757
self.MAV_CMD_DO_LAND_START,
13758+
self.MAV_CMD_DO_SET_GLOBAL_ORIGIN,
1370813759
self.MAV_CMD_SET_EKF_SOURCE_SET,
1370913760
self.MAV_CMD_NAV_TAKEOFF,
1371013761
self.MAV_CMD_NAV_TAKEOFF_command_int,

0 commit comments

Comments
 (0)