forked from franciscofleury/flight_scripts_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtakeoff_and_land.py
39 lines (29 loc) · 1.09 KB
/
takeoff_and_land.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
from copter import Copter
import time
# CHANGE THE VALUES IN THIS DICTIONARY TO MATCH THE ONES IN YOUR SITL INSTANCE
copter_params = {
"sysid": 10,
"connection_string": "udpin:127.0.0.1:17171",
}
def big_print(text):
print("##################################################################################")
print("########## %s ##########" % text)
print("##################################################################################")
big_print("Lets test takeoff and land")
copter = Copter(sysid=int(copter_params['sysid']))
big_print("Let's connect on " + str(copter_params['connection_string']))
copter.connect(connection_string=str(copter_params['connection_string']))
big_print("Let's do some GUIDED movement")
# We will do some guided command
copter.change_mode("GUIDED")
big_print("Let's wait ready to arm")
# We wait that can pass all arming check
copter.wait_ready_to_arm()
if not copter.armed():
copter.arm_vehicle()
big_print("Let's wait ready to arm")
# example of mavlink takeoff
copter.user_takeoff(11)
time.sleep(5)
# Get back to home
copter.land_and_disarm()