Skip to content

[T-030b] geometry: vectorised 2-D ray casting on occupancy grids and analytic rectangles #44

Closed

Description

@CodewithJha

Task T-030b · Milestone M2 — Scenario + kinematic2d · Size S · Priority P0 · Epic #2

Implements FR-SIM-001 · NFR-PERF-001

Branch feat/t-030b-geometry-vectorised-2-d-ray — one task = one branch = one PR (doc 32 §6)

Summary

Implement geometry/raycast.py: cast N beams from a pose against the grid (ray marching / DDA) and against analytic rectangles, returning ranges clipped to [r_min, r_max].

Context / motivation

Lidar (180 beams) and depth (60 beams) simulation in kinematic2d must be fast enough for ≤ 2 s per 120 s episode (NFR-PERF-001).

Scope

In scope

  • cast(grid, pose, angles, r_min, r_max, rects=None, include_rects=True) -> ndarray.
  • Option to exclude rectangles (lidar does not see the sub-scan-plane pallet, doc 10 §7.1).

Implementation guidance

  • Use Amanatides–Woo DDA vectorised across beams, or fixed-step marching with step = cell/2; benchmark both, keep the faster with documented accuracy.
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Acceptance criteria

  • Analytic tests (walls at known distances) within one cell.
  • Benchmark: 180 beams ≤ 0.5 ms median on CI runner (pytest-benchmark, recorded).
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • tests/unit/geometry/test_raycast.py, tests/benchmark/test_raycast_bench.py.

Dependencies

Blocked by: #43 (T-030a)

Blocks: #51 (T-033a), #52 (T-033b)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • backend/src/roboprobe/geometry/raycast.py

Owns one module.

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-030b (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 10 §7.1 · doc 02 §5

Requirements: FR-SIM-001 · NFR-PERF-001 (traceability: doc 28)

External:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:simulatorSimulator backends (kinematic2d, Gazebo adapter)milestone:M2M2 — Scenario + kinematic2dpriority:P0Critical path / blocks otherssize:S<= 1 daytaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions