File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed
Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change 22HITL Test - GPS + Camera Feed Verification
33
44"""
5+
56import cv2
67import os
78import time
89
910from modules .mavlink import flight_controller
1011
1112
12-
1313# Physical connection to Pixhawk: /dev/ttyAMA0
1414# Simulated connection to Pixhawk: tcp:localhost:5762
1515PIXHAWK_ADDRESS = "/dev/ttyAMA0"
1616TEST_DURATION = 10
1717
1818
19-
2019def test_camera_feed () -> bool :
2120 """
2221 Returns True if camera feed is available, False otherwise.
2322 """
2423 try :
2524 camera = cv2 .VideoCapture (2 )
26-
25+
2726 if not camera .isOpened ():
2827 camera .release ()
2928 return False
30-
29+
3130 ret , frame = camera .read ()
3231 camera .release ()
33-
32+
3433 if ret and frame is not None and frame .size > 0 :
3534 return True
36-
35+
3736 return False
38-
37+
3938 except Exception :
4039 return False
4140
@@ -65,17 +64,17 @@ def main() -> int:
6564 if controller .hitl_instance is not None :
6665 controller .hitl_instance .start ()
6766 print ("HITL emulators started" )
68-
67+
6968 print ("Waiting for camera creation..." )
70- time .sleep (5 )
71-
69+ time .sleep (5 )
70+
7271 print ("Checking for camera..." )
7372 camera_available = test_camera_feed ()
7473 if camera_available :
7574 print ("Camera: detected" )
7675 else :
7776 print ("Camera: not detected" )
78-
77+
7978 else :
8079 print ("ERROR: HITL instance not created" )
8180 return - 1
You can’t perform that action at this time.
0 commit comments