@@ -295,6 +295,7 @@ def __init__(self, mpstate):
295
295
MPSetting ('thresh_climit_dis' , int , 20 , range = (10 ,50 )),
296
296
MPSetting ('thresh_volt_dis' , int , 40 , range = (20 ,80 )),
297
297
MPSetting ('thresh_ang_dis' , int , 40 , range = (30 ,4000 )),
298
+ ('stow_on_landing' , bool , True ),
298
299
])
299
300
self .add_completion_function ('(SIYISETTING)' ,
300
301
self .siyi_settings .completion )
@@ -366,6 +367,12 @@ def __init__(self, mpstate):
366
367
self .last_getconfig = time .time ()
367
368
self .click_mode = "Flag"
368
369
370
+ # support for stowing the camera when we start to land:
371
+ self .extended_sys_state_received_time = 0
372
+ self .extended_sys_state_request_time = 0
373
+ self .extended_sys_state_warn_time = 0 # last time we warned about not being able to auto-stow
374
+ self .last_landed_state = None
375
+
369
376
if mp_util .has_wxpython :
370
377
menu = MPMenuSubMenu ('SIYI' ,
371
378
items = [
@@ -1470,6 +1477,14 @@ def mavlink_packet(self, m):
1470
1477
self .show_fov ()
1471
1478
except Exception as ex :
1472
1479
print (traceback .format_exc ())
1480
+ elif mtype == 'EXTENDED_SYS_STATE' :
1481
+ if self .settings .stow_on_landing :
1482
+ self .extended_sys_state_received_time = time .time ()
1483
+ if (m .landed_state == mavutil .mavlink .MAV_LANDED_STATE_LANDING and
1484
+ self .last_landed_state != mavutil .mavlink .MAV_LANDED_STATE_LANDING ):
1485
+ # we've just transition into landing
1486
+ self .cmd_angle ([0 , 0 ])
1487
+ self .last_landed_state = m .landed_state
1473
1488
1474
1489
def receive_thread (self ):
1475
1490
'''thread for receiving UDP packets from SIYI'''
@@ -1510,6 +1525,31 @@ def idle_task(self):
1510
1525
self .check_thermal_events ()
1511
1526
self .therm_capture ()
1512
1527
1528
+ # we need EXTENDED_SYS_STATE to work out if we're landing:
1529
+ if self .settings .stow_on_landing :
1530
+ now = time .time ()
1531
+ delta_t = now - self .extended_sys_state_received_time
1532
+ delta_sent_t = now = self .extended_sys_state_request_time
1533
+ if delta_t > 5 and delta_sent_t > 5 :
1534
+ self .extended_sys_state_request_time = now
1535
+ self .master .mav .command_long_send (
1536
+ 1 , # FIXME, target_system
1537
+ 1 , # FIXME, target_component
1538
+ mavutil .mavlink .MAV_CMD_SET_MESSAGE_INTERVAL ,
1539
+ 0 , # confirmation
1540
+ mavutil .mavlink .MAVLINK_MSG_ID_EXTENDED_SYS_STATE , # p1
1541
+ 1e6 , #p2 interval (microseconds)
1542
+ 0 , #p3 instance
1543
+ 0 ,
1544
+ 0 ,
1545
+ 0 ,
1546
+ 0
1547
+ )
1548
+ delta_warn_t = now - self .extended_sys_state_warn_time
1549
+ if delta_warn_t > 60 :
1550
+ self .extended_sys_state_warn_time = now
1551
+ print ("SIYI: no EXTENDED_SYS_STATE, can't auto-stow" )
1552
+
1513
1553
def show_horizon_lines (self ):
1514
1554
'''show horizon lines'''
1515
1555
if self .rgb_view is None or self .rgb_view .im is None :
0 commit comments