forked from aerostack2/project_gazebo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmission.py
71 lines (52 loc) · 1.32 KB
/
mission.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/python3
"""
mission.py
"""
from time import sleep
import rclpy
from as2_python_api.drone_interface import DroneInterface
def drone_run(drone_interface: DroneInterface):
""" Run the mission """
speed = 0.5
takeoff_height = 1.0
height = 1.0
sleep_time = 2.0
dim = 1.0
path = [
[-dim, dim, height],
[-dim, -dim, height],
[dim, -dim, height],
[dim, dim, height]
]
print("Start mission")
##### ARM OFFBOARD #####
print("Arm")
drone_interface.offboard()
sleep(sleep_time)
print("Offboard")
drone_interface.arm()
sleep(sleep_time)
##### TAKE OFF #####
print("Take Off")
drone_interface.takeoff(takeoff_height, speed=1.0)
print("Take Off done")
sleep(sleep_time)
##### GO TO #####
for goal in path:
print(f"Go to with path facing {goal}")
drone_interface.go_to.go_to_point_path_facing(goal, speed=speed)
print("Go to done")
sleep(sleep_time)
##### LAND #####
print("Landing")
drone_interface.land(speed=0.5)
print("Land done")
drone_interface.disarm()
if __name__ == '__main__':
rclpy.init()
uav = DroneInterface("drone0", verbose=False, use_sim_time=True)
drone_run(uav)
uav.shutdown()
rclpy.shutdown()
print("Clean exit")
exit(0)