Is there a way to control the drone with arrow keys to fly manually? #3544
Answered
by
ahmed-elsaharti
jueunkwon
asked this question in
Support Q&A
-
Is there a way to fly the drone manually using the arrow keys (without a RC)? |
Beta Was this translation helpful? Give feedback.
Answered by
ahmed-elsaharti
Apr 4, 2021
Replies: 1 comment 3 replies
-
Hi @jueunkwon , you could always use the C++ or Python APIs to write your own tool that would control the drone's velocities (as an example) on keypress. import airsim
import keyboard # using module keyboard (install using pip3 install keyboard)
vx=0
vy=0
vz=0
client = airsim.MultirotorClient()
client.confirmConnection()
client.enableApiControl(True)
while True: # making a loop
try: # used try so that if user pressed other than the given key error will not be shown
if keyboard.is_pressed('w'):
vx=5
elif keyboard.is_pressed('s'):
vx=-5
else:
vx=0
if keyboard.is_pressed('d'):
vy=5
elif keyboard.is_pressed('a'):
vy=-5
else:
vy=0
if keyboard.is_pressed('space'):
vz=-5
else:
vz=5
print("vx" + str(vx) + " vy " + str(vy) + " vz " + str(vz))
client.moveByVelocityAsync(vx,vy,vz,12)
except:
break # if user pressed a key other than the given key the loop will break |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
jueunkwon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @jueunkwon , you could always use the C++ or Python APIs to write your own tool that would control the drone's velocities (as an example) on keypress.
Here's a crude example using python's keyboard library that I wrote a couple of months ago: