Skip to content

Commit

Permalink
improve frame grabbing with a configurable timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
M4GNV5 committed Jun 6, 2021
1 parent 0b478a0 commit c67fe58
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion djitellopy/tello.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Tello:
# Send and receive commands, client socket
RESPONSE_TIMEOUT = 7 # in seconds
TAKEOFF_TIMEOUT = 20 # in seconds
FRAME_GRAB_TIMEOUT = 3
TIME_BTW_COMMANDS = 0.1 # in seconds
TIME_BTW_RC_CONTROL_COMMANDS = 0.001 # in seconds
RETRY_COUNT = 3 # number of retries after a failed command
Expand Down Expand Up @@ -930,7 +931,9 @@ def __init__(self, tello, address):
# Try grabbing a frame multiple times
# According to issue #90 the decoder might need some time
# https://github.com/damiafuentes/DJITelloPy/issues/90#issuecomment-855458905
for _ in range(20):
start = time.time()
while time.time() - start < Tello.FRAME_GRAB_TIMEOUT:
Tello.LOGGER.debug('trying to grab a frame...')
self.grabbed, self.frame = self.cap.read()
if self.frame is not None:
break
Expand Down

0 comments on commit c67fe58

Please sign in to comment.