2026.7.1简化日志与配置文件优化
This commit is contained in:
@@ -32,6 +32,13 @@
|
|||||||
"enabled": true,
|
"enabled": true,
|
||||||
"tcp_port": 9999
|
"tcp_port": 9999
|
||||||
},
|
},
|
||||||
|
"missions": {
|
||||||
|
"target_altitude": 3.0,
|
||||||
|
"arrival_radius": 0.3,
|
||||||
|
"hold_duration": 8.0,
|
||||||
|
"return_to_home": false,
|
||||||
|
"target_lost_timeout": null
|
||||||
|
},
|
||||||
"log": {
|
"log": {
|
||||||
"enable_flight_log": true,
|
"enable_flight_log": true,
|
||||||
"flight_log_interval": 20,
|
"flight_log_interval": 20,
|
||||||
|
|||||||
+12
-2
@@ -223,12 +223,13 @@ class VideoStreaming:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def _udp_stream_sender_worker(self):
|
def _udp_stream_sender_worker(self):
|
||||||
""" 原图传发送线程(增加帧统计日志) """
|
""" 原图传发送线程(异常降噪:首次报错后静默,恢复时输出日志) """
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
server_address = (self.gs_ip, self.udp_port)
|
server_address = (self.gs_ip, self.udp_port)
|
||||||
self.logger.info("图传后台线程已启动,目标地面站 -> %s:%s",
|
self.logger.info("图传后台线程已启动,目标地面站 -> %s:%s",
|
||||||
self.gs_ip, self.udp_port)
|
self.gs_ip, self.udp_port)
|
||||||
send_count = 0
|
send_count = 0
|
||||||
|
tx_error_reported = False # 标记当前是否处于异常状态,避免刷屏
|
||||||
|
|
||||||
while self.is_running:
|
while self.is_running:
|
||||||
try:
|
try:
|
||||||
@@ -244,13 +245,22 @@ class VideoStreaming:
|
|||||||
self.logger.debug("图像数据过大 (%d bytes), 跳过发送", len(data))
|
self.logger.debug("图像数据过大 (%d bytes), 跳过发送", len(data))
|
||||||
continue
|
continue
|
||||||
sock.sendto(data, server_address)
|
sock.sendto(data, server_address)
|
||||||
|
|
||||||
|
# ---- 发送成功:若之前处于异常状态,输出恢复日志 ----
|
||||||
|
if tx_error_reported:
|
||||||
|
tx_error_reported = False
|
||||||
|
self.logger.info("✅ 图传已恢复: %s:%s", self.gs_ip, self.udp_port)
|
||||||
|
|
||||||
send_count += 1
|
send_count += 1
|
||||||
if send_count % 100 == 0:
|
if send_count % 100 == 0:
|
||||||
self.logger.info("图传统计: 已发送 %d 帧 UDP 数据包", send_count)
|
self.logger.info("图传统计: 已发送 %d 帧 UDP 数据包", send_count)
|
||||||
|
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
continue
|
continue
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.exception("图传线程异常: %s", e)
|
if not tx_error_reported:
|
||||||
|
tx_error_reported = True
|
||||||
|
self.logger.error("图传异常: %s (后续同类错误静默,恢复后输出日志)", e)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -119,13 +119,14 @@ class MissionOrchestrator:
|
|||||||
|
|
||||||
self.proxy.set_waypoints_callback(self._on_qgc_waypoints)
|
self.proxy.set_waypoints_callback(self._on_qgc_waypoints)
|
||||||
|
|
||||||
|
missions = cfg["missions"]
|
||||||
self.mission = MissionManager(
|
self.mission = MissionManager(
|
||||||
proxy=self.proxy,
|
proxy=self.proxy,
|
||||||
waypoints=self.waypoints,
|
waypoints=self.waypoints,
|
||||||
target_altitude=3.0,
|
target_altitude=missions.get("target_altitude", 3.0),
|
||||||
arrival_radius=0.3,
|
arrival_radius=missions.get("arrival_radius", 0.3),
|
||||||
hold_duration=8.0,
|
hold_duration=missions.get("hold_duration", 5.0),
|
||||||
return_to_home=False,
|
return_to_home=missions.get("return_to_home", True),
|
||||||
)
|
)
|
||||||
|
|
||||||
# ================================================================
|
# ================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user