Skip to main content

Lasvsim OpenAPI SDK for Python - A client library for accessing Lasvsim's simulation platform

Project description

Lasvsim OpenAPI SDK for Python

千行仿真平台的Python SDK。提供了一种简单直观的方式来控制和获取自动驾驶场景的仿真。

安装

您可以直接从PyPI安装该软件包:

pip install lasvsim-openapi

迁移

执行下面命令修改包名,其中./src为代码目录。修改完成后使用git检查改动。

grep -rl 'qianxing_openapi' ./src | xargs sed -i '' 's/qianxing_openapi/lasvsim_openapi/g'

快速开始

以下是SDK使用的简单示例:

from lasvsim_openapi.client import Client
from lasvsim_openapi.http_client import HttpConfig
from lasvsim_openapi.simulator import SimulatorConfig
from lasvsim_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页面。

Project details


Download files

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

Source Distribution

lasvsim-openapi-0.1.9a0.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

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

lasvsim_openapi-0.1.9a0-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

File details

Details for the file lasvsim-openapi-0.1.9a0.tar.gz.

File metadata

  • Download URL: lasvsim-openapi-0.1.9a0.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for lasvsim-openapi-0.1.9a0.tar.gz
Algorithm Hash digest
SHA256 0571013dbc3de4ddc7b5624063242645ccaeb99d9ddf7e9eeb3a1cd8cb67f670
MD5 d96a3ff861fc475b82a6fedd6e7ff3ed
BLAKE2b-256 8823a79d23916a3d1aa8bb193b22f46a431f55032a83950de62aaff976bb5aed

See more details on using hashes here.

File details

Details for the file lasvsim_openapi-0.1.9a0-py3-none-any.whl.

File metadata

File hashes

Hashes for lasvsim_openapi-0.1.9a0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3be8fe8b90055a269916197d10ab3cb28c1c6a5099e84d6484c7504c37c4986
MD5 bdeff988ee00f91c1793ffd4745232d5
BLAKE2b-256 7c0b12c967c5133e010a4ffbee9a5d058c90cb514b9e11c15981eee267d95ed5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page