This repository has been archived by the owner on Feb 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathantenna_tracking_controller.py
90 lines (71 loc) · 2.74 KB
/
antenna_tracking_controller.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import json
import socket
import logging
import struct
import sys
from antenna import Antenna
import time
import imu_client
class AntennaTrackingController:
""" This class will controll all antenna calculation loop.
It has the responsability to ensure we can fetch all neccessary data in
order to make the system working properly
"""
# MAVLink packet id for GPS. See:
# https://pixhawk.ethz.ch/mavlink/#GLOBAL_POSITION_INT
MAVLINK_GPS_ID = 33
def __init__(self):
""" Constructor """
def start(self, verbose=True, use_internal_gps=False):
""" Start execution of the main loop
This is the central point of the antenna tracking system. It put
all together the data and trigger calculations. Then a nice
output is given to STDOUT.
"""
# Display some funky ascii
self.greeting()
# Setup antenna tracking system
self.antenna = Antenna(use_internal_gps)
if self.antenna.ready:
while True:
# Apply a pwm according to the calculations
self.antenna.update_target_orientation()
# time.sleep(0.2) NOOOO
if verbose:
self.antenna.print_current_data()
else:
logging.error(
'Initialization aborted due to unmet startup conditions for one or more module.')
self.stop()
def stop(self):
""" Gracefully stop antenna tracking controller """
logging.info('Closing antenna tracking system')
# Close threads
self.antenna.close()
def greeting(self):
""" Welcome message """
print("""
___ _ _ _ _
/ _ \ | | | | | | (_)
/ /_\ \_ __ | |_ ___ _ __ _ __ __ _ | |_ _ __ __ _ ___| | ___ _ __ __ _
| _ | '_ \| __/ _ \ '_ \| '_ \ / _` | | __| '__/ _` |/ __| |/ / | '_ \ / _` |
| | | | | | | || __/ | | | | | | (_| | | |_| | | (_| | (__| <| | | | | (_| |
\_| |_/_| |_|\__\___|_| |_|_| |_|\__,_| \__|_| \__,_|\___|_|\_\_|_| |_|\__, |
__/ |
_.--l--._ |___/
.` | `.
.` `. | .` `.
.` ` | .` `. POWERED BY DRONOLAB
/ __ .|.` __ \ Source code: github.com/dronolab/antenna_tracking
| ''--._ V _.--'' | License: MIT
| _ (") _ |
| __..--' ^ '--..__ | _
\\ .`|`. /-.)
`. .` | `. .`
`. .` | `. .`
`._ | _.`|
`--l--` | |
/ . \\
/ / \\ \\
/ / \\ \\
""")