PB 车辆配置/标定文件(vehicle_config.proto)反序列化校验、解析为 YAML、从 YAML 统一格式地组装为 .pb.txt。V0.1.7:新增 PB 工作区实体级 CRUD,统一由 pb_calibration 控制 manifest,并保留 V0.1.6 的格式与一致性校验能力。
Project description
pb-calibration
当前版本:0.1.7
基于 vehicle_config.proto(与 mdrive master 对齐,依赖 modules/message/common/geometry.proto)的 PB 车辆配置/标定文件(.pb.txt)反序列化校验、解析为 YAML、从 YAML 统一格式地组装为 .pb.txt。
V0.1.7:在 V0.1.6 基础上,新增 PB 工作区实体级 CRUD(list/get/create/update/delete/replace),把 manifest 控制权统一收回到 pb_calibration,不再要求外部程序自己拼 order_manifest.yaml。
V0.1.6:无论是未修改、修改还是新增内容,build 输出都统一空格与缩进;未修改块尽量保留原数字字面量,修改/新增块的浮点标准化精度提升到最多 16 位小数;新增 YAML 工作区一致性校验与 register/remove/reorder 共享接口,避免“文件已存在但未被 manifest 引用”的静默错误。
V0.1.5:新增“未修改原文保真”重组、未知字段警告与尽量保留、浮点标准化输出、YAML 全量双引号字符串化。
V0.1.4:vehicle_config.proto 与上游 mdrive 一致,Transform 使用 mdrive.message.common.Point3D / Quaternion;VehicleLidarConfig.enable_ids 为 uint32(与此前本地单文件内嵌 int32 的实验性定义不同)。
V0.1.3:在 V0.1.2 基础上为 VehicleConfig 增加 vehicle_lidar_config(enable_ids),兼容 mdrive_conf 新标定。
V0.1.2:VehicleInfo 新增字段 color、manufacturer 等;此前版本曾将 Point3D/Quaternion 内嵌在单文件内。
环境与安装
推荐使用 Conda 环境 py310,并在该环境中安装本包及依赖:
conda activate py310
pip install -e . # 开发安装
# 或
pip install . # 普通安装
若仅安装不开发,也可:
pip install pb-calibration
功能
- 反序列化检查:检查
pb.txt是否存在格式问题(能否正常解析)。 - 解析为 YAML:将
pb.txt解析为每个单独的 yaml 文件,输出到指定目录;该目录与后续「组合」时使用的目录一致。 - 从 YAML 组装:按顺序将指定目录中的单独 yaml 文件组装成
pb.txt(输入目录与解析输出目录一致,可指定)。 - 统一格式重组:无论 PB 内容是否修改,输出都会统一为规范空格与缩进,避免 tab、混排空格和多空格残留。
- 未知字段警告:如果输入 PB 含当前 proto 未识别字段,
parse会给出 warning;未修改对应块时会尽量保留其原字段内容,修改该块后会再次警告这些字段可能丢失。 - 统一输出规范:修改或新增的
float/double字段统一输出为十进制、不使用科学计数法、最多 16 位小数、四舍五入、0.0不省略;空内容不写。未修改块也会统一格式,但尽量保留原数字字面量。 - YAML 全量字符串化:所有 YAML 标量值均以双引号字符串输出,避免隐式类型转换。
- 工作区一致性校验:
build前会强制检查order_manifest与intrinsics/、extrinsics/文件集是否一致;孤儿 YAML、缺失文件、重复frame_id、manifest/frame_id 不一致、内参矩阵长度错误都会直接报错。 - 实体级 CRUD:新增
list/get/create/update/delete/replace的 intrinsics / extrinsics 公共接口,外部程序不再需要自己控制 manifest。 - 共享工作区操作:保留
validate_yaml_workspace、register_intrinsic_file、register_extrinsic_file、remove_intrinsic_entry、remove_extrinsic_entry、reorder_intrinsic_entries、reorder_extrinsic_entries,供 skill、GUI 与脚本共用。 - 顶层块操作:新增
get/update_vehicle_info、get/update_vehicle_param、get/update_vehicle_lidar_config。 - YamlConfigManager:类,存储默认 YAML 路径;不缓存 YAML 内容,每次从默认路径读取,保证多程序共同维护时数据为最新。支持
read_yaml/update_yaml、read_order_manifest/update_order_manifest、rescan/get_cached/get、一致性校验与 CRUD 封装。 - 函数式低层 API:
read_yaml、update_yaml、read_order_manifest、update_order_manifest等接口仍保留,供专家/兼容场景使用,但不再是推荐的 manifest 编辑主路径。
命令行
# 1. 检查 pb.txt 格式
pb-calibration check -i /path/to/vehicle_config.pb.txt
# 2. 解析 pb.txt 为 yaml,输出到指定目录(该目录即后续 build 的输入)
pb-calibration parse -i /path/to/vehicle_config.pb.txt -o /path/to/yaml_dir
# 3. 从指定目录按顺序组装为 pb.txt(目录与 parse 的 -o 一致)
pb-calibration build -i /path/to/yaml_dir -o /path/to/vehicle_config_out.pb.txt
# 4. build 前先检查工作区一致性
pb-calibration validate -i /path/to/yaml_dir
测试
在本版本目录(V0.1.7)下执行:
conda activate py310
pip install -e .[dev]
pytest test/ -v
python -m build
或单独运行:pytest test/test_crud_api.py -v、pytest test/test_workspace_consistency.py -v、pytest test/test_v015_features.py -v、pytest test/test_roundtrip.py -v、pytest test/test_api.py -v、pytest test/test_yaml_manager.py -v。
从 proto 重新生成 *_pb2.py(维护者)
在包根目录下,需同时生成 geometry.proto 与 vehicle_config.proto(若系统无 protoc,可用 grpcio-tools):
conda activate py310
python -m grpc_tools.protoc --proto_path=pb_calibration/protobuf --python_out=pb_calibration/protobuf \
pb_calibration/protobuf/modules/message/common/geometry.proto \
pb_calibration/protobuf/vehicle_config.proto
生成后请将 vehicle_config_pb2.py 中对 geometry_pb2 的导入改为相对导入:
from .modules.message.common import geometry_pb2 as ...,以便打包安装后可解析。
依赖
- Python >= 3.10(推荐在 conda 环境
py310下使用) - PyYAML >= 6.0
- protobuf >= 4.21.0
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pb_calibration-0.1.7.tar.gz.
File metadata
- Download URL: pb_calibration-0.1.7.tar.gz
- Upload date:
- Size: 44.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
921b707e451d34aa29084d6e32b2ee23455c05ff688b918de0ff38ebfb9a01ca
|
|
| MD5 |
6ba165ba8881e8e72ec1f321db819b6a
|
|
| BLAKE2b-256 |
cf1168a05ac3ac23dcf73df0b3bf20caedeab8cc429e4f28ae9ba3c9e8bd20b2
|
File details
Details for the file pb_calibration-0.1.7-py3-none-any.whl.
File metadata
- Download URL: pb_calibration-0.1.7-py3-none-any.whl
- Upload date:
- Size: 42.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0790fa68cbad1ddc7baf350ed8710c35e976a8f1dd13678e2436ef3dde8d3625
|
|
| MD5 |
9bd3afefdd12301ecdb0c6b4fd62ef9b
|
|
| BLAKE2b-256 |
de24f8b85bfeeaa405605d148aefc091d8644f3f60e8dbe8df3663ae5b7684eb
|