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
源码示例会优先加载当前仓库中的 metacar_hybrid,不受环境里已安装旧版本影响。
基础程序支持以下按键:
WASD或方向键:世界坐标系 Delta 移动- 按住
X:发送零位移停车指令 Space:重开当前关卡N:跳过当前关卡Esc:发送停车指令并安全退出
程序不依赖 GUI。它与原版 main.py 一样是 TCP 监听端:应先启动本程序,
再在平台中启动虚实结合场景,由场景主动连接本机的 127.0.0.1:5061
控制端口和 127.0.0.1:5063 视频端口。终端会分别显示控制端口连接、
视频端口连接和场景初始化三个阶段,并在握手完成后持续输出位置和控制状态。
完整轨迹控制和测试策略属于内部开发代码,不包含在 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.0a4- 对齐原版连接顺序并增加分阶段连接诊断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.0a4.tar.gz.
File metadata
- Download URL: metacar_hybrid-0.1.0a4.tar.gz
- Upload date:
- Size: 38.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8dd9f4d2d31ad473eca66e04711679d0583ef651dc473ed7b89c86538990eedc
|
|
| MD5 |
fd91bc733a6ac8b72ce3582b943083c3
|
|
| BLAKE2b-256 |
281f9f6d0bacd480dab75b790de994c6a61ed9c497c4bda12d7b98c95679fa9f
|
Provenance
The following attestation bundles were made for metacar_hybrid-0.1.0a4.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.0a4.tar.gz -
Subject digest:
8dd9f4d2d31ad473eca66e04711679d0583ef651dc473ed7b89c86538990eedc - Sigstore transparency entry: 2206409911
- Sigstore integration time:
-
Permalink:
YDL-Simulation/metacar-hybrid@1793a321c450eb63637c1cf5e7604b6cf44a1e5a -
Branch / Tag:
refs/tags/v0.1.0a4 - Owner: https://github.com/YDL-Simulation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@1793a321c450eb63637c1cf5e7604b6cf44a1e5a -
Trigger Event:
release
-
Statement type:
File details
Details for the file metacar_hybrid-0.1.0a4-py3-none-any.whl.
File metadata
- Download URL: metacar_hybrid-0.1.0a4-py3-none-any.whl
- Upload date:
- Size: 18.1 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 |
6a6b8c40e547b9085b36f6aeee79075534da92d39cd4b35f17701e97468a453e
|
|
| MD5 |
71e046c2176f9a5b21aec63a01e4c8d8
|
|
| BLAKE2b-256 |
b7440383875b72fac07577a91fbc2e13c74286c63e0dc08a96d688ab2caf3837
|
Provenance
The following attestation bundles were made for metacar_hybrid-0.1.0a4-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.0a4-py3-none-any.whl -
Subject digest:
6a6b8c40e547b9085b36f6aeee79075534da92d39cd4b35f17701e97468a453e - Sigstore transparency entry: 2206410079
- Sigstore integration time:
-
Permalink:
YDL-Simulation/metacar-hybrid@1793a321c450eb63637c1cf5e7604b6cf44a1e5a -
Branch / Tag:
refs/tags/v0.1.0a4 - Owner: https://github.com/YDL-Simulation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@1793a321c450eb63637c1cf5e7604b6cf44a1e5a -
Trigger Event:
release
-
Statement type: