2021-11-26 19:10:23 +08:00
|
|
|
import threading
|
|
|
|
|
2021-11-26 15:48:54 +08:00
|
|
|
from remote_control_unit import RemoteControlUnit
|
2021-11-27 20:29:23 +08:00
|
|
|
from navigation import Navigation
|
2021-11-26 15:48:54 +08:00
|
|
|
from control import Control
|
|
|
|
from settings import Settings
|
2021-11-30 17:49:41 +08:00
|
|
|
from ground_control_station import GroundControlStation
|
2021-12-02 18:35:32 +08:00
|
|
|
from mission import Mission
|
2021-12-04 22:20:04 +08:00
|
|
|
from log import Log
|
2021-11-26 15:48:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
class UsvControl:
|
|
|
|
"""程序入口"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.settings = Settings()
|
2021-11-27 20:29:23 +08:00
|
|
|
self.futaba = RemoteControlUnit(self.settings.sbus_com)
|
2021-12-10 11:47:15 +08:00
|
|
|
self.navigation = Navigation(self)
|
2021-11-26 15:48:54 +08:00
|
|
|
self.control = Control()
|
2021-11-30 17:49:41 +08:00
|
|
|
self.gcs = GroundControlStation(self.settings.gcs_com)
|
2021-12-02 18:35:32 +08:00
|
|
|
self.mission = Mission(self.settings.usv_id)
|
2021-12-04 22:20:04 +08:00
|
|
|
self.log = Log(self.settings.usv_id)
|
2021-11-26 15:48:54 +08:00
|
|
|
|
2021-12-01 11:51:04 +08:00
|
|
|
def ms10_run(self):
|
2021-11-26 19:10:23 +08:00
|
|
|
self.futaba.rcu_run(self)
|
|
|
|
self.control.c_run(self)
|
2021-12-10 08:57:15 +08:00
|
|
|
self.navigation.n_run(self)
|
2021-11-30 17:49:41 +08:00
|
|
|
self.gcs.g_run(self)
|
2021-12-01 17:18:55 +08:00
|
|
|
self.futaba.backup_data()
|
2021-12-04 22:20:04 +08:00
|
|
|
self.log.write_log(self)
|
2021-12-01 11:51:04 +08:00
|
|
|
timer_10 = threading.Timer(0.01, self.ms10_run, )
|
2021-11-26 19:10:23 +08:00
|
|
|
timer_10.start()
|
2021-11-26 15:48:54 +08:00
|
|
|
|
2021-12-01 11:51:04 +08:00
|
|
|
def ms1000_run(self):
|
|
|
|
print(self.futaba.receive_data)
|
|
|
|
print(self.navigation.data)
|
|
|
|
print(self.control.data)
|
|
|
|
print(self.control.pid)
|
|
|
|
print(self.gcs.heart_beat)
|
|
|
|
print(self.gcs.command)
|
|
|
|
timer_1000 = threading.Timer(1, self.ms1000_run, )
|
|
|
|
timer_1000.start()
|
|
|
|
|
2021-11-26 15:48:54 +08:00
|
|
|
|
|
|
|
# 按间距中的绿色按钮以运行脚本。
|
|
|
|
if __name__ == '__main__':
|
|
|
|
usv1 = UsvControl()
|
2021-12-01 11:51:04 +08:00
|
|
|
usv1.ms10_run()
|
|
|
|
usv1.ms1000_run()
|