Sensors, Proximity & Offscreen Camera

Contacts, Proximity & AABBs

  • Contacts (contacts, contact_count, contact_counts, total_contact_count): Structured NumPy view (CONTACT_DTYPE) with env_id, body1, body2, flags, contact point (px, py, pz), normal (nx, ny, nz), impulse, and penetration.

  • World-Space AABBs: get_aabb(body_idx) (World) or get_aabb(env_idx, body_idx) (VecWorld) returns (min_xyz, max_xyz) as float32 (3,) NumPy arrays from JPH::Body::GetWorldSpaceBounds().

  • Proximity Queries (World):

    • get_closest_points(body1, body2, max_dist=0.5) returns a list of ClosestPointResult.

    • get_overlapping_objects(aabb_min, aabb_max) returns overlapping body_idx integers.

  • Joint FT & IMU (World):

    • get_joint_ft_sensor(art_idx) -> (num_joints, 6) wrench [fx, fy, fz, tx, ty, tz].

    • get_imu(body_idx, include_gravity=True) -> (6,) [ax, ay, az, wx, wy, wz] in body frame.

Batched Raycasting (raycast_batch)

raycast_batch(starts, directions, max_dist=10.0) returns a structured RAY_HIT_DTYPE array (body_idx, fraction, px, py, pz, nx, ny, nz):

  • On World: starts / directions shape (M, 3) -> (M,) hits.

  • On VecWorld: (M, 3) (shared across envs) or (N, M, 3) (per-env rays) -> (N, M) hits.

Offscreen Camera & 2D Optical Flow (joltsim.camera)

joltsim.camera.get_camera_image(...) renders RGB (uint8), planar Z-depth (float32), per-body segmentation (int32), and optional 2D optical flow (float32, (du/dt, dv/dt) in pixels/sec) using raycast_batch:

from joltsim import camera

view = camera.compute_view_matrix((1.5, -1.5, 1.2), (0.0, 0.0, 0.4))
proj = camera.compute_projection_matrix(fov_deg=60.0, aspect=1.0, near=0.05, far=50.0)

rgb, depth, seg, flow = camera.get_camera_image(
    world_or_vec,
    width=64,
    height=64,
    view_matrix=view,     # or omit and mount via body_idx=... / site_idx=...
    projection_matrix=proj,
    return_flow=True,
    as_torch=True,
    device="cuda",
)

camera.has_wgpu() checks whether optional wgpu is available in the current environment.