Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
kinivi committed Mar 16, 2021
2 parents 727b894 + 73f424c commit 6e1df2d
Showing 2 changed files with 17 additions and 9 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -110,8 +110,7 @@ The following is a list of keys and action description -

* `k` -> Toggle Keyboard controls
* `g` -> Toggle Gesture controls
* `Left Shift` -> Take off drone #TODO
* `Space` -> Land drone
* `Space` -> Take off drone(if landed) **OR** Land drone(if in flight)
* `w` -> Move forward
* `s` -> Move back
* `a` -> Move left
23 changes: 16 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ def get_args():

return args


def select_mode(key, mode):
number = -1
if 48 <= key <= 57: # 0 ~ 9
@@ -49,6 +50,7 @@ def select_mode(key, mode):
mode = 2
return number, mode


def main():
# init global vars
global gesture_buffer
@@ -59,16 +61,13 @@ def main():
args = get_args()
KEYBOARD_CONTROL = args.is_keyboard
WRITE_CONTROL = False
in_flight = False

# Camera preparation
tello = Tello()
tello.connect()
tello.streamon()


# Take-off drone
tello.takeoff()

cap = tello.get_frame_read()

# Init Tello Controllers
@@ -107,15 +106,26 @@ def tello_battery(tello):
key = cv.waitKey(1) & 0xff
if key == 27: # ESC
break
elif key == 32: # Space
if not in_flight:
# Take-off drone
tello.takeoff()
in_flight = True

elif in_flight:
# Land tello
tello.land()
in_flight = False

elif key == ord('k'):
mode=0
mode = 0
KEYBOARD_CONTROL = True
WRITE_CONTROL = False
tello.send_rc_control(0, 0, 0, 0) # Stop moving
elif key == ord('g'):
KEYBOARD_CONTROL = False
elif key == ord('n'):
mode=1
mode = 1
WRITE_CONTROL = True
KEYBOARD_CONTROL = True

@@ -124,7 +134,6 @@ def tello_battery(tello):
if 48 <= key <= 57: # 0 ~ 9
number = key - 48


# Camera capture
image = cap.frame

0 comments on commit 6e1df2d

Please sign in to comment.