# Qianxing OpenAPI SDK for Python
千行仿真平台的Python SDK。提供了一种简单直观的方式来控制和获取自动驾驶场景的仿真。
## 安装
您可以直接从PyPI安装该软件包:
```bash
pip install qianxing-openapi
```
## 快速开始
以下是SDK使用的简单示例:
```python
from qianxing_openapi.client import Client
from qianxing_openapi.http_client import HttpConfig
from qianxing_openapi.simulator import SimulatorConfig
from qianxing_openapi.request_model import Point
# 初始化客户端
client = Client(
HttpConfig(
token="your_token_here",
endpoint="your_endpoint_here"
)
)
# 从训练任务中获取可用场景
res = client.train_task.get_scene_id_list(task_id)
print(f"可用场景: {res}")
# 创建仿真器实例
simulator = client.init_simulator_from_config(
SimulatorConfig(
scenario_id=res.scene_id_list[0],
scenario_version=res.scene_version_list[0]
)
)
# 运行仿真步骤
for i in range(10):
step_res = simulator.step()
print(f"第 {i} 步结果: {step_res}")
# 获取车辆信息
vehicle_ids = simulator.get_vehicle_id_list()
print(f"车辆ID列表: {vehicle_ids}")
# 控制车辆运动
simulator.set_vehicle_control_info(
vehicle_id="test_vehicle_1",
ste_wheel=1.2,
lon_acc=1.1
)
# 设置车辆位置
simulator.set_vehicle_position(
vehicle_id="test_vehicle_1",
point=Point(x=-8.75, y=-537.0316, z=0)
)
# 停止仿真
simulator.stop()
```
## 可用API
### 仿真器API
#### 仿真控制
- `init_from_config(sim_config)`: 从配置初始化仿真器
- `init_from_sim(simulation_id, addr)`: 从现有仿真初始化仿真器
- `step()`: 仿真前进一步
- `stop()`: 停止仿真
- `reset(reset_traffic_flow)`: 重置仿真器到初始状态,可选择是否重置交通流
#### 车辆API
- `get_vehicle_id_list()`: 获取所有车辆ID
- `get_test_vehicle_id_list()`: 获取测试车辆ID
- `get_vehicle_base_info(id_list)`: 获取车辆基本信息
- `get_vehicle_position(id_list)`: 获取车辆位置
- `get_vehicle_moving_info(id_list)`: 获取车辆运动信息
- `get_vehicle_control_info(id_list)`: 获取车辆控制参数
- `get_vehicle_perception_info(vehicle_id)`: 获取车辆感知信息
- `get_vehicle_reference_lines(vehicle_id)`: 获取可用参考线
- `get_vehicle_planning_info(vehicle_id)`: 获取车辆规划信息
- `get_vehicle_navigation_info(vehicle_id)`: 获取车辆导航信息
- `get_vehicle_collision_status(vehicle_id)`: 检查车辆碰撞状态
- `get_vehicle_target_speed(vehicle_id)`: 获取车辆目标速度
- `set_vehicle_position(vehicle_id, point, phi)`: 设置车辆位置和航向角
- `set_vehicle_control_info(vehicle_id, ste_wheel, lon_acc)`: 设置车辆控制参数
- `set_vehicle_planning_info(vehicle_id, planning_path)`: 设置车辆规划路径
- `set_vehicle_moving_info(vehicle_id, u, v, w, u_acc, v_acc, w_acc)`: 设置车辆运动参数
- `set_vehicle_base_info(vehicle_id, base_info)`: 设置车辆基本信息
- `set_vehicle_link_nav(vehicle_id, link_nav)`: 设置车辆链接导航信息
- `set_vehicle_destination(vehicle_id, destination)`: 设置车辆目标点
#### 交通信号灯API
- `get_current_stage(junction_id)`: 获取当前交通信号灯阶段
- `get_movement_signal(movement_id)`: 获取转向信号灯颜色
- `get_signal_plan(junction_id)`: 获取交通信号灯配时方案
- `get_movement_list(junction_id)`: 获取路口转向列表
#### 行人API
- `get_ped_id_list()`: 获取所有行人ID
- `get_ped_base_info(ped_id_list)`: 获取行人基本信息
- `set_ped_position(ped_id, point, phi)`: 设置行人位置和航向角
#### 非机动车API
- `get_nmv_id_list()`: 获取所有非机动车ID
- `get_nmv_base_info(nmv_id_list)`: 获取非机动车基本信息
- `set_nmv_position(nmv_id, point, phi)`: 设置非机动车位置和航向角
### 训练任务API
- `get_scene_id_list(task_id)`: 获取训练任务可用场景列表
### 资源API
- `get_map(asset_id, asset_version)`: 获取特定资源的地图数据
## 系统要求
- Python >= 3.0
- requests >= 2.25.0
## 许可证
## 支持
如需报告错误或请求新功能,请使用[GitHub Issues](https://github.com/risenlighten-qianxing/openapi-sdk-python/issues)页面。
Raw data
{
"_id": null,
"home_page": "https://github.com/risenlighten-qianxing/openapi-sdk-python",
"name": "qianxing-openapi",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.0",
"maintainer_email": null,
"keywords": "Qianxing, Lasvsim, \u81ea\u52a8\u9a7e\u9a76, OpenAPI, Simulation, Autonomous Driving",
"author": "Zhihong Luo",
"author_email": "luozhihong@risenlighten.com",
"download_url": "https://files.pythonhosted.org/packages/6c/0e/34c02667b8542d8b3b5f42e1ba4868383bb7136cb4ff82b77658c7ed6160/qianxing-openapi-0.1.8.tar.gz",
"platform": null,
"description": "# Qianxing OpenAPI SDK for Python\n\n\u5343\u884c\u4eff\u771f\u5e73\u53f0\u7684Python SDK\u3002\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u76f4\u89c2\u7684\u65b9\u5f0f\u6765\u63a7\u5236\u548c\u83b7\u53d6\u81ea\u52a8\u9a7e\u9a76\u573a\u666f\u7684\u4eff\u771f\u3002\n\n## \u5b89\u88c5\n\n\u60a8\u53ef\u4ee5\u76f4\u63a5\u4ecePyPI\u5b89\u88c5\u8be5\u8f6f\u4ef6\u5305\uff1a\n\n```bash\npip install qianxing-openapi\n```\n\n## \u5feb\u901f\u5f00\u59cb\n\n\u4ee5\u4e0b\u662fSDK\u4f7f\u7528\u7684\u7b80\u5355\u793a\u4f8b\uff1a\n\n```python\nfrom qianxing_openapi.client import Client\nfrom qianxing_openapi.http_client import HttpConfig\nfrom qianxing_openapi.simulator import SimulatorConfig\nfrom qianxing_openapi.request_model import Point\n\n# \u521d\u59cb\u5316\u5ba2\u6237\u7aef\nclient = Client(\n HttpConfig(\n token=\"your_token_here\",\n endpoint=\"your_endpoint_here\"\n )\n)\n\n# \u4ece\u8bad\u7ec3\u4efb\u52a1\u4e2d\u83b7\u53d6\u53ef\u7528\u573a\u666f\nres = client.train_task.get_scene_id_list(task_id)\nprint(f\"\u53ef\u7528\u573a\u666f: {res}\")\n\n# \u521b\u5efa\u4eff\u771f\u5668\u5b9e\u4f8b\nsimulator = client.init_simulator_from_config(\n SimulatorConfig(\n scenario_id=res.scene_id_list[0],\n scenario_version=res.scene_version_list[0]\n )\n)\n\n# \u8fd0\u884c\u4eff\u771f\u6b65\u9aa4\nfor i in range(10):\n step_res = simulator.step()\n print(f\"\u7b2c {i} \u6b65\u7ed3\u679c: {step_res}\")\n # \u83b7\u53d6\u8f66\u8f86\u4fe1\u606f\n vehicle_ids = simulator.get_vehicle_id_list()\n print(f\"\u8f66\u8f86ID\u5217\u8868: {vehicle_ids}\")\n\n # \u63a7\u5236\u8f66\u8f86\u8fd0\u52a8\n simulator.set_vehicle_control_info(\n vehicle_id=\"test_vehicle_1\", \n ste_wheel=1.2,\n lon_acc=1.1\n )\n\n # \u8bbe\u7f6e\u8f66\u8f86\u4f4d\u7f6e\n simulator.set_vehicle_position(\n vehicle_id=\"test_vehicle_1\",\n point=Point(x=-8.75, y=-537.0316, z=0)\n )\n\n# \u505c\u6b62\u4eff\u771f\nsimulator.stop()\n```\n\n## \u53ef\u7528API\n\n### \u4eff\u771f\u5668API\n\n#### \u4eff\u771f\u63a7\u5236\n- `init_from_config(sim_config)`: \u4ece\u914d\u7f6e\u521d\u59cb\u5316\u4eff\u771f\u5668\n- `init_from_sim(simulation_id, addr)`: \u4ece\u73b0\u6709\u4eff\u771f\u521d\u59cb\u5316\u4eff\u771f\u5668\n- `step()`: \u4eff\u771f\u524d\u8fdb\u4e00\u6b65\n- `stop()`: \u505c\u6b62\u4eff\u771f\n- `reset(reset_traffic_flow)`: \u91cd\u7f6e\u4eff\u771f\u5668\u5230\u521d\u59cb\u72b6\u6001\uff0c\u53ef\u9009\u62e9\u662f\u5426\u91cd\u7f6e\u4ea4\u901a\u6d41\n\n#### \u8f66\u8f86API\n- `get_vehicle_id_list()`: \u83b7\u53d6\u6240\u6709\u8f66\u8f86ID\n- `get_test_vehicle_id_list()`: \u83b7\u53d6\u6d4b\u8bd5\u8f66\u8f86ID\n- `get_vehicle_base_info(id_list)`: \u83b7\u53d6\u8f66\u8f86\u57fa\u672c\u4fe1\u606f\n- `get_vehicle_position(id_list)`: \u83b7\u53d6\u8f66\u8f86\u4f4d\u7f6e\n- `get_vehicle_moving_info(id_list)`: \u83b7\u53d6\u8f66\u8f86\u8fd0\u52a8\u4fe1\u606f\n- `get_vehicle_control_info(id_list)`: \u83b7\u53d6\u8f66\u8f86\u63a7\u5236\u53c2\u6570\n- `get_vehicle_perception_info(vehicle_id)`: \u83b7\u53d6\u8f66\u8f86\u611f\u77e5\u4fe1\u606f\n- `get_vehicle_reference_lines(vehicle_id)`: \u83b7\u53d6\u53ef\u7528\u53c2\u8003\u7ebf\n- `get_vehicle_planning_info(vehicle_id)`: \u83b7\u53d6\u8f66\u8f86\u89c4\u5212\u4fe1\u606f\n- `get_vehicle_navigation_info(vehicle_id)`: \u83b7\u53d6\u8f66\u8f86\u5bfc\u822a\u4fe1\u606f\n- `get_vehicle_collision_status(vehicle_id)`: \u68c0\u67e5\u8f66\u8f86\u78b0\u649e\u72b6\u6001\n- `get_vehicle_target_speed(vehicle_id)`: \u83b7\u53d6\u8f66\u8f86\u76ee\u6807\u901f\u5ea6\n- `set_vehicle_position(vehicle_id, point, phi)`: \u8bbe\u7f6e\u8f66\u8f86\u4f4d\u7f6e\u548c\u822a\u5411\u89d2\n- `set_vehicle_control_info(vehicle_id, ste_wheel, lon_acc)`: \u8bbe\u7f6e\u8f66\u8f86\u63a7\u5236\u53c2\u6570\n- `set_vehicle_planning_info(vehicle_id, planning_path)`: \u8bbe\u7f6e\u8f66\u8f86\u89c4\u5212\u8def\u5f84\n- `set_vehicle_moving_info(vehicle_id, u, v, w, u_acc, v_acc, w_acc)`: \u8bbe\u7f6e\u8f66\u8f86\u8fd0\u52a8\u53c2\u6570\n- `set_vehicle_base_info(vehicle_id, base_info)`: \u8bbe\u7f6e\u8f66\u8f86\u57fa\u672c\u4fe1\u606f\n- `set_vehicle_link_nav(vehicle_id, link_nav)`: \u8bbe\u7f6e\u8f66\u8f86\u94fe\u63a5\u5bfc\u822a\u4fe1\u606f\n- `set_vehicle_destination(vehicle_id, destination)`: \u8bbe\u7f6e\u8f66\u8f86\u76ee\u6807\u70b9\n\n#### \u4ea4\u901a\u4fe1\u53f7\u706fAPI\n- `get_current_stage(junction_id)`: \u83b7\u53d6\u5f53\u524d\u4ea4\u901a\u4fe1\u53f7\u706f\u9636\u6bb5\n- `get_movement_signal(movement_id)`: \u83b7\u53d6\u8f6c\u5411\u4fe1\u53f7\u706f\u989c\u8272\n- `get_signal_plan(junction_id)`: \u83b7\u53d6\u4ea4\u901a\u4fe1\u53f7\u706f\u914d\u65f6\u65b9\u6848\n- `get_movement_list(junction_id)`: \u83b7\u53d6\u8def\u53e3\u8f6c\u5411\u5217\u8868\n\n#### \u884c\u4ebaAPI\n- `get_ped_id_list()`: \u83b7\u53d6\u6240\u6709\u884c\u4ebaID\n- `get_ped_base_info(ped_id_list)`: \u83b7\u53d6\u884c\u4eba\u57fa\u672c\u4fe1\u606f\n- `set_ped_position(ped_id, point, phi)`: \u8bbe\u7f6e\u884c\u4eba\u4f4d\u7f6e\u548c\u822a\u5411\u89d2\n\n#### \u975e\u673a\u52a8\u8f66API\n- `get_nmv_id_list()`: \u83b7\u53d6\u6240\u6709\u975e\u673a\u52a8\u8f66ID\n- `get_nmv_base_info(nmv_id_list)`: \u83b7\u53d6\u975e\u673a\u52a8\u8f66\u57fa\u672c\u4fe1\u606f\n- `set_nmv_position(nmv_id, point, phi)`: \u8bbe\u7f6e\u975e\u673a\u52a8\u8f66\u4f4d\u7f6e\u548c\u822a\u5411\u89d2\n\n### \u8bad\u7ec3\u4efb\u52a1API\n- `get_scene_id_list(task_id)`: \u83b7\u53d6\u8bad\u7ec3\u4efb\u52a1\u53ef\u7528\u573a\u666f\u5217\u8868\n\n### \u8d44\u6e90API\n- `get_map(asset_id, asset_version)`: \u83b7\u53d6\u7279\u5b9a\u8d44\u6e90\u7684\u5730\u56fe\u6570\u636e\n\n## \u7cfb\u7edf\u8981\u6c42\n\n- Python >= 3.0\n- requests >= 2.25.0\n\n## \u8bb8\u53ef\u8bc1\n\n## \u652f\u6301\n\n\u5982\u9700\u62a5\u544a\u9519\u8bef\u6216\u8bf7\u6c42\u65b0\u529f\u80fd\uff0c\u8bf7\u4f7f\u7528[GitHub Issues](https://github.com/risenlighten-qianxing/openapi-sdk-python/issues)\u9875\u9762\u3002\n",
"bugtrack_url": null,
"license": null,
"summary": "Qianxing OpenAPI SDK for Python - A client library for accessing Qianxing's simulation platform",
"version": "0.1.8",
"project_urls": {
"Bug Reports": "https://github.com/risenlighten-qianxing/openapi-sdk-python/issues",
"Homepage": "https://github.com/risenlighten-qianxing/openapi-sdk-python",
"Source": "https://github.com/risenlighten-qianxing/openapi-sdk-python"
},
"split_keywords": [
"qianxing",
" lasvsim",
" \u81ea\u52a8\u9a7e\u9a76",
" openapi",
" simulation",
" autonomous driving"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c762e5d7320c0add7f598dfd2f9820196b314ad95efe865a2b4b566ab497a3f4",
"md5": "27ed518f79c0bf08f8daad776a47e74c",
"sha256": "5bb154bd4059c61e1765d9f7984ae69ca36c80a1cefc007999436a79b5dc8e44"
},
"downloads": -1,
"filename": "qianxing_openapi-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "27ed518f79c0bf08f8daad776a47e74c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.0",
"size": 23183,
"upload_time": "2024-12-19T08:56:51",
"upload_time_iso_8601": "2024-12-19T08:56:51.539204Z",
"url": "https://files.pythonhosted.org/packages/c7/62/e5d7320c0add7f598dfd2f9820196b314ad95efe865a2b4b566ab497a3f4/qianxing_openapi-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6c0e34c02667b8542d8b3b5f42e1ba4868383bb7136cb4ff82b77658c7ed6160",
"md5": "58aa574286e8d3cdc8f4675c65fc6fa4",
"sha256": "199cd2d742418d102d718985a9e1862e5c5874055e2cec1ba62d940c1cc70724"
},
"downloads": -1,
"filename": "qianxing-openapi-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "58aa574286e8d3cdc8f4675c65fc6fa4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.0",
"size": 17158,
"upload_time": "2024-12-19T08:56:52",
"upload_time_iso_8601": "2024-12-19T08:56:52.867552Z",
"url": "https://files.pythonhosted.org/packages/6c/0e/34c02667b8542d8b3b5f42e1ba4868383bb7136cb4ff82b77658c7ed6160/qianxing-openapi-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-19 08:56:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "risenlighten-qianxing",
"github_project": "openapi-sdk-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "requests",
"specs": [
[
"===",
"2.28.2"
]
]
}
],
"lcname": "qianxing-openapi"
}