@@ -43,7 +43,7 @@ def __init__(self, mpstate):
43
43
44
44
self .mpstate = mpstate
45
45
46
- # GUI
46
+ # Settings
47
47
# TODO: provide args to set RTSP server location
48
48
# localhost simulation
49
49
rtsp_url = "rtsp://127.0.0.1:8554/camera"
@@ -57,6 +57,9 @@ def __init__(self, mpstate):
57
57
# SIYI A8 camera
58
58
# rtsp_url = "rtsp://192.168.144.25:8554/main.264"
59
59
60
+ self ._camera_tracking_image_status_rate = 50 # Hz
61
+
62
+ # GUI
60
63
self .camera_view = CameraView (self .mpstate , "Camera Tracking" , rtsp_url )
61
64
62
65
# NOTE: unused except for status
@@ -76,12 +79,6 @@ def __init__(self, mpstate):
76
79
self ._do_request_camera_information = True
77
80
self ._do_request_camera_tracking_image_status = True
78
81
79
- # control update rate to GUI
80
- self ._msg_list = []
81
- self ._fps = 30.0
82
- self ._last_send = 0.0
83
- self ._send_delay = (1.0 / self ._fps ) * 0.9
84
-
85
82
# commands
86
83
self .add_command ("camtrack" , self .cmd_camtrack , "camera tracking" )
87
84
@@ -155,7 +152,7 @@ def mavlink_packet(self, msg):
155
152
elif mtype == "CAMERA_TRACKING_IMAGE_STATUS" :
156
153
self .handle_camera_tracking_image_status (msg )
157
154
158
- # TODO: NOTE: disabled
155
+ # TODO: NOTE: ack checks are disabled
159
156
# check command_ack
160
157
elif False : # mtype == "COMMAND_ACK":
161
158
if msg .command == mavutil .mavlink .MAV_CMD_CAMERA_TRACK_POINT :
@@ -215,7 +212,7 @@ def mavlink_packet(self, msg):
215
212
elif msg .command == mavutil .mavlink .MAV_CMD_SET_MESSAGE_INTERVAL :
216
213
print ("Got COMMAND_ACK: MAV_CMD_SET_MESSAGE_INTERVAL" )
217
214
218
- # TODO: NOTE: disabled
215
+ # TODO: NOTE: command processing disabled
219
216
# check command_long
220
217
elif False : # mtype == "COMMAND_LONG":
221
218
# TODO: check target_system is for offboard control
@@ -293,15 +290,7 @@ def check_events(self):
293
290
# self.needs_unloading = True
294
291
295
292
def send_messages (self ):
296
- """Send message list via pipe to GUI at desired update rate"""
297
- if (time .time () - self ._last_send ) > self ._send_delay :
298
- # pipe data to GUI
299
- # TODO: check interface in view for pipe updates
300
- # self.camera_view.parent_pipe_send.send(self._msg_list)
301
- # reset counters etc
302
- self ._msg_list = []
303
- self ._last_send = time .time ()
304
-
293
+ """Send messages"""
305
294
# TODO: implement camera and gimbal discovery correctly
306
295
# Discovery - most of these requests are handled in the FC
307
296
# by GCS_MAVLINK::try_send_message
@@ -335,9 +324,10 @@ def send_messages(self):
335
324
self ._do_request_camera_information = False
336
325
337
326
if self ._do_request_camera_tracking_image_status :
327
+ interval_us = int (1e6 / self ._camera_tracking_image_status_rate )
338
328
self .send_set_message_interval_message (
339
329
mavutil .mavlink .MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS ,
340
- 1000 * 50 , # 20Hz
330
+ interval_us , # requested interval in microseconds
341
331
response_target = 1 , # flight-stack default
342
332
)
343
333
self ._do_request_camera_tracking_image_status = False
@@ -402,12 +392,9 @@ def idle_task(self):
402
392
403
393
def unload (self ):
404
394
"""Close the GUI and unload module"""
405
-
406
- # close the GUI
407
395
self .camera_view .close ()
408
396
409
397
410
398
def init (mpstate ):
411
399
"""Initialise module"""
412
-
413
400
return CamTrackModule (mpstate )
0 commit comments