# Lasvsim OpenAPI SDK for Python
千行仿真平台的Python SDK。提供了一种简单直观的方式来控制和获取自动驾驶场景的仿真。
## 安装
您可以直接从PyPI安装该软件包:
```bash
pip install lasvsim-openapi
```
## 快速开始
以下是SDK使用的简单示例:
```python
from lasvsim.client import Client
from lasvsim.http_client import HttpConfig
from lasvsim.simulator import SimulatorConfig
from lasvsim.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/rl-lasvsim/openapi-sdk-python",
"name": "lasvsim-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/5d/e9/06df9f6a775df8ec8ac3e95f49efc5d22dd928361060a1aa57aecf427712/lasvsim-openapi-0.1.8.tar.gz",
"platform": null,
"description": "# Lasvsim 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 lasvsim-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 lasvsim.client import Client\nfrom lasvsim.http_client import HttpConfig\nfrom lasvsim.simulator import SimulatorConfig\nfrom lasvsim.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": "Lasvsim OpenAPI SDK for Python - A client library for accessing Lasvsim's simulation platform",
"version": "0.1.8",
"project_urls": {
"Bug Reports": "https://github.com/rl-lasvsim/openapi-sdk-python/issues",
"Homepage": "https://github.com/rl-lasvsim/openapi-sdk-python",
"Source": "https://github.com/rl-lasvsim/openapi-sdk-python"
},
"split_keywords": [
"qianxing",
" lasvsim",
" \u81ea\u52a8\u9a7e\u9a76",
" openapi",
" simulation",
" autonomous driving"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c6622b5e6ac1d8c30552cfdaace223d0c1b7f0bfd037181f8bcfe7f32f098f3c",
"md5": "a70256557ac3fdddb2f2f2e09ccc2cfc",
"sha256": "9e3fba2841fdf9b288fea2a9dcb096a7cc1294361ccfec99121728ea3eddce70"
},
"downloads": -1,
"filename": "lasvsim_openapi-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a70256557ac3fdddb2f2f2e09ccc2cfc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.0",
"size": 39392,
"upload_time": "2024-12-19T09:23:44",
"upload_time_iso_8601": "2024-12-19T09:23:44.823665Z",
"url": "https://files.pythonhosted.org/packages/c6/62/2b5e6ac1d8c30552cfdaace223d0c1b7f0bfd037181f8bcfe7f32f098f3c/lasvsim_openapi-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5de906df9f6a775df8ec8ac3e95f49efc5d22dd928361060a1aa57aecf427712",
"md5": "c4773ca998c3c1e60999108656f50a04",
"sha256": "3c13e4303a99439200fc7135c556acb086223bb842ef76cd7604d784170d7fd1"
},
"downloads": -1,
"filename": "lasvsim-openapi-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "c4773ca998c3c1e60999108656f50a04",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.0",
"size": 17327,
"upload_time": "2024-12-19T09:23:46",
"upload_time_iso_8601": "2024-12-19T09:23:46.386419Z",
"url": "https://files.pythonhosted.org/packages/5d/e9/06df9f6a775df8ec8ac3e95f49efc5d22dd928361060a1aa57aecf427712/lasvsim-openapi-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-19 09:23:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "rl-lasvsim",
"github_project": "openapi-sdk-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "requests",
"specs": [
[
"===",
"2.28.2"
]
]
}
],
"lcname": "lasvsim-openapi"
}