Skip to content

feat: route sensors by entity_name (M3.6 / ADR-0012 S4) - #138

Merged
KraHsu merged 1 commit into
devfrom
feat/m3-6-s4-sensor-entity
May 23, 2026
Merged

KraHsu merged 1 commit into
devfrom
feat/m3-6-s4-sensor-entity

Conversation

@KraHsu

@KraHsu KraHsu commented May 22, 2026

Copy link
Copy Markdown
Owner

What

Slice S4 — sensors gain SensorCfg.entity_name (default "robot") and attach to / read
from the named scene entity. Backward-compatible (default → primary; single-robot
scenes unchanged).

  • sensor/_entity.py (new): entity_handle / entity_state / entity_articulation
    resolve env.articulations[entity_name] with a primary fallback. It lives in the sensor
    layer
    on purpose — mdp._helpers imports sensor.contact, so a sensor importing it back
    would form a cycle.
  • All nine sensors (camera, force_torque, contact, self_contact, imu, ray_cast,
    body_velocity, frame_transformer, angular_momentum) now reach their entity's
    gs_handle / RobotState / articulation and resolve their link/joint indices
    against that entity's name tables (not the primary's) — correct for heterogeneous robots.

Reviewer-caught regressions (fixed)

The full suite earned its keep again:

  1. entity_articulation first fell back to env.articulation directly → 67 failures from
    minimal fakes that expose link_names at env-level. Fixed to getattr(env, "articulation", env)
    (matching mdp.resolve_articulation).
  2. FT fake articulation lacked joint_names (FT now resolves joints against the entity) → gave
    it joint_names.
  3. Camera error-message wording assertion → updated (env.link_names → link_names).

Tests

tests/test_multi_robot.py +2 — resolver selection/fallback + a ForceTorqueSensor with
entity_name="robot_b" resolving/reading that entity. All sensor suites green.

Gates

  • ruff ✓ · ruff format (full repo) ✓ · pyright 0/0/0 · lint-imports 6 kept / 0 broken
  • full suite 464 passed

🤖 Generated with Claude Code

Sensors gain SensorCfg.entity_name (default "robot") and attach to / read from the named
scene entity instead of the singular accessors.

- sensor/_entity.py (new): entity_handle / entity_state / entity_articulation resolve
  env.articulations[entity_name] with a primary fallback (env.robot / env.robot_state /
  env.articulation, then env itself for minimal fakes). Lives in the sensor layer because
  mdp._helpers imports sensor.contact — a sensor importing it back would cycle.
- All nine sensors (camera, force_torque, contact, self_contact, imu, ray_cast,
  body_velocity, frame_transformer, angular_momentum) reach their entity's gs_handle /
  RobotState / articulation via entity_name, and resolve link/joint indices against that
  entity's name tables (not the primary's) for heterogeneous-multi-robot correctness.

Backward-compatible: entity_name defaults to primary "robot"; single-robot scenes unchanged
(managers/scene wire sensors as before). Test fakes: the FT fake articulation gains
joint_names (real entity has it); camera/FT error-message wording dropped the "env." prefix.

Gates: ruff ✓, ruff format ✓ (full repo), pyright 0/0/0, lint-imports 6 kept / 0 broken,
full suite 464 passed (+2).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@KraHsu
KraHsu merged commit ecec8b1 into dev May 23, 2026
3 checks passed
@KraHsu
KraHsu deleted the feat/m3-6-s4-sensor-entity branch May 23, 2026 02:07
KraHsu added a commit that referenced this pull request Jun 5, 2026
feat: route sensors by entity_name (M3.6 / ADR-0012 S4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant