Skip to main content

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

Project description

Qianxing OpenAPI SDK for Python

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

安装

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

pip install qianxing-openapi

快速开始

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

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页面。

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

qianxing-openapi-0.1.8.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

qianxing_openapi-0.1.8-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file qianxing-openapi-0.1.8.tar.gz.

File metadata

  • Download URL: qianxing-openapi-0.1.8.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for qianxing-openapi-0.1.8.tar.gz
Algorithm Hash digest
SHA256 199cd2d742418d102d718985a9e1862e5c5874055e2cec1ba62d940c1cc70724
MD5 58aa574286e8d3cdc8f4675c65fc6fa4
BLAKE2b-256 6c0e34c02667b8542d8b3b5f42e1ba4868383bb7136cb4ff82b77658c7ed6160

See more details on using hashes here.

File details

Details for the file qianxing_openapi-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for qianxing_openapi-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5bb154bd4059c61e1765d9f7984ae69ca36c80a1cefc007999436a79b5dc8e44
MD5 27ed518f79c0bf08f8daad776a47e74c
BLAKE2b-256 c762e5d7320c0add7f598dfd2f9820196b314ad95efe865a2b4b566ab497a3f4

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