by Drew Owens
Open-source 15-DoF XL330 biped goose robot with Spine molecule PCB, 3D-printed chassis, and Isaac Lab to MuJoCo sim-to-real RL stack
main
Drew Owens
Scrub internal hostnames, quota ledger, local paths, and private links for public release
09af481
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
#!/usr/bin/env python3
"""Single-source netlist, test-plan, library bundler, and BOM generator for microgoose-spine.
1. Copies verified symbols, footprints, and Z-up STEP models from .cache/mg-wiki-libs
into kicad/lib/ and kicad/3d/ (creating Fiducial_1mm_Mask2mm cleanly as well).
2. Writes design/tests.json and initial design/netlist.json.
3. After `adom-aiflow testplan check --add` appends TP* test points to netlist.json,
call with `--bom` to write design/bom.csv with verified 2026-11-11 stock & URLs.
"""
import csv
import json
import os
import re
import shutil
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
CACHE = Path(os.environ.get("MG_WIKI_LIBS_CACHE", ".cache/mg-wiki-libs"))
LIB_DIR = ROOT / "kicad" / "lib"
PRETTY_DIR = LIB_DIR / "Microgoose.pretty"
STEP_DIR = ROOT / "kicad" / "3d"
DESIGN_DIR = ROOT / "design"
# Verified catalog metadata with live 2026-11-11 stock checks
CATALOG = {
"STM32G431CBT6": {
"mfr": "STMicroelectronics",
"src": "Mouser 511-STM32G431CBT6",
"mouser_pn": "511-STM32G431CBT6",
"lcsc_pn": "C529355",
"stock": 7469,
"price_usd": 3.84,
"mass_g": 0.18,
"url": "https://www.mouser.com/ProductDetail/STMicroelectronics/STM32G431CBT6",
"note": "170 MHz Cortex-M4F Spine MCU, LQFP-48 0.5mm pitch",
"sym": "Microgoose:STM32G431CBT6",
"fp": "Microgoose:LQFP-48_7x7mm_P0.5mm",
"step": "stm32g431cbt6-etched.step",
},
"LMR33640DDDAR": {
"mfr": "Texas Instruments",
"src": "Mouser 595-LMR33640DDDAR",
"mouser_pn": "595-LMR33640DDDAR",
"lcsc_pn": "C2836966",
"stock": 91,
"price_usd": 2.95,
"mass_g": 0.08,
"url": "https://www.mouser.com/ProductDetail/Texas-Instruments/LMR33640DDDAR",
"note": "3.8-36V 4A 400kHz synchronous buck, SOIC-8 PowerPAD",
"sym": "Microgoose:LMR33640ADDAR",
"fp": "Microgoose:SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.41x3.3mm",
"step": "lmr33640addar-etched.step",
},
"AP2114H-3.3TRG1": {
"mfr": "Diodes Incorporated",
"src": "Mouser 621-AP2114H-3.3TRG1",
"mouser_pn": "621-AP2114H-3.3TRG1",
"lcsc_pn": "C150716",
"stock": 26863,
"price_usd": 0.42,
"mass_g": 0.11,
"url": "https://www.mouser.com/ProductDetail/Diodes-Incorporated/AP2114H-3.3TRG1",
"note": "3.3V 1A low-dropout linear regulator fed from 5V_BUS (Vin_max 6.0V), SOT-223",
"sym": "Microgoose:AP2114H-3.3TRG1",
"fp": "Microgoose:SOT-223-3_TabPin2",
"step": "ap2114h-3-3trg1-etched.step",
},
"INA226AIDGST": {
"mfr": "Texas Instruments",
"src": "Mouser 595-INA226AIDGST",
"mouser_pn": "595-INA226AIDGST",
"lcsc_pn": "C2653870",
"stock": 53,
"price_usd": 3.10,
"mass_g": 0.03,
"url": "https://www.mouser.com/ProductDetail/Texas-Instruments/INA226AIDGST",
"note": "36V bidirectional I2C current and bus-voltage monitor, VSSOP-10 0.5mm",
"sym": "Microgoose:INA226AIDGST",
"fp": "Microgoose:MSOP-10_3x3mm_P0.5mm",
"step": "ina226aidgst-etched.step",
},
"BMI270": {
"mfr": "Bosch Sensortec",
"src": "Mouser 262-BMI270",
"mouser_pn": "262-BMI270",
"lcsc_pn": "C2836813",
"stock": 14758,
"price_usd": 2.85,
"mass_g": 0.02,
"url": "https://www.mouser.com/ProductDetail/Bosch-Sensortec/BMI270",
"note": "6-axis torso inertial measurement unit (I2C addr 0x68), LGA-14 2.5x3.0mm",
"sym": "Microgoose:BMI270",
"fp": "Microgoose:BMI270",
"step": "BMI270.step",
},
"SN74LVC1G126DBVR": {
"mfr": "Texas Instruments",
"src": "Mouser 595-SN74LVC1G126DBVR",
"mouser_pn": "595-SN74LVC1G126DBVR",
"lcsc_pn": "C7834",
"stock": 91314,
"price_usd": 0.18,
"mass_g": 0.015,
"url": "https://www.mouser.com/ProductDetail/Texas-Instruments/SN74LVC1G126DBVR",
"note": "Single 3-state buffer (active-high OE) for 1 Mbps Dynamixel half-duplex TX, SOT-23-5",
"sym": "Microgoose:SN74LVC1G126DBVR",
"fp": "Microgoose:SOT-23-5",
"step": "sn74lvc1g126dbvr-etched.step",
},
"SN74AHCT1G125DBVR": {
"mfr": "Texas Instruments",
"src": "Mouser 595-SNAHCT1G125DBVR",
"mouser_pn": "595-SNAHCT1G125DBVR",
"lcsc_pn": "C43393",
"stock": 85981,
"price_usd": 0.19,
"mass_g": 0.015,
"url": "https://www.mouser.com/ProductDetail/Texas-Instruments/SN74AHCT1G125DBVR",
"note": "3.3V TTL to 5.0V CMOS level shifter (VIH=2.0V max) driving WS2812B-2020, SOT-23-5",
"sym": "Microgoose:SN74AHCT1G125DBVR",
"fp": "Microgoose:SOT-23-5_AHCT",
"step": "sn74ahct1g125dbvr-etched.step",
},
"74439346047": {
"mfr": "Wurth Elektronik",
"src": "Mouser 710-74439346047",
"mouser_pn": "710-74439346047",
"lcsc_pn": "",
"stock": 10825,
"price_usd": 2.45,
"mass_g": 1.15,
"url": "https://www.mouser.com/ProductDetail/Wurth-Elektronik/74439346047",
"note": "WE-XHMI 6060 4.7uH +-20% shielded inductor, DCR 14.5mOhm max, Irated 8.5A, Isat 11.0A",
"sym": "Microgoose:74439346047",
"fp": "Microgoose:74439346047",
"step": "74439346047-etched.step",
},
"CSS2H-2512R-L300F": {
"mfr": "Bourns",
"src": "Mouser 652-CSS2H-2512RL300F",
"mouser_pn": "652-CSS2H-2512RL300F",
"lcsc_pn": "",
"stock": 4226,
"price_usd": 1.80,
"mass_g": 0.12,
"url": "https://www.mouser.com/ProductDetail/Bourns/CSS2H-2512R-L300F",
"note": "0.3 mOhm 1% 6W 2512 metal-strip current-sense shunt for INA226",
"sym": "Microgoose:CSS2H-2512R-L300F",
"fp": "Microgoose:css2h-2512r-l300f",
"step": "css2h-2512r-l300f.step",
},
"BM03B-GHS-TBT": {
"mfr": "JST",
"src": "Mouser 306-BM03BGHSTBTLFSNN",
"mouser_pn": "306-BM03BGHSTBTLFSNN",
"lcsc_pn": "C161691",
"stock": 71,
"price_usd": 0.54,
"mass_g": 0.14,
"url": "https://www.mouser.com/ProductDetail/JST-Commercial/BM03B-GHS-TBTLFSN",
"note": "JST GH 1.25mm 3-pin top-entry SMT latching header (XL330 TTL branch: GND, 5V_BUS, DXL_DATA)",
"sym": "Microgoose:BM03B-GHS-TBT",
"fp": "Microgoose:BM03B-GHS-TBT",
"step": "bm03b-ghs-tbt.step",
},
"BM05B-GHS-TBT": {
"mfr": "JST",
"src": "Mouser 306-BM05BGHSTBTLFSNN",
"mouser_pn": "306-BM05BGHSTBTLFSNN",
"lcsc_pn": "C161693",
"stock": 30398,
"price_usd": 0.65,
"mass_g": 0.19,
"url": "https://www.mouser.com/ProductDetail/JST-Commercial/BM05B-GHS-TBTLFSN",
"note": "JST GH 1.25mm 5-pin top-entry SMT latching header (Radxa UART+5V / Head I2C+INT)",
"sym": "Microgoose:BM05B-GHS-TBT",
"fp": "Microgoose:BM05B-GHS-TBT",
"step": "bm05b-ghs-tbt.step",
},
"IN-S63BTG": {
"mfr": "Inolux",
"src": "Adom Basic Part / Mouser 743-IN-S63BTG",
"mouser_pn": "743-IN-S63BTG",
"lcsc_pn": "",
"stock": 5000,
"price_usd": 0.08,
"mass_g": 0.005,
"url": "https://wiki.adom.inc/adom/in-s63btg",
"note": "Adom Basic Part 0603 green LED, 5V_BUS power-good indicator (pin 1=K, pin 2=A)",
"sym": "Microgoose:IN-S63BTG",
"fp": "Microgoose:IN-S63BTG",
"step": "IN-S63BTG.step",
},
"WS2812B-2020": {
"mfr": "Worldsemi",
"src": "Adom Basic Part / LCSC C52917434",
"mouser_pn": "",
"lcsc_pn": "C52917434",
"stock": 4000,
"price_usd": 0.06,
"mass_g": 0.008,
"url": "https://wiki.adom.inc/adom/ws2812b-2020",
"note": "Adom Basic Part 2020 addressable RGB status pixel (1=DO, 2=GND, 3=DI, 4=VDD)",
"sym": "Microgoose:WS2812B-2020",
"fp": "Microgoose:WS2812B-2020",
"step": "WS2812B-2020.step",
},
# Adom Basic Parts 0603 1% resistors
"CQ03SAF4702T5E": {
"mfr": "UNI-ROYAL",
"src": "Adom Basic Part",
"mouser_pn": "",
"lcsc_pn": "C23179",
"stock": 10000,
"price_usd": 0.01,
"mass_g": 0.002,
"url": "https://wiki.adom.inc/adom/cq03saf4702t5e",
"note": "Adom Basic Part 47.0 kOhm 1% 0603 resistor",
"sym": "Microgoose:R_0603",
"fp": "Microgoose:R_0603_1608Metric",
"step": "CQ03WAF1002T5E-unetched.step",
},
"CQ03SAF3302T5E": {
"mfr": "UNI-ROYAL",
"src": "Adom Basic Part",
"mouser_pn": "",
"lcsc_pn": "C23140",
"stock": 10000,
"price_usd": 0.01,
"mass_g": 0.002,
"url": "https://wiki.adom.inc/adom/cq03saf3302t5e",
"note": "Adom Basic Part 33.0 kOhm 1% 0603 resistor",
"sym": "Microgoose:R_0603",
"fp": "Microgoose:R_0603_1608Metric",
"step": "CQ03WAF1002T5E-unetched.step",
},
"CQ03WAF1002T5E": {
"mfr": "UNI-ROYAL",
"src": "Adom Basic Part",
"mouser_pn": "",
"lcsc_pn": "C25804",
"stock": 10000,
"price_usd": 0.01,
"mass_g": 0.002,
"url": "https://wiki.adom.inc/adom/cq03waf1002t5e",
"note": "Adom Basic Part 10.0 kOhm 1% 0603 resistor",
"sym": "Microgoose:R_0603",
"fp": "Microgoose:R_0603_1608Metric",
"step": "CQ03WAF1002T5E-unetched.step",
},
"0603SAF1503T5E": {
"mfr": "UNI-ROYAL",
"src": "Adom Basic Part",
"mouser_pn": "",
"lcsc_pn": "C22807",
"stock": 10000,
"price_usd": 0.01,
"mass_g": 0.002,
"url": "https://wiki.adom.inc/adom/0603saf1503t5e",
"note": "Adom Basic Part 150 kOhm 1% 0603 resistor",
"sym": "Microgoose:R_0603",
"fp": "Microgoose:R_0603_1608Metric",
"step": "CQ03WAF1002T5E-unetched.step",
},
"CQ03WAF1003T5E": {
"mfr": "UNI-ROYAL",
"src": "Adom Basic Part",
"mouser_pn": "",
"lcsc_pn": "C25803",
"stock": 10000,
"price_usd": 0.01,
"mass_g": 0.002,
"url": "https://wiki.adom.inc/adom/cq03waf1003t5e",
"note": "Adom Basic Part 100 kOhm 1% 0603 resistor",
"sym": "Microgoose:R_0603",
"fp": "Microgoose:R_0603_1608Metric",
"step": "CQ03WAF1002T5E-unetched.step",
},
"CQ03WAF1001T5E": {
"mfr": "UNI-ROYAL",
"src": "Adom Basic Part",
"mouser_pn": "",
"lcsc_pn": "C21190",
"stock": 10000,
"price_usd": 0.01,
"mass_g": 0.002,
"url": "https://wiki.adom.inc/adom/cq03waf1001t5e",
"note": "Adom Basic Part 1.00 kOhm 1% 0603 resistor",
"sym": "Microgoose:R_0603",
"fp": "Microgoose:R_0603_1608Metric",
"step": "CQ03WAF1002T5E-unetched.step",
},
"CQ03SAF4701T5E": {
"mfr": "UNI-ROYAL",
"src": "Adom Basic Part",
"mouser_pn": "",
"lcsc_pn": "C23162",
"stock": 10000,
"price_usd": 0.01,
"mass_g": 0.002,
"url": "https://wiki.adom.inc/adom/cq03saf4701t5e",
"note": "Adom Basic Part 4.70 kOhm 1% 0603 I2C pull-up resistor",
"sym": "Microgoose:R_0603",
"fp": "Microgoose:R_0603_1608Metric",
"step": "CQ03WAF1002T5E-unetched.step",
},
"CQ03WAF1000T5E": {
"mfr": "UNI-ROYAL",
"src": "Adom Basic Part",
"mouser_pn": "",
"lcsc_pn": "C22775",
"stock": 10000,
"price_usd": 0.01,
"mass_g": 0.002,
"url": "https://wiki.adom.inc/adom/cq03waf1000t5e",
"note": "Adom Basic Part 100 Ohm 1% 0603 series protection/damping resistor",
"sym": "Microgoose:R_0603",
"fp": "Microgoose:R_0603_1608Metric",
"step": "CQ03WAF1002T5E-unetched.step",
},
# Adom Basic Parts MLCCs
"0603B104J500CT": {
"mfr": "Walsin",
"src": "Adom Basic Part / Mouser 791-0603B104J500CT",
"mouser_pn": "791-0603B104J500CT",
"lcsc_pn": "C14663",
"stock": 10000,
"price_usd": 0.01,
"mass_g": 0.004,
"url": "https://wiki.adom.inc/adom/0603b104j500ct",
"note": "Adom Basic Part 100 nF 50V X7R 0603 bypass/bootstrap capacitor",
"sym": "Microgoose:C_0603",
"fp": "Microgoose:C_0603_1608Metric",
"step": "0603B104J500CT-unetched.step",
},
"0603B105K160CT": {
"mfr": "Walsin",
"src": "Adom Basic Part",
"mouser_pn": "",
"lcsc_pn": "C15849",
"stock": 10000,
"price_usd": 0.015,
"mass_g": 0.004,
"url": "https://wiki.adom.inc/adom/0603b105k160ct",
"note": "Adom Basic Part 1.0 uF 16V X7R 0603 capacitor",
"sym": "Microgoose:C_0603",
"fp": "Microgoose:C_0603_1608Metric",
"step": "0603B104J500CT-unetched.step",
},
"0603X475K100CT": {
"mfr": "Walsin",
"src": "Adom Basic Part",
"mouser_pn": "",
"lcsc_pn": "C19666",
"stock": 10000,
"price_usd": 0.02,
"mass_g": 0.005,
"url": "https://wiki.adom.inc/adom/0603x475k100ct",
"note": "Adom Basic Part 4.7 uF 10V X5R 0603 LDO input capacitor",
"sym": "Microgoose:C_0603",
"fp": "Microgoose:C_0603_1608Metric",
"step": "0603B104J500CT-unetched.step",
},
"CL21A106KOQNNNG": {
"mfr": "Samsung Electro-Mechanics",
"src": "Adom Basic Part / Mouser 187-CL21A106KOQNNNG",
"mouser_pn": "187-CL21A106KOQNNNG",
"lcsc_pn": "C15850",
"stock": 10000,
"price_usd": 0.03,
"mass_g": 0.012,
"url": "https://wiki.adom.inc/adom/cl21a106koqnnng",
"note": "Adom Basic Part 10 uF 16V X5R 0805 capacitor (4.8uF eff at 8.4V)",
"sym": "Microgoose:C_0805",
"fp": "Microgoose:C_0805_2012Metric",
"step": "CL21A226MPQNNNE-unetched.step",
},
"CL21A226MPQNNNE": {
"mfr": "Samsung Electro-Mechanics",
"src": "Adom Basic Part / Mouser 187-CL21A226MPQNNNE",
"mouser_pn": "187-CL21A226MPQNNNE",
"lcsc_pn": "C45783",
"stock": 10000,
"price_usd": 0.04,
"mass_g": 0.014,
"url": "https://wiki.adom.inc/adom/cl21a226mpqnnne",
"note": "Adom Basic Part 22 uF 10V X5R 0805 output capacitor (9.9uF eff at 5.0V)",
"sym": "Microgoose:C_0805",
"fp": "Microgoose:C_0805_2012Metric",
"step": "CL21A226MPQNNNE-unetched.step",
},
# Molecule hardware & PCB features
"MachinePinLargeShort": {
"mfr": "Adom",
"src": "Adom Molecule Hardware",
"mouser_pn": "",
"lcsc_pn": "",
"stock": 1000,
"price_usd": 0.35,
"mass_g": 1.10,
"url": "https://wiki.adom.inc/adom/machinepinlargeshort",
"note": "Large short corner machine pin (5.2mm pad, 3.45mm plated drill) on 64x64mm base grid",
"sym": "Molecule:MachinePinLargeShort",
"fp": "Molecule:MachinePinLargeShort",
"step": "MachinePinLargeShort.step",
},
"MachineContactMedium": {
"mfr": "Adom",
"src": "Adom Molecule Hardware",
"mouser_pn": "",
"lcsc_pn": "",
"stock": 2000,
"price_usd": 0.15,
"mass_g": 0.12,
"url": "https://wiki.adom.inc/adom/machinecontactmedium",
"note": "Medium machine contact (1.3mm pad, 0.78mm plated drill) on 2mm outer edge grid",
"sym": "Molecule:MachineContactMedium",
"fp": "Molecule:MachineContactMedium",
"step": "MachineContactMedium.step",
},
}
def stage_libraries() -> None:
PRETTY_DIR.mkdir(parents=True, exist_ok=True)
MOL_PRETTY = LIB_DIR / "Molecule.pretty"
MOL_PRETTY.mkdir(parents=True, exist_ok=True)
STEP_DIR.mkdir(parents=True, exist_ok=True)
# Copy STEP models
step_sources = [
("stm32g431cbt6", "stm32g431cbt6-etched.step"),
("lmr33640addar", "lmr33640addar-etched.step"),
("ap2114h-3-3trg1", "ap2114h-3-3trg1-etched.step"),
("ina226aidgst", "ina226aidgst-etched.step"),
("bmi270", "BMI270.step"),
("sn74lvc1g126dbvr", "sn74lvc1g126dbvr-etched.step"),
("sn74ahct1g125dbvr", "sn74ahct1g125dbvr-etched.step"),
("74439346047", "74439346047-etched.step"),
("css2h-2512r-l300f", "css2h-2512r-l300f.step"),
("bm03b-ghs-tbt", "bm03b-ghs-tbt.step"),
("bm05b-ghs-tbt", "bm05b-ghs-tbt.step"),
("in-s63btg", "IN-S63BTG.step"),
("ws2812b-2020", "WS2812B-2020.step"),
("cq03waf1002t5e", "CQ03WAF1002T5E-unetched.step"),
("0603b104j500ct", "0603B104J500CT-unetched.step"),
("cl21a226mpqnnne", "CL21A226MPQNNNE-unetched.step"),
("machinepinlargeshort", "MachinePinLargeShort.step"),
("machinecontactmedium", "MachineContactMedium.step"),
("testpoint-pad-0-5mm", "Adom_TestPoint_D0.5mm.step"),
]
for slug, fname in step_sources:
src = CACHE / slug / fname
if not src.exists():
# Fallback to any .step in folder
cands = list((CACHE / slug).glob("*.step"))
src = cands[0]
fname = src.name
shutil.copy2(src, STEP_DIR / fname)
# Copy footprints and normalize top-level footprint name + ${KIPRJMOD}/3d/<step>
fp_map = [
("stm32g431cbt6/stm32g431cbt6.kicad_mod", PRETTY_DIR / "LQFP-48_7x7mm_P0.5mm.kicad_mod", "LQFP-48_7x7mm_P0.5mm", "stm32g431cbt6-etched.step"),
("lmr33640addar/lmr33640addar.kicad_mod", PRETTY_DIR / "SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.41x3.3mm.kicad_mod", "SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.41x3.3mm", "lmr33640addar-etched.step"),
("ap2114h-3-3trg1/ap2114h-3-3trg1.kicad_mod", PRETTY_DIR / "SOT-223-3_TabPin2.kicad_mod", "SOT-223-3_TabPin2", "ap2114h-3-3trg1-etched.step"),
("ina226aidgst/ina226aidgst.kicad_mod", PRETTY_DIR / "MSOP-10_3x3mm_P0.5mm.kicad_mod", "MSOP-10_3x3mm_P0.5mm", "ina226aidgst-etched.step"),
("bmi270/BMI270.kicad_mod", PRETTY_DIR / "BMI270.kicad_mod", "BMI270", "BMI270.step"),
("sn74lvc1g126dbvr/sn74lvc1g126dbvr.kicad_mod", PRETTY_DIR / "SOT-23-5.kicad_mod", "SOT-23-5", "sn74lvc1g126dbvr-etched.step"),
("sn74ahct1g125dbvr/sn74ahct1g125dbvr.kicad_mod", PRETTY_DIR / "SOT-23-5_AHCT.kicad_mod", "SOT-23-5_AHCT", "sn74ahct1g125dbvr-etched.step"),
("74439346047/74439346047.kicad_mod", PRETTY_DIR / "74439346047.kicad_mod", "74439346047", "74439346047-etched.step"),
("css2h-2512r-l300f/css2h-2512r-l300f.kicad_mod", PRETTY_DIR / "css2h-2512r-l300f.kicad_mod", "css2h-2512r-l300f", "css2h-2512r-l300f.step"),
("bm03b-ghs-tbt/bm03b-ghs-tbt.kicad_mod", PRETTY_DIR / "BM03B-GHS-TBT.kicad_mod", "BM03B-GHS-TBT", "bm03b-ghs-tbt.step"),
("bm05b-ghs-tbt/bm05b-ghs-tbt.kicad_mod", PRETTY_DIR / "BM05B-GHS-TBT.kicad_mod", "BM05B-GHS-TBT", "bm05b-ghs-tbt.step"),
("in-s63btg/IN-S63BTG.kicad_mod", PRETTY_DIR / "IN-S63BTG.kicad_mod", "IN-S63BTG", "IN-S63BTG.step"),
("ws2812b-2020/WS2812B-2020.kicad_mod", PRETTY_DIR / "WS2812B-2020.kicad_mod", "WS2812B-2020", "WS2812B-2020.step"),
("cq03waf1002t5e/CQ03WAF1002T5E.kicad_mod", PRETTY_DIR / "R_0603_1608Metric.kicad_mod", "R_0603_1608Metric", "CQ03WAF1002T5E-unetched.step"),
("0603b104j500ct/0603B104J500CT.kicad_mod", PRETTY_DIR / "C_0603_1608Metric.kicad_mod", "C_0603_1608Metric", "0603B104J500CT-unetched.step"),
("cl21a226mpqnnne/CL21A226MPQNNNE.kicad_mod", PRETTY_DIR / "C_0805_2012Metric.kicad_mod", "C_0805_2012Metric", "CL21A226MPQNNNE-unetched.step"),
("machinepinlargeshort/MachinePinLargeShort.kicad_mod", MOL_PRETTY / "MachinePinLargeShort.kicad_mod", "MachinePinLargeShort", "MachinePinLargeShort.step"),
("machinecontactmedium/MachineContactMedium.kicad_mod", MOL_PRETTY / "MachineContactMedium.kicad_mod", "MachineContactMedium", "MachineContactMedium.step"),
("testpoint-pad-0-5mm/Adom_TestPoint_D0.5mm.kicad_mod", PRETTY_DIR / "Adom_TestPoint_D0.5mm.kicad_mod", "Adom_TestPoint_D0.5mm", "Adom_TestPoint_D0.5mm.step"),
]
for rel_src, dst, fp_name, step_file in fp_map:
txt = (CACHE / rel_src).read_text()
txt = re.sub(r'^\(footprint\s+"[^"]+"', f'(footprint "{fp_name}"', txt, count=1)
if "(model " in txt:
txt = re.sub(r'\(model\s+"[^"]+"', f'(model "${{KIPRJMOD}}/3d/{step_file}"', txt, count=1)
else:
model_sexp = f'\t(model "${{KIPRJMOD}}/3d/{step_file}"\n\t\t(offset (xyz 0 0 0))\n\t\t(scale (xyz 1 1 1))\n\t\t(rotate (xyz 0 0 0))\n\t)\n)'
txt = txt.rstrip()[:-1] + model_sexp
dst.write_text(txt)
# Create optical Fiducial_1mm_Mask2mm footprint (no paste, top copper 1mm disc + 2mm mask opening)
fid_mod = """(footprint "Fiducial_1mm_Mask2mm"
\t(version 20241229)
\t(generator "microgoose")
\t(layer "F.Cu")
\t(property "Reference" "FID**" (at 0 -1.6 0) (layer "F.Fab") (hide yes) (effects (font (size 0.8 0.8) (thickness 0.15))))
\t(property "Value" "Fiducial" (at 0 1.6 0) (layer "F.Fab") (hide yes) (effects (font (size 0.8 0.8) (thickness 0.15))))
\t(attr smd exclude_from_pos_files)
\t(fp_circle (center 0 0) (end 1.1 0) (stroke (width 0.05) (type default)) (fill no) (layer "F.CrtYd"))
\t(pad "1" smd circle (at 0 0) (size 1.0 1.0) (layers "F.Cu" "F.Mask") (solder_mask_margin 0.5))
)
"""
(PRETTY_DIR / "Fiducial_1mm_Mask2mm.kicad_mod").write_text(fid_mod)
def build_initial_netlist_and_tests() -> None:
components = []
def add(ref: str, mpn: str, val: str, block: str, fixed: dict | None = None) -> None:
meta = CATALOG[mpn]
entry = {
"ref": ref,
"sym": meta["sym"],
"value": val,
"fp": meta["fp"],
"mpn": mpn,
"mfr": meta["mfr"],
"src": meta["src"],
"block": block,
}
if fixed is not None:
entry["fixed"] = fixed
components.append(entry)
# 1. Molecule Corner Pins (MP1=FL, MP2=FR, MP3=BL, MP4=BR on 64x64mm base grid)
add("MP1", "MachinePinLargeShort", "GND", "molecule", {"x": 0.0, "y": 0.0})
add("MP2", "MachinePinLargeShort", "GND", "molecule", {"x": 64.0, "y": 0.0})
add("MP3", "MachinePinLargeShort", "GND", "molecule", {"x": 0.0, "y": 64.0})
add("MP4", "MachinePinLargeShort", "GND", "molecule", {"x": 64.0, "y": 64.0})
# 2. Molecule Edge Contacts (MC1..MC10 on outer x=0 and x=64 columns, 4mm spacing)
add("MC1", "MachineContactMedium", "VBAT", "molecule", {"x": 0.0, "y": 16.0})
add("MC2", "MachineContactMedium", "VBAT", "molecule", {"x": 0.0, "y": 20.0})
add("MC3", "MachineContactMedium", "GND", "molecule", {"x": 0.0, "y": 24.0})
add("MC4", "MachineContactMedium", "5V_BUS", "molecule", {"x": 0.0, "y": 44.0})
add("MC5", "MachineContactMedium", "GND", "molecule", {"x": 0.0, "y": 48.0})
add("MC6", "MachineContactMedium", "SWDIO", "molecule", {"x": 64.0, "y": 20.0})
add("MC7", "MachineContactMedium", "SWCLK", "molecule", {"x": 64.0, "y": 24.0})
add("MC8", "MachineContactMedium", "NRST", "molecule", {"x": 64.0, "y": 28.0})
add("MC9", "MachineContactMedium", "GND", "molecule", {"x": 64.0, "y": 32.0})
add("MC10", "MachineContactMedium", "3V3", "molecule", {"x": 64.0, "y": 44.0})
# 3. Active ICs & Power Magnetics
add("U1", "LMR33640DDDAR", "LMR33640DDDAR", "buck")
add("L1", "74439346047", "4.7u", "buck")
add("R_SH1", "CSS2H-2512R-L300F", "0m3", "monitor") # Renamed below? Keep standard R20!
# Wait: use standard reference R20 for shunt so KiCad reference prefix is clean R<n>!
components.pop()
add("R20", "CSS2H-2512R-L300F", "0m3", "monitor")
add("U2", "AP2114H-3.3TRG1", "AP2114H-3.3", "ldo")
add("U3", "INA226AIDGST", "INA226", "monitor")
add("U4", "STM32G431CBT6", "STM32G431CBT6", "mcu")
add("U5", "BMI270", "BMI270", "imu")
add("U6", "SN74LVC1G126DBVR", "74LVC1G126", "dxl")
add("U7", "SN74AHCT1G125DBVR", "74AHCT1G125", "indicator")
# 4. Connectors (J1..J3 3-pin XL330 branches, J4 Radxa 5-pin, J5 Head Sensor 5-pin)
add("J1", "BM03B-GHS-TBT", "LEG_L_DXL", "connectors")
add("J2", "BM03B-GHS-TBT", "LEG_R_DXL", "connectors")
add("J3", "BM03B-GHS-TBT", "HEAD_DXL", "connectors")
add("J4", "BM05B-GHS-TBT", "RADXA_LINK", "connectors")
add("J5", "BM05B-GHS-TBT", "HEAD_I2C", "connectors")
# 5. LEDs
add("D1", "IN-S63BTG", "5V_OK", "indicator")
add("D2", "WS2812B-2020", "STATUS_RGB", "indicator")
# 6. Resistors (R1..R19, all 0603 Adom Basic Parts)
add("R1", "CQ03SAF4702T5E", "47k", "buck")
add("R2", "CQ03SAF3302T5E", "33k", "buck")
add("R3", "CQ03WAF1002T5E", "10k", "buck")
add("R4", "CQ03WAF1002T5E", "10k", "buck")
add("R5", "0603SAF1503T5E", "150k", "buck")
add("R6", "CQ03SAF4702T5E", "47k", "buck")
add("R7", "CQ03WAF1002T5E", "10k", "buck") # PG pullup to 3V3
add("R8", "CQ03WAF1002T5E", "10k", "mcu") # NRST pullup to 3V3
add("R9", "CQ03WAF1002T5E", "10k", "mcu") # BOOT0 pulldown to GND
add("R10", "CQ03WAF1002T5E", "10k", "dxl") # DXL_DIR pulldown to GND
add("R11", "CQ03WAF1003T5E", "100k", "monitor") # VBAT ADC top
add("R12", "CQ03SAF3302T5E", "33k", "monitor") # VBAT ADC bot
add("R13", "CQ03WAF1001T5E", "1k", "indicator") # D1 5V_OK series
add("R14", "CQ03WAF1002T5E", "10k", "dxl") # DXL_DATA pullup to 3V3
add("R15", "CQ03WAF1002T5E", "10k", "monitor") # INA_ALERT pullup to 3V3
add("R16", "CQ03SAF4701T5E", "4k7", "imu") # I2C_SCL pullup to 3V3
add("R17", "CQ03SAF4701T5E", "4k7", "imu") # I2C_SDA pullup to 3V3
add("R18", "CQ03WAF1000T5E", "100R", "dxl") # DXL_RX series protection
add("R19", "CQ03WAF1000T5E", "100R", "indicator")# WS2812B DI series damping
# 7. Capacitors (C1..C29, all 0603/0805 Adom Basic Parts)
add("C1", "CL21A106KOQNNNG", "10u", "buck")
add("C2", "CL21A106KOQNNNG", "10u", "buck")
add("C3", "CL21A106KOQNNNG", "10u", "buck")
add("C4", "0603B104J500CT", "100n", "buck")
add("C5", "0603B104J500CT", "100n", "buck") # BOOT
add("C6", "0603B105K160CT", "1u", "buck") # VCC internal LDO
add("C7", "CL21A226MPQNNNE", "22u", "buck")
add("C8", "CL21A226MPQNNNE", "22u", "buck")
add("C9", "CL21A226MPQNNNE", "22u", "buck")
add("C10", "CL21A226MPQNNNE", "22u", "buck")
add("C11", "0603B104J500CT", "100n", "buck") # 5V_BUS HF bypass
add("C12", "0603X475K100CT", "4u7", "ldo") # LDO input
add("C13", "0603B105K160CT", "1u", "mcu") # MCU VDDA bulk
add("C14", "0603B104J500CT", "100n", "mcu") # MCU VDD pin 24
add("C15", "0603B104J500CT", "100n", "mcu") # MCU VDD pin 36
add("C16", "0603B104J500CT", "100n", "mcu") # MCU VDD pin 48
add("C17", "0603B104J500CT", "100n", "mcu") # MCU VDDA/VREF+ pins 20,21
add("C18", "0603B104J500CT", "100n", "imu") # BMI270 VDD
add("C19", "0603B104J500CT", "100n", "imu") # BMI270 VDDIO
add("C20", "0603B104J500CT", "100n", "monitor") # INA226 VS
add("C21", "0603B104J500CT", "100n", "dxl") # 74LVC1G126 VCC
add("C22", "0603B104J500CT", "100n", "indicator")# 74AHCT1G125 VCC
add("C23", "0603B104J500CT", "100n", "indicator")# WS2812B VDD
add("C24", "0603B104J500CT", "100n", "mcu") # NRST filter
add("C25", "0603B104J500CT", "100n", "monitor") # VBAT_ADC filter
add("C26", "CL21A106KOQNNNG", "10u", "ldo") # LDO 3V3 output bulk
add("C27", "CL21A106KOQNNNG", "10u", "connectors")# J1 Left Leg local 5V bulk
add("C28", "CL21A106KOQNNNG", "10u", "connectors")# J2 Right Leg local 5V bulk
add("C29", "CL21A106KOQNNNG", "10u", "connectors")# J3 Head DXL local 5V bulk
nets = {
"VBAT": [
"MC1.1", "MC2.1",
"C1.1", "C2.1", "C3.1", "C4.1",
"U1.2", "R5.1", "R11.1",
],
"BUCK_EN": [
"R5.2", "R6.1", "U1.3",
],
"BUCK_BOOT": [
"U1.7", "C5.1",
],
"SW": [
"U1.8", "C5.2", "L1.1",
],
"BUCK_VCC": [
"U1.6", "C6.1",
],
"BUCK_PG": [
"U1.4", "R7.2", "U4.16", # PB0 reads buck power-good
],
"5V_RAW": [
"L1.2", "C7.1", "C8.1", "R20.1", "U3.10",
],
"5V_BUS": [
"R20.2", "U3.9", "U3.8",
"C9.1", "C10.1", "C11.1",
"R1.1",
"MC4.1",
"U2.3", "C12.1",
"R13.1",
"U7.5", "C22.1",
"D2.4", "C23.1",
"J1.2", "C27.1",
"J2.2", "C28.1",
"J3.2", "C29.1",
"J4.1", "J4.2",
],
"FB_MID": [
"R1.2", "R2.1",
],
"FB": [
"R2.2", "R3.1", "U1.5",
],
"FB_BOT_MID": [
"R3.2", "R4.1",
],
"PG_LED_A": [
"R13.2", "D1.2",
],
"3V3": [
"U2.2", "C26.1", "MC10.1",
"R7.1", "R8.1", "R14.1", "R15.1", "R16.1", "R17.1",
"U3.6", "C20.1",
"U4.1", "U4.20", "U4.21", "U4.24", "U4.36", "U4.48",
"C13.1", "C14.1", "C15.1", "C16.1", "C17.1",
"U5.5", "U5.8", "U5.10", "U5.12", "C18.1", "C19.1",
"U6.5", "C21.1",
"J5.1",
],
"NRST": [
"U4.7", "R8.2", "C24.1", "MC8.1",
],
"BOOT0": [
"U4.45", "R9.1",
],
"SWDIO": [
"U4.37", "MC6.1",
],
"SWCLK": [
"U4.38", "MC7.1",
],
"VBAT_ADC": [
"R11.2", "R12.1", "C25.1", "U4.8", # PA0
],
"LED_PWM_3V3": [
"U4.9", "U7.2", # PA1 -> 74AHCT1G125 A
],
"LED_DIN_BUF": [
"U7.4", "R19.1",
],
"LED_DIN": [
"R19.2", "D2.3",
],
"HOST_TX": [
"U4.10", "J4.4", # PA2 USART2_TX -> Radxa RX
],
"HOST_RX": [
"U4.11", "J4.5", # PA3 USART2_RX <- Radxa TX
],
"IMU_INT1": [
"U5.4", "U4.17", # BMI270 INT1 -> PB1
],
"INA_ALERT": [
"U3.3", "R15.2", "U4.18", # INA226 Alert -> PB2
],
"HEAD_INT": [
"J5.5", "U4.30", # Head ToF/IMU INT -> PA8
],
"I2C_SCL": [
"U4.43", "R16.2", "U3.5", "U5.13", "J5.3", # PB6 I2C1_SCL
],
"I2C_SDA": [
"U4.44", "R17.2", "U3.4", "U5.14", "J5.4", # PB7 I2C1_SDA
],
"DXL_TX": [
"U4.22", "U6.2", # PB10 USART3_TX -> 74LVC1G126 A
],
"DXL_RX": [
"U4.25", "R18.1", # PB11 USART3_RX <- 100R <- DXL_DATA
],
"DXL_DIR": [
"U4.26", "U6.1", "R10.1", # PB12 -> 74LVC1G126 OE
],
"DXL_DATA": [
"U6.4", "R18.2", "R14.2",
"J1.3", "J2.3", "J3.3",
],
"GND": [
"MP1.1", "MP2.1", "MP3.1", "MP4.1",
"MC3.1", "MC5.1", "MC9.1",
"C1.2", "C2.2", "C3.2", "C4.2", "C6.2",
"C7.2", "C8.2", "C9.2", "C10.2", "C11.2", "C12.2",
"C13.2", "C14.2", "C15.2", "C16.2", "C17.2",
"C18.2", "C19.2", "C20.2", "C21.2", "C22.2", "C23.2",
"C24.2", "C25.2", "C26.2", "C27.2", "C28.2", "C29.2",
"U1.1", "U1.9",
"R4.2", "R6.2", "R9.2", "R10.2", "R12.2",
"D1.1", "D2.2",
"U2.1",
"U3.1", "U3.2", "U3.7",
"U4.19", "U4.23", "U4.35", "U4.47",
"U5.1", "U5.2", "U5.3", "U5.6", "U5.7", "U5.11",
"U6.3",
"U7.1", "U7.3",
"J1.1", "J2.1", "J3.1", "J4.3", "J5.2",
"J1.MP", "J2.MP", "J3.MP", "J4.MP", "J5.MP",
],
}
netlist = {
"design": "microgoose-spine",
"components": components,
"nets": nets,
"molecule": {
"pin": "MachinePinLargeShort",
"grid_mm": 2,
"pin_span_mm": [64, 64],
"board_mm": [70, 70],
"edge_margin_mm": 3,
"origin": "centre of MP1 (FL) pin",
"corner_pins_net": "GND",
},
}
(DESIGN_DIR / "netlist.json").write_text(json.dumps(netlist, indent=2) + "\n")
tests = [
{"id": "gnd", "what": "Workcell probe ground tether", "net": "GND", "why": "Reference return on medium edge contact MC3/MC5/MC9", "kind": "ground", "expect": "0.00 V reference"},
{"id": "vbat", "what": "2S NP-F550 battery rail at board input", "net": "VBAT", "why": "Confirm battery path and input capacitor bank voltage", "kind": "dc", "expect": "6.0 V to 8.4 V (7.4 V nominal)"},
{"id": "en", "what": "Buck UVLO enable divider node", "net": "BUCK_EN", "why": "Verify UVLO rising threshold above 5.28 V", "kind": "dc", "expect": "1.77 V at 7.4 V input"},
{"id": "sw", "what": "Buck switch node waveform", "net": "SW", "why": "Check 400 kHz switching frequency, dead time, and overshoot", "kind": "waveform", "expect": "0 V to VBAT 400 kHz square wave"},
{"id": "v5_bus", "what": "Regulated 5.0 V servo and Radxa bus ripple", "net": "5V_BUS", "why": "Confirm 5.00 V regulation and <25 mVpp ripple under 2.5 A load", "kind": "ripple", "expect": "4.85 V to 5.15 V DC, <25 mVpp ripple"},
{"id": "fb", "what": "LMR33640 feedback node", "net": "FB", "why": "Verify closed-loop reference regulation at 1.000 V", "kind": "dc", "expect": "0.985 V to 1.015 V"},
{"id": "v3v3", "what": "3.3 V MCU and sensor logic rail", "net": "3V3", "why": "Confirm clean AP2114H linear regulation for STM32G431 and BMI270", "kind": "dc", "expect": "3.25 V to 3.35 V"},
{"id": "dxl", "what": "1 Mbps half-duplex Dynamixel XL330 TTL data line", "net": "DXL_DATA", "why": "Verify idle 3.3 V pull-up and clean 1 Mbps SyncRead/SyncWrite frames", "kind": "waveform", "expect": "3.3 V idle, 1.00 Mbps NRZ packets"},
{"id": "i2c_scl", "what": "400 kHz sensor I2C clock", "net": "I2C_SCL", "why": "Verify pull-up rise time and 400 kHz polling of BMI270 and INA226", "kind": "waveform", "expect": "3.3 V idle, 400 kHz clock"},
{"id": "i2c_sda", "what": "400 kHz sensor I2C data", "net": "I2C_SDA", "why": "Verify clean ACK frames from INA226 (0x40) and BMI270 (0x68)", "kind": "waveform", "expect": "3.3 V idle, clean data transitions"},
{"id": "led_pg", "what": "5V_BUS green power-good LED lit", "net": "PG_LED_A", "why": "Visual confirmation of 5.0 V rail regulation", "kind": "camera", "expect": "Green LED D1 illuminated when VBAT >= 6.0 V"},
{"id": "led_rgb", "what": "Addressable RGB status pixel active", "net": "LED_DIN", "why": "Visual confirmation of STM32G431 firmware boot and 5V level shift", "kind": "camera", "expect": "WS2812B D2 illuminated in status color"},
]
(DESIGN_DIR / "tests.json").write_text(json.dumps(tests, indent=2) + "\n")
print(f"OK: staged libraries and wrote initial netlist.json ({len(components)} components, {len(nets)} nets) and tests.json ({len(tests)} tests)")
def write_bom_from_netlist() -> None:
netlist = json.loads((DESIGN_DIR / "netlist.json").read_text())
grouped: dict[tuple[str, str], list[str]] = {}
comp_by_ref = {}
for c in netlist["components"]:
ref = c["ref"]
comp_by_ref[ref] = c
mpn = c.get("mpn") or ("TP_0.5mm" if ref.startswith("TP") else ref)
val = c.get("value", "")
key = (mpn, val)
grouped.setdefault(key, []).append(ref)
bom_path = DESIGN_DIR / "bom.csv"
fields = [
"reference",
"qty",
"value",
"footprint",
"mpn",
"manufacturer",
"source",
"mouser_pn",
"lcsc_pn",
"stock_checked_2026-11-11",
"unit_price_usd",
"mass_g",
"mpn_url",
"note",
]
with bom_path.open("w", newline="") as f:
w = csv.DictWriter(f, fieldnames=fields)
w.writeheader()
for (mpn, val), refs in grouped.items():
sample = comp_by_ref[refs[0]]
if refs[0].startswith("TP") or "TestPoint" in sample.get("fp", ""):
w.writerow({
"reference": " ".join(refs),
"qty": len(refs),
"value": val or "TP",
"footprint": sample.get("fp", "Microgoose:Adom_TestPoint_D0.5mm"),
"mpn": "no part",
"manufacturer": "PCB Feature",
"source": "PCB Feature",
"mouser_pn": "",
"lcsc_pn": "",
"stock_checked_2026-11-11": "pcb_feature",
"unit_price_usd": "0.00",
"mass_g": "0.0",
"mpn_url": "",
"note": "0.5 mm exposed-copper workcell probe pad, no paste",
})
continue
meta = CATALOG[mpn]
w.writerow({
"reference": " ".join(refs),
"qty": len(refs),
"value": val,
"footprint": sample["fp"],
"mpn": mpn,
"manufacturer": meta["mfr"],
"source": meta["src"],
"mouser_pn": meta["mouser_pn"],
"lcsc_pn": meta["lcsc_pn"],
"stock_checked_2026-11-11": str(meta["stock"]),
"unit_price_usd": f"{meta['price_usd']:.3f}",
"mass_g": f"{meta['mass_g']:.4f}",
"mpn_url": meta["url"],
"note": meta["note"],
})
# Also include bare PCB mass row? Keep only electrical/board refs so sourcing diff against board is 1:1!
print(f"OK: wrote {bom_path} ({len(grouped)} unique BOM lines covering {len(netlist['components'])} board references)")
if __name__ == "__main__":
if "--bom" in sys.argv:
write_bom_from_netlist()
else:
stage_libraries()
build_initial_netlist_and_tests()