-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdrone_test.py
45 lines (32 loc) · 1.18 KB
/
drone_test.py
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
"""
The MotionCommander uses velocity setpoints.
"""
import logging
import time
import cflib.crtp
from cflib.crazyflie import Crazyflie
from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
from cflib.positioning.motion_commander import MotionCommander
import sys
if len(sys.argv)>1:
URI = 'radio://0/80/2M/E7E7E7E7'+sys.argv[1][-2:]
else:
URI = 'radio://0/80/2M/E7E7E7E701'
# Only output errors from the logging framework
logging.basicConfig(level=logging.ERROR)
if __name__ == '__main__':
# Initialize the low-level drivers (don't list the debug drivers)
cflib.crtp.init_drivers(enable_debug_driver=False)
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
# We take off when the commander is created
with MotionCommander(scf) as mc:
time.sleep(1)
# There is a set of functions that move a specific distance
# We can move in all directions
mc.up(0.5)
time.sleep(2)
mc.down(0.5)
time.sleep(2)
# And we can stop
mc.stop()
# We land when the MotionCommander goes out of scope