Skip to content

feat(pcb_component): add relational_constraints for hierarchical auto-placement#570

Open
billwestrup wants to merge 1 commit into
tscircuit:mainfrom
billwestrup:feat/pcb-component-placement-constraints
Open

feat(pcb_component): add relational_constraints for hierarchical auto-placement#570
billwestrup wants to merge 1 commit into
tscircuit:mainfrom
billwestrup:feat/pcb-component-placement-constraints

Conversation

@billwestrup
Copy link
Copy Markdown

Summary

Adds an optional relational_constraints field to pcb_component to express soft proximity relationships between components. This is useful for hierarchical and tile-based auto-placement pipelines.

Motivation

When building auto-placement engines for dense mixed-signal boards (e.g. RTLS trackers with nRF9151, nPM1300, nRF5340, BQ51013B co-located on a 50×82mm 2-layer PCB), you need a way to encode "this decoupling cap must stay within 8mm of its IC" without hard-coding absolute XY coordinates.

The existing position_mode / anchor_position / anchor_alignment fields cover deterministic relative placement (component A at exact offset from component B). relational_constraints covers the complementary soft constraint case — telling a physics-based or greedy placement engine what the goal is, while letting the engine decide the exact position.

Fields Added

relational_constraints?: {
  // Name of the target component to stay near (soft constraint)
  anchor_to?: string
  // Maximum allowed Euclidean distance in mm between centers
  max_distance?: number
  // Grouping hint for tile/cluster assignment
  keep_near?: string
}

All fields are optional. The constraints are advisory — they are intended to be consumed by placement engines, not enforced by Zod validation.

Example Usage

{
  "type": "pcb_component",
  "pcb_component_id": "pcb_component_C_DEC2",
  "source_component_id": "...",
  "center": { "x": -18.3, "y": -28.1 },
  "width": 1.6, "height": 0.8,
  "layer": "top", "rotation": 0,
  "obstructs_within_bounds": true,
  "relational_constraints": {
    "anchor_to": "U1_NRF9151",
    "max_distance": 8,
    "keep_near": "T1_RF"
  }
}

Changes

  • src/pcb/pcb_component.ts: adds relational_constraints to both the Zod schema and the PcbComponent TypeScript interface
  • Build and expectTypesMatch pass cleanly (tsc --noEmit exit 0)

Testing

The expectTypesMatch<PcbComponent, InferredPcbComponent>(true) structural check at the bottom of the file ensures the interface and Zod-inferred type stay in sync — this already validates the new field.

…gines

Adds an optional `relational_constraints` field to `pcb_component`
to express soft proximity relationships between components. This is
particularly useful for hierarchical auto-placement pipelines that need
to encode constraints like "this decoupling cap must stay within Nmm of
its IC" without hard-coding absolute coordinates.

Fields:
- `anchor_to`: name of the target component to stay near
- `max_distance`: maximum allowed Euclidean distance (mm) between centers
- `keep_near`: grouping hint for tile/cluster assignment

All fields are optional. The constraints are advisory — they are
intended to be consumed by placement engines rather than enforced
by the schema validator.

Motivated by real-world use in the Sentinel RTLS v6 PCB pipeline,
where 100+ components are placed across 6 hierarchical tiles and
proximity to anchor ICs (nRF9151, nPM1300, etc.) must be enforced
without relying on fixed coordinate systems.
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.

2 participants