-
Notifications
You must be signed in to change notification settings - Fork 2
/
main_script.py
49 lines (28 loc) · 1.03 KB
/
main_script.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
# import thread for multithreading
import thread
# import custom classes
from drone_class import SAFMC_drone
from corridor_navigation import corridor
from TOF import TOF_sensor
from velocity_calculator import vel_calc
# Vehicle's connection string and baud rate
CONNECTION_STRING = '/dev/ttyUSB0'
BAUD_RATE = 57600
# initialize the TOF object with ports 0,1,2,3,7
tofs = TOF_sensor(0,1,2,3,7)
# initialize tofs with distance param 3
tofs.initialize_sensors(3)
# starts the multithread to read the sensors at 0.05s rate
thread.start_new_thread(get_sensor_readings, (0.05))
# initialize the drone object
drone = SAFMC_drone(CONNECTION_STRING, BAUD_RATE)
# starts the velocity calculator object and get the list of velocities
velocity = vel_calc(drone.get_heading())
vel_list = velocity.calc_vel_FBLR()
#initialize the corridor object
corridor_nav = corridor(drone, tofs, vel_list)
# Land the drone and close the vehicle object
drone.set_land()
drone.close_vehicle()
# set the termination condition of the TOFs
tofs.terminate = True