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_hybrid,与原版metacar明确区分。 metacar-hybrid与原版metacar可以安装在同一个 Python 环境中。- 本产品使用独立版本号,并在 UPSTREAM.md 中记录对应的上游基线。
功能特性
- 与虚实结合平台进行 TCP 通信
- 解析
HybridControl和deltaTime - 通过
SceneAPI.set_hybrid_delta()发送dx/dy控制量 - 获取场景静态数据、车辆状态和传感器数据
- 摄像头视频流处理
- 保留原版油门、刹车、转向控制接口
- 提供不包含产品策略的基础键盘 Delta 控制示例
安装
建议在独立虚拟环境中安装:
python -m venv .venv
Windows PowerShell:
.venv\Scripts\Activate.ps1
python -m pip install --pre metacar-hybrid
安装运行示例所需的键盘和 GUI 依赖:
python -m pip install --pre "metacar-hybrid[examples]"
虚实结合控制
from metacar_hybrid 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 --pre "metacar-hybrid[examples]"
metacar-hybrid-basic
从源码开发时也可以运行:
python examples/main_hybrid_basic.py
基础程序支持以下按键:
WASD或方向键:世界坐标系 Delta 移动- 按住
X:发送零位移停车指令 Space:重开当前关卡N:跳过当前关卡Esc:发送停车指令并安全退出
程序不依赖 GUI;启动后会等待虚实结合场景连接,并持续输出位置和控制状态。
完整轨迹控制和测试策略属于内部开发代码,不包含在 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 测试版,使用旧导入名metacar0.1.0a2- 使用独立导入名metacar_hybrid,支持与原版共存0.1.0a3- 提供可直接运行的基础虚实结合键盘控制程序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
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 metacar_hybrid-0.1.0a3.tar.gz.
File metadata
- Download URL: metacar_hybrid-0.1.0a3.tar.gz
- Upload date:
- Size: 37.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8863c34e17645833ebcb2adaf0ca7684cd08daa8cf4718964007cb0ecb47df41
|
|
| MD5 |
d84af717a990db6050fe3759f8d95827
|
|
| BLAKE2b-256 |
1ce5da422df2880ee563aede5bfc22c5fb648c3e2970791b85140d95f69d10dd
|
Provenance
The following attestation bundles were made for metacar_hybrid-0.1.0a3.tar.gz:
Publisher:
python-publish.yml on YDL-Simulation/metacar-hybrid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metacar_hybrid-0.1.0a3.tar.gz -
Subject digest:
8863c34e17645833ebcb2adaf0ca7684cd08daa8cf4718964007cb0ecb47df41 - Sigstore transparency entry: 2206276810
- Sigstore integration time:
-
Permalink:
YDL-Simulation/metacar-hybrid@63bb6af9e37af53d4883b4d6e93e7270130ac7ba -
Branch / Tag:
refs/tags/v0.1.0a3 - Owner: https://github.com/YDL-Simulation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@63bb6af9e37af53d4883b4d6e93e7270130ac7ba -
Trigger Event:
release
-
Statement type:
File details
Details for the file metacar_hybrid-0.1.0a3-py3-none-any.whl.
File metadata
- Download URL: metacar_hybrid-0.1.0a3-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48fa86d2fa02d51b73503eb543ad0cf5b043877c199cb82cef0583fedf707ccd
|
|
| MD5 |
0a4943612d0adb5672cef37f6596183e
|
|
| BLAKE2b-256 |
4adaf9e316dc1acad28bf444a3534e82db7c09cd4885bddfc3a6cd45eba75c3d
|
Provenance
The following attestation bundles were made for metacar_hybrid-0.1.0a3-py3-none-any.whl:
Publisher:
python-publish.yml on YDL-Simulation/metacar-hybrid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metacar_hybrid-0.1.0a3-py3-none-any.whl -
Subject digest:
48fa86d2fa02d51b73503eb543ad0cf5b043877c199cb82cef0583fedf707ccd - Sigstore transparency entry: 2206276823
- Sigstore integration time:
-
Permalink:
YDL-Simulation/metacar-hybrid@63bb6af9e37af53d4883b4d6e93e7270130ac7ba -
Branch / Tag:
refs/tags/v0.1.0a3 - Owner: https://github.com/YDL-Simulation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@63bb6af9e37af53d4883b4d6e93e7270130ac7ba -
Trigger Event:
release
-
Statement type: