Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

MetaCar Hybrid - 虚实结合平台 Python API

MetaCar Hybrid 是面向智能网联汽车虚实结合场景的 Python API。本项目基于 YDL-Simulation/autodrive_api_python 开发,在保留原有场景通信、车辆状态和视频流能力的基础上,增加了 HybridControl 消息和 Delta 位移控制。

当前为 Alpha 版本,接口可能随虚实平台协议继续调整。

与原版 MetaCar 的关系

  • PyPI 发行包名为 metacar-hybrid
  • 为便于持续同步上游,Python 导入包仍保留为 metacar
  • metacar-hybrid 与原版 metacar 不应安装在同一个 Python 环境中。
  • 本产品使用独立版本号,并在 UPSTREAM.md 中记录对应的上游基线。

功能特性

  • 与虚实结合平台进行 TCP 通信
  • 解析 HybridControldeltaTime
  • 通过 SceneAPI.set_hybrid_delta() 发送 dx / dy 控制量
  • 获取场景静态数据、车辆状态和传感器数据
  • 摄像头视频流处理
  • 保留原版油门、刹车、转向控制接口
  • 提供不包含产品策略的基础键盘 Delta 控制示例

安装

建议在独立虚拟环境中安装:

python -m venv .venv

Windows PowerShell:

.venv\Scripts\Activate.ps1
python -m pip uninstall -y metacar
python -m pip install metacar-hybrid

安装运行示例所需的键盘和 GUI 依赖:

python -m pip install "metacar-hybrid[examples]"

Alpha 版本需要显式允许预发布版:

python -m pip install --pre metacar-hybrid

虚实结合控制

from metacar import SceneAPI

api = SceneAPI()
api.connect()

for sim_car_msg, frames in api.main_loop():
    hybrid_control = sim_car_msg.hybrid_control or {}
    dt = hybrid_control.get("deltaTime")

    # dx / dy 由上层轨迹跟踪或键盘算法计算
    api.set_hybrid_delta(dx=0.1, dy=0.0, dt=dt)

示例

仓库中包含:

  • examples/main_hybrid_basic.py - 可公开的基础键盘 Delta 控制示例
  • examples/main.py - 原有仿真控制示例
  • examples/gui.py - 车辆状态与场景信息 GUI

安装示例依赖后,可以直接运行基础示例:

python -m pip install "metacar-hybrid[examples]"
metacar-hybrid-basic

从源码开发时也可以运行:

python examples/main_hybrid_basic.py

完整轨迹控制和测试策略属于内部开发代码,不包含在 PyPI 的 wheel 和源码发布包中。

维护

本项目采用内部开发仓库与公开产品仓库分离的方式维护。上游同步、公开边界和发版步骤请参阅 MAINTENANCE.md

创建 GitHub Release 和发布 PyPI 前,请按照 RELEASING.md 完成版本、标签、Trusted Publisher 和安装验证。

本地开发与验证

python -m pip install -e ".[test,examples]" build twine
python -m pytest
python -m build
python -m twine check --strict dist/*
python scripts/check_release_artifacts.py dist/*

文档

本地构建 Sphinx 文档:

python -m pip install -r docs/requirements.txt
sphinx-build -W -b html docs docs/_build/html

版本策略

MetaCar Hybrid 独立发版:

  • 0.1.0a1 - 首个 Alpha 测试版
  • 0.1.0rc1 - 首个发布候选版
  • 0.1.0 - 首个稳定版

每次同步上游后,应在 UPSTREAM.md 和发布说明中记录上游标签及提交哈希。

许可证

本项目基于 MIT 许可证的上游项目开发,继续使用 MIT 许可证。详见 LICENSE

Download files

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

Source Distribution

metacar_hybrid-0.1.0a1.tar.gz (34.1 kB view details)

Uploaded Source

Built Distribution

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

metacar_hybrid-0.1.0a1-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file metacar_hybrid-0.1.0a1.tar.gz.

File metadata

  • Download URL: metacar_hybrid-0.1.0a1.tar.gz
  • Upload date:
  • Size: 34.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for metacar_hybrid-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 2dc334d0feecca3ba11d0dc90afd98ba656ac37e21c9be8b1ba7cda80e218654
MD5 3b4549780a696193eacec3cee24d00d1
BLAKE2b-256 9b26fd10e42024200a7fba908e7a632cc3a9ca22873b6f370130636efba34ee4

See more details on using hashes here.

Provenance

The following attestation bundles were made for metacar_hybrid-0.1.0a1.tar.gz:

Publisher: python-publish.yml on YDL-Simulation/metacar-hybrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file metacar_hybrid-0.1.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for metacar_hybrid-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a5a45411ba6452ba8a44649cd35060a2789a8566d2a09827d2ac3093a3b758d
MD5 fc31e13267cd2979301182bd0bec4bce
BLAKE2b-256 57d3dd3d1b20fc778805a6e5ca7e33bb38a5c44d8e1bbf6699842401f6158a05

See more details on using hashes here.

Provenance

The following attestation bundles were made for metacar_hybrid-0.1.0a1-py3-none-any.whl:

Publisher: python-publish.yml on YDL-Simulation/metacar-hybrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.0

2 files

This release

0.1.0a1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page