From 3c2021441490ae9b93f7a2ef0f379909b589edd9 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期六, 13 十二月 2025 18:53:16 +0800
Subject: [PATCH] 应该是拍视频的版本,外包在此基础上加了MQTT部分。

---
 python/gps_imu_receiver.py |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/python/gps_imu_receiver.py b/python/gps_imu_receiver.py
index dc63740..4e53893 100644
--- a/python/gps_imu_receiver.py
+++ b/python/gps_imu_receiver.py
@@ -298,29 +298,33 @@
     
     try:
         last_stats_time = time.time()
+        last_print_time = 0.0
+        latest_gps_data = None
         
         while True:
-            gps_data, imu_data = receiver.receive_packet()
+            gps_data, _ = receiver.receive_packet()
             
             if gps_data:
-                print(f"[GPS] 绾害: {gps_data.latitude:.8f}掳, "
-                      f"缁忓害: {gps_data.longitude:.8f}掳, "
-                      f"鑸悜: {gps_data.heading_angle:.2f}掳, "
-                      f"淇话: {gps_data.pitch_angle:.2f}掳, "
-                      f"妯粴: {gps_data.roll_angle:.2f}掳, "
-                      f"閫熷害(E/N/U): {gps_data.east_velocity:.2f}/{gps_data.north_velocity:.2f}/{gps_data.up_velocity:.2f} m/s, "
-                      f"鍗槦: {gps_data.satellite_count}, "
-                      f"璐ㄩ噺: {gps_data.position_quality}")
+                latest_gps_data = gps_data
             
-            if imu_data:
-                print(f"[IMU] 鍔犻�熷害(X/Y/Z): {imu_data.accel_x:.3f}/{imu_data.accel_y:.3f}/{imu_data.accel_z:.3f} g, "
-                      f"瑙掗�熷害(X/Y/Z): {imu_data.gyro_x:.2f}/{imu_data.gyro_y:.2f}/{imu_data.gyro_z:.2f} 掳/s, "
-                      f"娓╁害: {imu_data.temperature:.1f}鈩�")
+            current_time = time.time()
+            
+            # 姣忕杈撳嚭涓�娆℃渶鏂扮殑GPS淇℃伅
+            if latest_gps_data and (current_time - last_print_time) >= 1.0:
+                print(f"[GPS] 绾害: {latest_gps_data.latitude:.8f}掳, "
+                      f"缁忓害: {latest_gps_data.longitude:.8f}掳, "
+                      f"鑸悜: {latest_gps_data.heading_angle:.2f}掳, "
+                      f"淇话: {latest_gps_data.pitch_angle:.2f}掳, "
+                      f"妯粴: {latest_gps_data.roll_angle:.2f}掳, "
+                      f"閫熷害(E/N/U): {latest_gps_data.east_velocity:.2f}/{latest_gps_data.north_velocity:.2f}/{latest_gps_data.up_velocity:.2f} m/s, "
+                      f"鍗槦: {latest_gps_data.satellite_count}, "
+                      f"璐ㄩ噺: {latest_gps_data.position_quality}")
+                last_print_time = current_time
             
             # 姣�10绉掓墦鍗颁竴娆$粺璁′俊鎭�
-            if time.time() - last_stats_time > 10.0:
+            if current_time - last_stats_time > 10.0:
                 receiver.print_stats()
-                last_stats_time = time.time()
+                last_stats_time = current_time
     
     except KeyboardInterrupt:
         print("\n[INFO] 鐢ㄦ埛涓柇")

--
Gitblit v1.10.0