Skip to content

Commit 3432d62

Browse files
committed
camtrack: camera and gimbal component ids should match autopilot
- camera_view: add variable for tracking image status update rate - camera_view: camera and gimbal component ids should match autopilot Signed-off-by: Rhys Mainwaring <[email protected]>
1 parent 8ebb9a4 commit 3432d62

File tree

2 files changed

+17
-38
lines changed

2 files changed

+17
-38
lines changed

MAVProxy/modules/mavproxy_camtrack/__init__.py

+9-22
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, mpstate):
4343

4444
self.mpstate = mpstate
4545

46-
# GUI
46+
# Settings
4747
# TODO: provide args to set RTSP server location
4848
# localhost simulation
4949
rtsp_url = "rtsp://127.0.0.1:8554/camera"
@@ -57,6 +57,9 @@ def __init__(self, mpstate):
5757
# SIYI A8 camera
5858
# rtsp_url = "rtsp://192.168.144.25:8554/main.264"
5959

60+
self._camera_tracking_image_status_rate = 50 # Hz
61+
62+
# GUI
6063
self.camera_view = CameraView(self.mpstate, "Camera Tracking", rtsp_url)
6164

6265
# NOTE: unused except for status
@@ -76,12 +79,6 @@ def __init__(self, mpstate):
7679
self._do_request_camera_information = True
7780
self._do_request_camera_tracking_image_status = True
7881

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-
8582
# commands
8683
self.add_command("camtrack", self.cmd_camtrack, "camera tracking")
8784

@@ -155,7 +152,7 @@ def mavlink_packet(self, msg):
155152
elif mtype == "CAMERA_TRACKING_IMAGE_STATUS":
156153
self.handle_camera_tracking_image_status(msg)
157154

158-
# TODO: NOTE: disabled
155+
# TODO: NOTE: ack checks are disabled
159156
# check command_ack
160157
elif False: # mtype == "COMMAND_ACK":
161158
if msg.command == mavutil.mavlink.MAV_CMD_CAMERA_TRACK_POINT:
@@ -215,7 +212,7 @@ def mavlink_packet(self, msg):
215212
elif msg.command == mavutil.mavlink.MAV_CMD_SET_MESSAGE_INTERVAL:
216213
print("Got COMMAND_ACK: MAV_CMD_SET_MESSAGE_INTERVAL")
217214

218-
# TODO: NOTE: disabled
215+
# TODO: NOTE: command processing disabled
219216
# check command_long
220217
elif False: # mtype == "COMMAND_LONG":
221218
# TODO: check target_system is for offboard control
@@ -293,15 +290,7 @@ def check_events(self):
293290
# self.needs_unloading = True
294291

295292
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"""
305294
# TODO: implement camera and gimbal discovery correctly
306295
# Discovery - most of these requests are handled in the FC
307296
# by GCS_MAVLINK::try_send_message
@@ -335,9 +324,10 @@ def send_messages(self):
335324
self._do_request_camera_information = False
336325

337326
if self._do_request_camera_tracking_image_status:
327+
interval_us = int(1e6 / self._camera_tracking_image_status_rate)
338328
self.send_set_message_interval_message(
339329
mavutil.mavlink.MAVLINK_MSG_ID_CAMERA_TRACKING_IMAGE_STATUS,
340-
1000 * 50, # 20Hz
330+
interval_us, # requested interval in microseconds
341331
response_target=1, # flight-stack default
342332
)
343333
self._do_request_camera_tracking_image_status = False
@@ -402,12 +392,9 @@ def idle_task(self):
402392

403393
def unload(self):
404394
"""Close the GUI and unload module"""
405-
406-
# close the GUI
407395
self.camera_view.close()
408396

409397

410398
def init(mpstate):
411399
"""Initialise module"""
412-
413400
return CamTrackModule(mpstate)

MAVProxy/modules/mavproxy_camtrack/camera_view.py

+8-16
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ def __init__(self, mpstate, title, rtsp_url, fps=30):
3232

3333
self.frame_counter = -1
3434

35-
# TODO: gimbal and camera system ids
35+
# Commands to autopilot attached cameras and gimbals are addressed
36+
# to the autopilot component.
37+
self.camera_sysid = 1 # system id matches vehicle
38+
self.camera_cmpid = 1 # component id matches autopilot
39+
self.camera_deviceid = 1 # first flight-stack connected camera
3640

37-
# autopilot component may proxy up to 6 cameras
38-
self.camera_sysid = 1
39-
self.camera_cmpid = mavutil.mavlink.MAV_COMP_ID_ONBOARD_COMPUTER
40-
self.camera_deviceid = 1 # first autopilot attached camera
41-
42-
self.gimbal_sysid = 1
43-
self.gimbal_cmpid = mavutil.mavlink.MAV_COMP_ID_ONBOARD_COMPUTER
44-
self.gimbal_deviceid = 1 # first autopilot attached gimbal
41+
self.gimbal_sysid = 1 # system id matches vehicle
42+
self.gimbal_cmpid = 1 # component id matches autopilot
43+
self.gimbal_deviceid = 1 # first flight-stack connected gimbal
4544

4645
self.im = TrackerImage(
4746
title=title,
@@ -75,13 +74,6 @@ def set_tracked_rectangle(self, top_left_x, top_left_y, bot_right_x, bot_right_y
7574

7675
def close(self):
7776
"""Close the GUI"""
78-
# TODO: MPImage does not have a close_event
79-
# trigger a close event which is monitored by the
80-
# child gui process - it will close allowing the
81-
# process to be joined
82-
# self.im.close_event.set()
83-
# if self.im.is_alive():
84-
# self.im.child.join(timeout=2.0)
8577
self.im.terminate()
8678

8779
def is_alive(self):

0 commit comments

Comments
 (0)