Skip to main content

PB 车辆配置/标定文件(vehicle_config.proto)反序列化校验、解析为 YAML、从 YAML 组装为 .pb.txt。V0.1.4:vehicle_config.proto 与 mdrive master 对齐,import geometry.proto;VehicleLidarConfig.enable_ids 为 uint32。

Project description

pb-calibration

当前版本:0.1.4

基于 vehicle_config.proto(与 mdrive master 对齐,依赖 modules/message/common/geometry.proto)的 PB 车辆配置/标定文件(.pb.txt)反序列化校验、解析为 YAML、从 YAML 按顺序组装为 .pb.txt
V0.1.4:vehicle_config.proto 与上游 mdrive 一致,Transform 使用 mdrive.message.common.Point3D / QuaternionVehicleLidarConfig.enable_idsuint32(与此前本地单文件内嵌 int32 的实验性定义不同)。
V0.1.3:在 V0.1.2 基础上为 VehicleConfig 增加 vehicle_lidar_configenable_ids),兼容 mdrive_conf 新标定。
V0.1.2:VehicleInfo 新增字段 colormanufacturer 等;此前版本曾将 Point3D/Quaternion 内嵌在单文件内。

环境与安装

推荐使用 Conda 环境 py310,并在该环境中安装本包及依赖:

conda activate py310
pip install -e .   # 开发安装
# 或
pip install .      # 普通安装

若仅安装不开发,也可:

pip install pb-calibration

功能

  1. 反序列化检查:检查 pb.txt 是否存在格式问题(能否正常解析)。
  2. 解析为 YAML:将 pb.txt 解析为每个单独的 yaml 文件,输出到指定目录;该目录与后续「组合」时使用的目录一致。
  3. 从 YAML 组装:按顺序将指定目录中的单独 yaml 文件组装成 pb.txt(输入目录与解析输出目录一致,可指定)。
  4. YamlConfigManager:类,存储默认 YAML 路径;不缓存 YAML 内容,每次从默认路径读取,保证多程序共同维护时数据为最新。支持 read_yaml / update_yamlread_order_manifest / update_order_manifestrescan / get_cached / get
  5. 函数式 APIread_yamlupdate_yamlread_order_manifestupdate_order_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

测试

在本版本目录(V0.1.4)下执行:

conda activate py310
pip install -e .
pytest test/ -v

或单独运行:pytest test/test_roundtrip.py -vpytest test/test_api.py -vpytest test/test_yaml_manager.py -v

从 proto 重新生成 *_pb2.py(维护者)

在包根目录下,需同时生成 geometry.protovehicle_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pb_calibration-0.1.4.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pb_calibration-0.1.4-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file pb_calibration-0.1.4.tar.gz.

File metadata

  • Download URL: pb_calibration-0.1.4.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for pb_calibration-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8ab16231058f4ff71765c86c2ec348380e0404a53e8e542c57ebdb6aca7e3448
MD5 687a9e5f6b5e5d04f6aa2ed1fe4249f7
BLAKE2b-256 85b5dc1ece4dc82c7819382ce0b9d9619cac7c3c76c5ef0a72f9e061a180284f

See more details on using hashes here.

File details

Details for the file pb_calibration-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pb_calibration-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for pb_calibration-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 87c5454927b163b5727bf8c9254c398028290d47aca9f44b3972058add316b95
MD5 2d5aa0cde89457cf951482aac3f063af
BLAKE2b-256 a103b4c8241aea7647eed0bc1b4e5beae678dcd0692be38fa92c0ad1a3bc8a3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page