-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
70 lines (49 loc) · 1.44 KB
/
main.py
File metadata and controls
70 lines (49 loc) · 1.44 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /usr/bin/python3.8
from uav import uav
from Logger import Logger
import time
L = Logger(0)
def wait():
while not drone.check_for_target_reached(): # TODO: include object avoidance check
drone.rate.sleep()
pass
time.sleep(15)
drone = uav("offb_node_py", 20.0)
drone.connnect()
drone.set_mode("OFFBOARD")
drone.arm(True)
# Needed, for the OFFBOARD to work, idk why
drone.take_off(2)
wait()
"""
drone.move_to_gps(43.64475, -79.38499, 25)
wait()
drone.move_to_gps(43.64375, -79.38464, 25)
wait()
drone.move_to_gps(43.64312, -79.38800, 25)
wait()
drone.move_to_gps(43.64344, -79.38868, 25)
wait()
L.INFO("Arrived at dropping location")
time.sleep(2)
drone.send_pwm(8, 2000)
time.sleep(2)
L.INFO("Package dropped")
drone.send_pwm(8, 1100)
"""
drone.drop_mission('../catkin_ws/src/px-lib-1/scripts/wp_demo.txt')
drone.return_to_home()
# Example by using waypoints
def waypoint_mission():
"""
drone.create_waypoint(3, 16, True, True, 0, 43.64475, -79.38499, 25)
drone.create_waypoint(3, 16, False, True, 0, 43.64375, -79.38464, 25)
drone.create_waypoint(3, 16, True, True, 0, 43.64312, -79.38800, 25)
drone.create_waypoint(3, 16, False, True, 0, 43.64344, -79.38868, 25)
"""
#drone.drop_mission('mission.txt')
drone.arm(True)
drone.start_mission()
while drone.check_for_mission_completion(): # TODO: include object avoidance check
pass
drone.auto_land() # TODO: land with object avoidance