yincheng.zhong
2 天以前 567085ead3f6adaabd884f16ab4b17c62e8f0403
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] 用户中断")