usvcont/usv.py

50 lines
1.4 KiB
Python
Raw Normal View History

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
from ground_control_station import GroundControlStation
from mission import Mission
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)
self.navigation = Navigation(self)
2021-11-26 15:48:54 +08:00
self.control = Control()
self.gcs = GroundControlStation(self.settings.gcs_com)
self.mission = Mission(self.settings.usv_id)
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):
self.futaba.rcu_run(self)
self.control.c_run(self)
self.navigation.n_run(self)
self.gcs.g_run(self)
self.futaba.backup_data()
self.log.write_log(self)
2021-12-01 11:51:04 +08:00
timer_10 = threading.Timer(0.01, self.ms10_run, )
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()