# [rosbag2_compression] 压缩比超过阈值：10.5（最大 5.0）。包文件可能已损坏。

- **ID:** `ros2/rosbag2-compression-ratio-exceeded`
- **领域:** ros2
- **类别:** data_error
- **错误码:** `ROSBAG2_COMPRESSION_001`
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

压缩算法（例如 zstd）生成的压缩文件大于未压缩数据，通常是由于不可压缩的数据（例如来自激光雷达或雷达等传感器的随机噪声）或配置错误的压缩级别。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Humble | active | — | — |
| Iron | active | — | — |
| Jazzy | active | — | — |
| Rolling | active | — | — |

## 解决方案

1. ```
   Increase the compression ratio threshold in the storage options: ros2 bag record -o my_bag --compression-mode file --compression-format zstd --compression-queue-size 100 --max-compression-ratio 20.0 /topic1 /topic2
   ```
2. ```
   Filter out noisy topics (e.g., raw sensor data) from recording to avoid incompressible data: ros2 bag record -o my_bag --exclude '/noisy_lidar/.*' /important_topic
   ```
3. ```
   Preprocess sensor data to reduce noise (e.g., downsampling or filtering) before recording, using a separate node that publishes filtered messages.
   ```

## 无效尝试

- **Increase the compression level to 22 (max for zstd)** — Higher compression levels can make the ratio worse for incompressible data, as overhead increases. (70% 失败率)
- **Disable compression entirely and store bags uncompressed** — This solves the warning but defeats the purpose of using compression for storage efficiency. (50% 失败率)
- **Change the compression format to 'lz4'** — LZ4 is faster but has even worse compression ratios for incompressible data and may still trigger the warning. (75% 失败率)
