Skip to main content

Python SDK for simulation-carema.

Project description

qhsim SDK

Python SDK for the simulation-carema backend API.

Install

python -m pip install -e sdk

Local Debug Flow

Run the prodtest HTTP flow from the repository root:

python sdk\examples\debug_http_render_flow.py

The debug script loads the scene, submits one render task with two camera poses, polls the render result, and prints the task id, status, finished flag, image URLs, and result COS keys.

Defaults:

  • service base URL: http://localhost:18080
  • service base prefix: /qh-sensor-simulation/api/c
  • QHSIM_USER_ID: 3FO4KV8SHSLV
  • QHSIM_DESIGN_ID: 3FO3BK4HCD6O
  • QHSIM_SNAPSHOT_TYPE_ID: 720
  • QHSIM_POLL_INTERVAL: 3
  • QHSIM_POLL_ATTEMPTS: 20

The service URL is fixed in the SDK. To change it, edit DEFAULT_BASE_URL in qhsim.backends.http. The service path prefix is fixed by DEFAULT_SERVICE_BASE_PREFIX. HTTPS certificate verification is disabled by default for prodtest self-signed certificates; pass config={"verify_ssl": True, "cafile": "internal-ca.pem"} to enable verification with a trusted CA.

If you use another example directly without editable install, set PYTHONPATH first:

$env:PYTHONPATH="D:\fengguo\Agent\repo\simulation-carema\sdk"
python sdk\examples\basic_http_flow.py

Example

from qhsim import SimulationApp
from qhsim.core.api import World
from qhsim.core.math import Position, Target
from qhsim.sensors.camera import Camera

simulation_app = SimulationApp(
    user_id="3FO4KV8SHSLV",
    config={
        "snapshot_type_id": 720,
    },
)

world = World(simulation_app)
world.load_scene(design_id="3FO3BK4HCD6O")

camera = Camera(
    name="camera",
    position=Position(0.0, 0.0, 1600.0),
    target=Target(0.0, 1938.0, 1300.0),
    fov=80.0,
    clarity=1,
)

world.scene.add(camera)

camera.set_world_pose(
    position=Position(1090.0, 0.0, 1600.0),
    target=Target(100.0, 1938.0, 1300.0),
)

submitted = world.render()
print(submitted.task_id)

render_data = world.get_render_result(submitted.task_id)
print(render_data.finished)
print(render_data.image_urls)

final_data = world.poll_render_result(submitted.task_id)
print(final_data.status)
print(final_data.image_urls)

print(camera.get_history_pose())
print(world.scene.get_object(object_name=camera.name))

simulation_app.close()

The default backend calls the fixed local service API:

  • GET /qh-sensor-simulation/api/c/scene/models?designId=...
  • POST /qh-sensor-simulation/api/c/camera/render
  • GET /qh-sensor-simulation/api/c/camera/render/result?rootTaskId=...

user_id is sent as the required x-qh-id header and should already be the encrypted user id expected by the backend. The service URL cannot be overridden by config or environment variables. To change it, edit DEFAULT_BASE_URL in qhsim.backends.http. HTTPS certificate verification is disabled by default for prodtest self-signed certificates; pass config={"verify_ssl": True, "cafile": "internal-ca.pem"} to enable verification with a trusted CA. To swap the transport in tests, pass a backend object with load_scene(), render(), and get_render_result() methods:

simulation_app = SimulationApp(config={"backend": custom_backend})

Public API

Each module defines __all__; names not listed there are implementation details.

qhsim

  • SimulationApp: SDK runtime entrypoint.
    • update()
    • close()
    • is_running()

qhsim.backends

  • HttpBackend: backend implementation for the service API.
    • load_scene(design_id)
    • render(design_id, camera_history, camera_name)
    • get_render_result(root_task_id)
  • BackendCameraData
  • BackendBoundingBoxData
  • BackendModelData
  • BackendVec3Data
  • RenderResultResponse
  • RenderSubmitResponse
  • RenderTaskRequest
  • SceneModelListResponse
  • DEFAULT_BASE_URL
  • DEFAULT_SERVICE_BASE_PREFIX
  • DEFAULT_SNAPSHOT_TYPE_ID

qhsim.core

  • ModelData: scene model metadata.
  • SimulationContext: app context holder.
  • Scene: loaded design scene.
    • add(obj)
    • get_objects()
    • get_object(object_id=None, object_name=None)
  • World: high-level scene and render API.
    • load_scene(design_id)
    • render(camera=None)
    • get_render_result(task_id)
    • poll_render_result(task_id, interval=3.0, max_attempts=20000, print_progress=True, require_result=True)
  • Position
    • from_dict(data)
    • to_dict()
  • Target
    • from_dict(data)
    • to_dict()
  • BoundingBox
    • from_dict(data)
    • to_dict()
  • RenderData: render task result with task_id, status, finished, result, image_urls, result_cos_key, and result_zip_cos_key.

qhsim.sensors

  • Camera: camera sensor used by World.render().
    • set_world_pose(position, target)
    • get_world_pose()
    • get_history_pose()
    • to_render_history()

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

qhsim-0.1.1.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

qhsim-0.1.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file qhsim-0.1.1.tar.gz.

File metadata

  • Download URL: qhsim-0.1.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for qhsim-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3fa0b7f9364623ec6989fced733f6dd45da46ffd3c86194690f6cb9772b3a842
MD5 0caf7de8f52a6a805b29978148930618
BLAKE2b-256 93e43b0978f291eebb65bbed73c00c8428ec58e91b0013155658bfb90c43710d

See more details on using hashes here.

File details

Details for the file qhsim-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: qhsim-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for qhsim-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46c35e92af0af85aa1ef9361b50674208a59ea7a145713ec9c1a33fdcd2fce1c
MD5 730f12a5bfb9b8705ded734d59ac2a06
BLAKE2b-256 26178b5b4ce7d300c50b004781f2930e843d83f56392ccd12120bc0dad67882e

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