Skip to content

[T-028] Shared materialisation helpers: Jinja2 StrictUndefined templates and place_obstacle #41

Closed

Description

@CodewithJha

Task T-028 · Milestone M2 — Scenario + kinematic2d · Size S · Priority P1 · Epic #2

Implements FR-SCN-005

Branch feat/t-028-shared-materialisation-helpers-jinja2-strictundefined — one task = one branch = one PR (doc 32 §6)

Summary

Implement scenario/materialize.py with render_template(template, ctx) (Jinja2 StrictUndefined, sandboxed) and place_obstacle(path, along, clearance, side) -> Pose2D per doc 06 §3.2.

Context / motivation

Both backends materialise scenarios; sharing these helpers guarantees identical obstacle placement in kinematic2d and Gazebo (cross-backend parity, doc 08 §7).

Scope

In scope

  • Polyline arc-length parametrisation; left normal n(s); obstacle centre c = path(s) + side·n(s)·clearance, yaw aligned with path tangent.
  • Deterministic output; byte-identical renders for equal inputs.

Implementation guidance

  • Use jinja2.sandbox.SandboxedEnvironment(undefined=StrictUndefined, autoescape=False, keep_trailing_newline=True).
  • 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 on straight and L-shaped paths.
  • Missing template variable raises immediately.
  • Rendering twice → identical bytes (FR-SCN-005).
  • 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/scenario/test_materialize.py.

Dependencies

Blocked by: #40 (T-027)

Blocks: #54 (T-033d), #201 (T-096a)

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/scenario/materialize.py

Independent 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-028 (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 05 §3 · doc 06 §3.2 · doc 10 §4 · doc 08 §7

Requirements: FR-SCN-005 (traceability: doc 28)

External:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:scenarioScenario space, sampling, scenario filesmilestone:M2M2 — Scenario + kinematic2dpriority:P1Required for milestone exitsize:S<= 1 daytaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions