feat(pcb_component): add relational_constraints for hierarchical auto-placement#570
Open
billwestrup wants to merge 1 commit into
Open
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
relational_constraintsfield topcb_componentto 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_alignmentfields cover deterministic relative placement (component A at exact offset from component B).relational_constraintscovers 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
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: addsrelational_constraintsto both the Zod schema and thePcbComponentTypeScript interfaceexpectTypesMatchpass cleanly (tsc --noEmitexit 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.