forked from venthur/python-ardrone
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_video.py
More file actions
72 lines (57 loc) · 2.12 KB
/
test_video.py
File metadata and controls
72 lines (57 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
"""
Test script to debug video stream issues with AR.Drone 2.0
"""
import time
import sys
import libardrone
def main():
print("AR.Drone 2.0 Video Stream Test")
print("================================")
# Initialize drone
print("1. Initializing drone connection...")
try:
drone = libardrone.ARDrone()
except Exception as e:
print(f"ERROR: Failed to initialize drone: {e}")
return
print("2. Drone initialized successfully")
# Wait for initial connection
print("3. Waiting for connection stabilization...")
time.sleep(2)
# Enable video stream explicitly
print("4. Enabling video stream...")
drone.enable_video_stream()
# Check connection and video data
print("5. Monitoring video stream for 10 seconds...")
start_time = time.time()
last_image_check = ""
while time.time() - start_time < 10:
# Check if we have navigation data
if hasattr(drone, 'navdata') and drone.navdata:
nav_keys = list(drone.navdata.keys())
if nav_keys:
print(f" Navdata keys available: {nav_keys}")
# Check drone state
if 'drone_state' in drone.navdata:
state = drone.navdata['drone_state']
video_enabled = state.get('video_mask', 0)
video_thread = state.get('video_thread_on', 0)
print(f" Video enabled: {video_enabled}, Video thread: {video_thread}")
# Check if we have video data
if hasattr(drone, 'image') and drone.image:
if drone.image != last_image_check:
print(f" Video data received! Image size: {len(drone.image)} bytes")
last_image_check = drone.image
else:
print(" No new video frames...")
else:
print(" No video data yet...")
time.sleep(1)
print("6. Test completed")
# Clean shutdown
print("7. Shutting down...")
drone.halt()
print("Done!")
if __name__ == "__main__":
main()