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.6.tar.gz (16.1 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.6-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qianxing-openapi-0.1.6.tar.gz
  • Upload date:
  • Size: 16.1 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.6.tar.gz
Algorithm Hash digest
SHA256 4132621251c80772360c5e6151c8e8f68df5e740ac3ac3dbc7f5511be34df102
MD5 6464e1f3d11d82059821254b2aa30594
BLAKE2b-256 e1a406660fdf62aaae8c373990f3018c6e636a48a6a13b0749bc0a7eb5b164c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qianxing_openapi-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e5e1362fafec539a7d6bf3b32da0442d62fccb469e916e68f5faca5a2a9525f4
MD5 0032627a52fba9aabb7d8c19c631fe80
BLAKE2b-256 318b4cf709b9252840601c4e38a23003a565f62c5f55838a35652a5c5b245d1d

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