@holoscript/core 7.0.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/README.md +2 -2
  2. package/bin/holoscript.cjs +3 -0
  3. package/dist/GLTFPipeline-276GE64O.js +16 -0
  4. package/dist/GLTFPipeline-M7WSSJED.cjs +37 -0
  5. package/dist/HoloScriptPlusParser-7FBIFUFC.js +693 -0
  6. package/dist/HoloScriptPlusParser-A2W7OCN2.cjs +698 -0
  7. package/dist/HoloScriptPlusParser-F2Z56FJR.js +10 -0
  8. package/dist/HoloScriptPlusParser-WKHRIH6T.cjs +27 -0
  9. package/dist/HoloScriptRuntime-3URVTKPJ.js +10 -0
  10. package/dist/HoloScriptRuntime-SXEAEU2N.cjs +19 -0
  11. package/dist/USDZExporter-3FWJ25JI.cjs +1037 -0
  12. package/dist/USDZExporter-D2HQLQYK.js +1035 -0
  13. package/dist/agents/index.cjs +19 -0
  14. package/dist/agents/index.d.ts +100 -0
  15. package/dist/agents/index.js +17 -0
  16. package/dist/chunk-23J755AR.js +1046 -0
  17. package/dist/chunk-253GBQZY.cjs +627 -0
  18. package/dist/chunk-25IQCHTO.cjs +781 -0
  19. package/dist/chunk-2BSMSUCE.js +1941 -0
  20. package/dist/chunk-2M2DPHKB.js +762 -0
  21. package/dist/chunk-2YSNA2F2.cjs +1274 -0
  22. package/dist/chunk-3AO425MZ.cjs +886 -0
  23. package/dist/chunk-3FOKASKO.cjs +348 -0
  24. package/dist/chunk-3HYYMEXI.cjs +56578 -0
  25. package/dist/chunk-3NFFOWGG.js +4287 -0
  26. package/dist/chunk-3WZEJHUQ.cjs +116 -0
  27. package/dist/chunk-4C57PR42.js +468 -0
  28. package/dist/chunk-4N4SXXWF.js +769 -0
  29. package/dist/chunk-4PDEPEQW.cjs +41 -0
  30. package/dist/chunk-4R6SBXDB.js +45 -0
  31. package/dist/chunk-4V2E7U7Q.cjs +2015 -0
  32. package/dist/chunk-5FSKKMR7.cjs +2092 -0
  33. package/dist/chunk-5GLCTO44.js +161 -0
  34. package/dist/chunk-5JEU52DW.js +382 -0
  35. package/dist/chunk-5S7RKFGR.cjs +446 -0
  36. package/dist/chunk-5WUNN6ZN.cjs +428 -0
  37. package/dist/chunk-62FBK3B7.js +70 -0
  38. package/dist/chunk-6CTRH7HT.cjs +1985 -0
  39. package/dist/chunk-6DPSFNJB.cjs +847 -0
  40. package/dist/chunk-6EX3I5P4.cjs +130 -0
  41. package/dist/chunk-73FELZVJ.cjs +611 -0
  42. package/dist/chunk-7CUEMLDZ.cjs +6445 -0
  43. package/dist/chunk-7HIASF7S.cjs +814 -0
  44. package/dist/chunk-A6KINLZJ.js +236 -0
  45. package/dist/chunk-AIA52I7T.cjs +543 -0
  46. package/dist/chunk-ANXZFVY2.js +113 -0
  47. package/dist/chunk-AYBXB26F.js +2176 -0
  48. package/dist/chunk-B4TFTDG4.js +449 -0
  49. package/dist/chunk-BE4UJCQT.js +623 -0
  50. package/dist/chunk-BRQJKJGT.cjs +20 -0
  51. package/dist/chunk-C2A5DUMF.cjs +689 -0
  52. package/dist/chunk-C37BHB7N.cjs +636 -0
  53. package/dist/chunk-CBJY23VL.js +126 -0
  54. package/dist/chunk-CIWWXYHZ.cjs +50 -0
  55. package/dist/chunk-CXFDRBQU.cjs +672 -0
  56. package/dist/chunk-D54CNIAJ.cjs +413 -0
  57. package/dist/chunk-DAJXW4KX.js +725 -0
  58. package/dist/chunk-DTGBOSEM.cjs +319 -0
  59. package/dist/chunk-E7JP3BS3.cjs +61 -0
  60. package/dist/chunk-EKBKLK7P.js +1169 -0
  61. package/dist/chunk-EKYL4PE3.cjs +404 -0
  62. package/dist/chunk-EUDQTK7N.cjs +4310 -0
  63. package/dist/chunk-EXKSFGSX.cjs +274 -0
  64. package/dist/chunk-EXUP2BUM.cjs +1173 -0
  65. package/dist/chunk-F43YAA34.js +623 -0
  66. package/dist/chunk-FDSGHPAK.js +130 -0
  67. package/dist/chunk-FEWUHQNM.cjs +144 -0
  68. package/dist/chunk-FGGJQRLZ.js +270 -0
  69. package/dist/chunk-FHP6LXJS.js +415 -0
  70. package/dist/chunk-FJPADH77.cjs +666 -0
  71. package/dist/chunk-FYSPZT4V.cjs +169 -0
  72. package/dist/chunk-GIOYPNTH.js +5575 -0
  73. package/dist/chunk-GJNCFRJU.cjs +125 -0
  74. package/dist/chunk-GMP623FG.cjs +1508 -0
  75. package/dist/chunk-GQHQOPXZ.cjs +5580 -0
  76. package/dist/chunk-GQT4TYKY.cjs +4381 -0
  77. package/dist/chunk-GTU2Z2WW.cjs +262 -0
  78. package/dist/chunk-GYZE55MO.js +2007 -0
  79. package/dist/chunk-GZG4KA4E.js +529 -0
  80. package/dist/chunk-H652NHX5.js +600 -0
  81. package/dist/chunk-HCCQLAA4.cjs +74 -0
  82. package/dist/chunk-HINXWAOD.cjs +1049 -0
  83. package/dist/chunk-HYNTS5CP.js +422 -0
  84. package/dist/chunk-HZSPDCXV.cjs +457 -0
  85. package/dist/chunk-HZTDET3N.js +1399 -0
  86. package/dist/chunk-I6XZ5DZF.cjs +488 -0
  87. package/dist/chunk-ILRBGFVD.cjs +72 -0
  88. package/dist/chunk-IPWSXCCN.js +1183 -0
  89. package/dist/chunk-IUTY5WQ2.cjs +424 -0
  90. package/dist/chunk-IVSZDECV.js +882 -0
  91. package/dist/chunk-IVY74O6C.js +247 -0
  92. package/dist/chunk-IZM5VQZD.js +714 -0
  93. package/dist/chunk-J32ZJZJH.js +554 -0
  94. package/dist/chunk-J6M4FPK5.js +421 -0
  95. package/dist/chunk-JC5YBPSF.cjs +984 -0
  96. package/dist/chunk-JCLBKPMX.js +3813 -0
  97. package/dist/chunk-JD7CIZ33.js +1949 -0
  98. package/dist/chunk-JIYN45TV.cjs +2525 -0
  99. package/dist/chunk-JJBE3TIH.cjs +1189 -0
  100. package/dist/chunk-JX7YL6ZE.js +2252 -0
  101. package/dist/chunk-K4VVR7CN.cjs +2433 -0
  102. package/dist/chunk-KEFNV2WM.cjs +2257 -0
  103. package/dist/chunk-KH4CNH66.cjs +424 -0
  104. package/dist/chunk-KJLB4OPV.js +5731 -0
  105. package/dist/chunk-KKFZ3B6J.cjs +557 -0
  106. package/dist/chunk-KKP7JKN4.cjs +6002 -0
  107. package/dist/chunk-KPJL34Y7.cjs +186 -0
  108. package/dist/chunk-KQCN6AKJ.cjs +3042 -0
  109. package/dist/chunk-KVRSTFNH.cjs +72 -0
  110. package/dist/chunk-LICPB5HZ.cjs +1409 -0
  111. package/dist/chunk-LM2VU56C.cjs +37 -0
  112. package/dist/chunk-M56JSP4A.js +400 -0
  113. package/dist/chunk-MBOOR7X4.js +18 -0
  114. package/dist/chunk-MGE5Z4GS.js +608 -0
  115. package/dist/chunk-MXFUTKCO.js +56 -0
  116. package/dist/chunk-MYY4PMWX.cjs +264 -0
  117. package/dist/chunk-N75IH2HY.js +258 -0
  118. package/dist/chunk-NBMHU6SW.js +669 -0
  119. package/dist/chunk-NG77ATEW.cjs +778 -0
  120. package/dist/chunk-NGKREZ36.js +6384 -0
  121. package/dist/chunk-NHWSN2SD.cjs +718 -0
  122. package/dist/chunk-NV4VMVXU.js +421 -0
  123. package/dist/chunk-NW5G5FBQ.js +215 -0
  124. package/dist/chunk-NXZFOPVD.cjs +5737 -0
  125. package/dist/chunk-OBIYPYYS.cjs +1993 -0
  126. package/dist/chunk-OIQYIIO3.cjs +473 -0
  127. package/dist/chunk-OL46QLBJ.js +61 -0
  128. package/dist/chunk-OMXII44L.js +5386 -0
  129. package/dist/chunk-OR4Q2BGL.cjs +759 -0
  130. package/dist/chunk-OSYNRVOV.cjs +243 -0
  131. package/dist/chunk-PGANYCAG.cjs +220 -0
  132. package/dist/chunk-PHENW4MQ.js +65 -0
  133. package/dist/chunk-PHVRG4I2.js +844 -0
  134. package/dist/chunk-Q56TT7IL.js +483 -0
  135. package/dist/chunk-QPOQ7VPI.js +1491 -0
  136. package/dist/chunk-QPSKHBJP.js +5963 -0
  137. package/dist/chunk-QXH7QDSZ.js +1989 -0
  138. package/dist/chunk-R75BSDH7.cjs +50 -0
  139. package/dist/chunk-RARB3MBR.js +207 -0
  140. package/dist/chunk-RVBHAXFG.js +56160 -0
  141. package/dist/chunk-S3MDHNKB.cjs +490 -0
  142. package/dist/chunk-S4W6Z2MN.js +2426 -0
  143. package/dist/chunk-S6YWHCKV.cjs +410 -0
  144. package/dist/chunk-SIEXCILW.js +229 -0
  145. package/dist/chunk-SJBGLS25.cjs +2196 -0
  146. package/dist/chunk-SLU6UPJI.cjs +410 -0
  147. package/dist/chunk-SMIWS6DE.cjs +212 -0
  148. package/dist/chunk-T2QCTZMO.js +811 -0
  149. package/dist/chunk-T5J7ZKP3.cjs +4885 -0
  150. package/dist/chunk-TDCNJHWO.js +341 -0
  151. package/dist/chunk-TG7O4WBC.js +406 -0
  152. package/dist/chunk-THCK6ECW.js +2085 -0
  153. package/dist/chunk-TJHVSBP2.js +439 -0
  154. package/dist/chunk-TVHSPJ4N.cjs +606 -0
  155. package/dist/chunk-U44IKGG7.cjs +5390 -0
  156. package/dist/chunk-UJXISJBN.js +487 -0
  157. package/dist/chunk-UM6C3CGK.js +4375 -0
  158. package/dist/chunk-UMABK6SI.js +686 -0
  159. package/dist/chunk-UOIGFQXC.cjs +9750 -0
  160. package/dist/chunk-URG2SJLK.js +2521 -0
  161. package/dist/chunk-V6MKC2FZ.js +979 -0
  162. package/dist/chunk-VECQYRXL.js +474 -0
  163. package/dist/chunk-VJ3L7CHT.cjs +169 -0
  164. package/dist/chunk-VMLKSV26.js +1216 -0
  165. package/dist/chunk-VVKVQZI6.js +55 -0
  166. package/dist/chunk-W6RW64BB.cjs +1219 -0
  167. package/dist/chunk-W7VDOASB.cjs +639 -0
  168. package/dist/chunk-WDT3JTGM.cjs +483 -0
  169. package/dist/chunk-WJIHFLMJ.js +404 -0
  170. package/dist/chunk-WKX5AMOY.js +309 -0
  171. package/dist/chunk-WNNE3PO3.js +34 -0
  172. package/dist/chunk-WRKUDAZJ.js +3038 -0
  173. package/dist/chunk-WRLUBRKS.cjs +1943 -0
  174. package/dist/chunk-WRNEH5MO.js +3169 -0
  175. package/dist/chunk-WRWEX5ZF.js +658 -0
  176. package/dist/chunk-X3GJPRVK.cjs +3246 -0
  177. package/dist/chunk-XHIV6326.cjs +793 -0
  178. package/dist/chunk-XIVIE43A.cjs +729 -0
  179. package/dist/chunk-XJAN7CZG.cjs +432 -0
  180. package/dist/chunk-XKTPFXGA.js +164 -0
  181. package/dist/chunk-XL6INWKT.js +121 -0
  182. package/dist/chunk-XSFNHP2E.js +632 -0
  183. package/dist/chunk-XT6JY5W5.js +9684 -0
  184. package/dist/chunk-XUILI4KB.cjs +430 -0
  185. package/dist/chunk-XUUVDHIF.cjs +3962 -0
  186. package/dist/chunk-YF2I3MV3.js +46 -0
  187. package/dist/chunk-YIMN575O.js +4847 -0
  188. package/dist/chunk-YIVFJNYV.js +176 -0
  189. package/dist/chunk-YKGPCZEE.cjs +237 -0
  190. package/dist/chunk-YN6V7R3L.cjs +327 -0
  191. package/dist/chunk-YQELFNJV.js +39 -0
  192. package/dist/chunk-YYXH45E2.js +426 -0
  193. package/dist/chunk-ZBQXLH2L.js +756 -0
  194. package/dist/chunk-ZDSYWBIE.cjs +69 -0
  195. package/dist/chunk-ZU7NIRT6.js +325 -0
  196. package/dist/chunk-ZZ7RO2UQ.js +1243 -0
  197. package/dist/chunk-ZZEI7MV4.js +778 -0
  198. package/dist/cli/holoscript-runner.cjs +2255 -0
  199. package/dist/cli/holoscript-runner.js +2230 -0
  200. package/dist/codebase/index.cjs +336 -0
  201. package/dist/codebase/index.js +331 -0
  202. package/dist/compiler/agent-inference.cjs +31 -0
  203. package/dist/compiler/agent-inference.js +8 -0
  204. package/dist/compiler/android-xr.cjs +24 -0
  205. package/dist/compiler/android-xr.js +14 -0
  206. package/dist/compiler/android.cjs +24 -0
  207. package/dist/compiler/android.js +14 -0
  208. package/dist/compiler/ar.cjs +23 -0
  209. package/dist/compiler/ar.js +11 -0
  210. package/dist/compiler/babylon.cjs +21 -0
  211. package/dist/compiler/babylon.js +15 -0
  212. package/dist/compiler/business-quest.cjs +43 -0
  213. package/dist/compiler/business-quest.js +4 -0
  214. package/dist/compiler/coco.cjs +27 -0
  215. package/dist/compiler/coco.js +4 -0
  216. package/dist/compiler/context.cjs +25 -0
  217. package/dist/compiler/context.d.ts +28 -0
  218. package/dist/compiler/context.js +8 -0
  219. package/dist/compiler/domain-block-utils.cjs +605 -0
  220. package/dist/compiler/domain-block-utils.js +11 -0
  221. package/dist/compiler/dtdl.cjs +27 -0
  222. package/dist/compiler/dtdl.js +11 -0
  223. package/dist/compiler/gltf-pipeline.cjs +39 -0
  224. package/dist/compiler/gltf-pipeline.js +4 -0
  225. package/dist/compiler/godot.cjs +18 -0
  226. package/dist/compiler/godot.js +12 -0
  227. package/dist/compiler/incremental.cjs +34 -0
  228. package/dist/compiler/incremental.js +9 -0
  229. package/dist/compiler/index.cjs +5860 -0
  230. package/dist/compiler/index.d.ts +322 -21
  231. package/dist/compiler/index.js +5525 -0
  232. package/dist/compiler/ios.cjs +23 -0
  233. package/dist/compiler/ios.js +13 -0
  234. package/dist/compiler/llm-provider-capabilities.cjs +25 -0
  235. package/dist/compiler/llm-provider-capabilities.d.ts +43 -0
  236. package/dist/compiler/llm-provider-capabilities.js +8 -0
  237. package/dist/compiler/multi-layer.cjs +24 -0
  238. package/dist/compiler/multi-layer.js +15 -0
  239. package/dist/compiler/nodetoy.cjs +23 -0
  240. package/dist/compiler/nodetoy.js +4 -0
  241. package/dist/compiler/openxr.cjs +19 -0
  242. package/dist/compiler/openxr.js +13 -0
  243. package/dist/compiler/playcanvas.cjs +19 -0
  244. package/dist/compiler/playcanvas.js +13 -0
  245. package/dist/compiler/r3f.cjs +38 -0
  246. package/dist/compiler/r3f.d.ts +22 -0
  247. package/dist/compiler/r3f.js +16 -0
  248. package/dist/compiler/remotion.cjs +23 -0
  249. package/dist/compiler/remotion.js +4 -0
  250. package/dist/compiler/reproducibility.cjs +39 -0
  251. package/dist/compiler/reproducibility.js +4 -0
  252. package/dist/compiler/sdf.cjs +24 -0
  253. package/dist/compiler/sdf.js +12 -0
  254. package/dist/compiler/semantic-scene.cjs +31 -0
  255. package/dist/compiler/semantic-scene.js +4 -0
  256. package/dist/compiler/state.cjs +21 -0
  257. package/dist/compiler/state.js +11 -0
  258. package/dist/compiler/trait-composition.cjs +30 -0
  259. package/dist/compiler/trait-composition.js +9 -0
  260. package/dist/compiler/unity.cjs +19 -0
  261. package/dist/compiler/unity.js +13 -0
  262. package/dist/compiler/unreal.cjs +23 -0
  263. package/dist/compiler/unreal.js +13 -0
  264. package/dist/compiler/urdf.cjs +52 -0
  265. package/dist/compiler/urdf.js +12 -0
  266. package/dist/compiler/usd-physics.cjs +26 -0
  267. package/dist/compiler/usd-physics.js +9 -0
  268. package/dist/compiler/visionos.cjs +19 -0
  269. package/dist/compiler/visionos.js +13 -0
  270. package/dist/compiler/vrchat.cjs +22 -0
  271. package/dist/compiler/vrchat.js +12 -0
  272. package/dist/compiler/vrr.cjs +24 -0
  273. package/dist/compiler/vrr.js +12 -0
  274. package/dist/compiler/wasm.cjs +36 -0
  275. package/dist/compiler/wasm.js +12 -0
  276. package/dist/compiler/webgpu.cjs +18 -0
  277. package/dist/compiler/webgpu.js +12 -0
  278. package/dist/coordinators/index.cjs +1266 -0
  279. package/dist/coordinators/index.d.ts +72 -1
  280. package/dist/coordinators/index.js +1259 -0
  281. package/dist/debugger.cjs +24 -0
  282. package/dist/debugger.js +11 -0
  283. package/dist/entries/interop.cjs +64 -0
  284. package/dist/entries/interop.js +7 -0
  285. package/dist/entries/scripting.cjs +55 -0
  286. package/dist/entries/scripting.js +10 -0
  287. package/dist/hololand/index.cjs +146 -0
  288. package/dist/hololand/index.d.ts +70 -0
  289. package/dist/hololand/index.js +5 -0
  290. package/dist/index.cjs +43233 -0
  291. package/dist/index.d.ts +976 -21
  292. package/dist/index.js +39995 -0
  293. package/dist/math/tropical-spmv.cjs +45 -0
  294. package/dist/math/tropical-spmv.js +4 -0
  295. package/dist/math/vec3.cjs +57 -0
  296. package/dist/math/vec3.js +4 -0
  297. package/dist/ml-dsa-FSKBTE3W.cjs +1265 -0
  298. package/dist/ml-dsa-Z7JDKW4L.js +1265 -0
  299. package/dist/paper-0c-spike/index.cjs +150 -0
  300. package/dist/paper-0c-spike/index.js +141 -0
  301. package/dist/parser.cjs +61 -0
  302. package/dist/parser.d.ts +11 -0
  303. package/dist/parser.js +12 -0
  304. package/dist/playwright-3AT3AKTV.cjs +98673 -0
  305. package/dist/playwright-VZPDVUEQ.js +98660 -0
  306. package/dist/reconstruction/index.cjs +153 -0
  307. package/dist/reconstruction/index.d.ts +29 -2
  308. package/dist/reconstruction/index.js +8 -0
  309. package/dist/runtime.cjs +316 -0
  310. package/dist/runtime.d.ts +61 -0
  311. package/dist/runtime.js +31 -0
  312. package/dist/self-improvement/index.cjs +563 -0
  313. package/dist/self-improvement/index.js +545 -0
  314. package/dist/storage/index.cjs +38 -0
  315. package/dist/storage/index.js +5 -0
  316. package/dist/testing.cjs +25 -0
  317. package/dist/testing.d.ts +70 -0
  318. package/dist/testing.js +4 -0
  319. package/dist/traitDocs/traitDocs.cjs +33 -0
  320. package/dist/traitDocs/traitDocs.js +7 -0
  321. package/dist/traits/botanical-lotus.cjs +41 -0
  322. package/dist/traits/botanical-lotus.d.ts +172 -0
  323. package/dist/traits/botanical-lotus.js +4 -0
  324. package/dist/traits/engines/index.cjs +520 -0
  325. package/dist/traits/engines/index.js +380 -0
  326. package/dist/traits/index.cjs +24409 -0
  327. package/dist/traits/index.d.ts +171 -35
  328. package/dist/traits/index.js +21634 -0
  329. package/dist/traits/simulation-solver-factory.cjs +13 -0
  330. package/dist/traits/simulation-solver-factory.d.ts +23 -0
  331. package/dist/traits/simulation-solver-factory.js +4 -0
  332. package/dist/traits/webcam-gaze.cjs +35 -0
  333. package/dist/traits/webcam-gaze.d.ts +17 -0
  334. package/dist/traits/webcam-gaze.js +4 -0
  335. package/dist/type-checker.cjs +19 -0
  336. package/dist/type-checker.js +6 -0
  337. package/dist/world/index.cjs +947 -0
  338. package/dist/world/index.d.ts +147 -0
  339. package/dist/world/index.js +939 -0
  340. package/dist/world-model/index.cjs +1446 -0
  341. package/dist/world-model/index.d.ts +119 -0
  342. package/dist/world-model/index.js +1414 -0
  343. package/dist/wot/index.cjs +29 -0
  344. package/dist/wot/index.js +4 -0
  345. package/package.json +93 -49
@@ -0,0 +1,1399 @@
1
+ import { init_DomainBlockCompilerMixin, compileDomainBlocks, compileWeatherBlock, compileAudioSourceBlock, compilePhysicsBlock, physicsToURDF, compileMaterialBlock } from './chunk-JCLBKPMX.js';
2
+ import { init_CompilerBase, CompilerBase } from './chunk-QPSKHBJP.js';
3
+ import { __export, __esm } from './chunk-OL46QLBJ.js';
4
+ import { ANSCapabilityPath } from '@holoscript/core-types/ans';
5
+
6
+ // src/compiler/URDFCompiler.ts
7
+ var URDFCompiler_exports = {};
8
+ __export(URDFCompiler_exports, {
9
+ URDFCompiler: () => URDFCompiler,
10
+ compileForGazebo: () => compileForGazebo,
11
+ compileForIsaacSim: () => compileForIsaacSim,
12
+ compileForROS2: () => compileForROS2,
13
+ compileToURDF: () => compileToURDF,
14
+ createURDFCompiler: () => createURDFCompiler,
15
+ default: () => URDFCompiler_default,
16
+ generateControllersYaml: () => generateControllersYaml,
17
+ generateROS2LaunchFile: () => generateROS2LaunchFile
18
+ });
19
+ function createURDFCompiler(options) {
20
+ return new URDFCompiler(options);
21
+ }
22
+ function compileToURDF(composition, options) {
23
+ const compiler = new URDFCompiler(options);
24
+ return compiler.compile(composition);
25
+ }
26
+ function compileForROS2(composition, options) {
27
+ const ros2Options = {
28
+ includeGazeboPlugins: true,
29
+ includeROS2Control: true,
30
+ includeVisual: true,
31
+ includeCollision: true,
32
+ includeInertial: true,
33
+ ...options
34
+ };
35
+ const compiler = new URDFCompiler(ros2Options);
36
+ return compiler.compile(composition);
37
+ }
38
+ function compileForGazebo(composition, options) {
39
+ const gazeboOptions = {
40
+ includeGazeboPlugins: true,
41
+ gazeboVersion: "classic",
42
+ includeVisual: true,
43
+ includeCollision: true,
44
+ includeInertial: true,
45
+ ...options
46
+ };
47
+ const compiler = new URDFCompiler(gazeboOptions);
48
+ return compiler.compile(composition);
49
+ }
50
+ function compileForIsaacSim(composition, options) {
51
+ const isaacOptions = {
52
+ includeVisual: true,
53
+ includeCollision: true,
54
+ includeInertial: true,
55
+ includeGazeboPlugins: false,
56
+ // Isaac Sim uses PhysX, not Gazebo plugins
57
+ includeROS2Control: true,
58
+ includeIsaacSimExtensions: true,
59
+ isaacSimDriveType: "acceleration",
60
+ isaacSimTargetType: "position",
61
+ isaacSimSolverPositionIterations: 8,
62
+ isaacSimSolverVelocityIterations: 4,
63
+ ...options
64
+ };
65
+ const compiler = new URDFCompiler(isaacOptions);
66
+ return compiler.compile(composition);
67
+ }
68
+ function generateROS2LaunchFile(packageName, urdfFilename, options) {
69
+ const useSimTime = options?.useSimTime ?? true;
70
+ const rviz = options?.rviz ?? true;
71
+ const gazebo = options?.gazebo ?? true;
72
+ const controllers = options?.controllers ?? [
73
+ "joint_state_broadcaster",
74
+ "joint_trajectory_controller"
75
+ ];
76
+ const lines = [];
77
+ lines.push('"""');
78
+ lines.push(`ROS 2 Launch file for ${packageName}`);
79
+ lines.push("Auto-generated by HoloScript URDFCompiler");
80
+ lines.push('"""');
81
+ lines.push("");
82
+ lines.push("import os");
83
+ lines.push("from ament_index_python.packages import get_package_share_directory");
84
+ lines.push("from launch import LaunchDescription");
85
+ lines.push(
86
+ "from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, RegisterEventHandler"
87
+ );
88
+ lines.push("from launch.conditions import IfCondition");
89
+ lines.push("from launch.event_handlers import OnProcessExit");
90
+ lines.push("from launch.launch_description_sources import PythonLaunchDescriptionSource");
91
+ lines.push(
92
+ "from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution"
93
+ );
94
+ lines.push("from launch_ros.actions import Node");
95
+ lines.push("from launch_ros.substitutions import FindPackageShare");
96
+ lines.push("");
97
+ lines.push("");
98
+ lines.push("def generate_launch_description():");
99
+ lines.push(` pkg_share = get_package_share_directory('${packageName}')`);
100
+ lines.push(` urdf_file = os.path.join(pkg_share, 'urdf', '${urdfFilename}')`);
101
+ lines.push("");
102
+ lines.push(' with open(urdf_file, "r") as f:');
103
+ lines.push(" robot_description = f.read()");
104
+ lines.push("");
105
+ lines.push(" # Robot State Publisher");
106
+ lines.push(" robot_state_publisher = Node(");
107
+ lines.push(" package='robot_state_publisher',");
108
+ lines.push(" executable='robot_state_publisher',");
109
+ lines.push(" parameters=[{");
110
+ lines.push(" 'robot_description': robot_description,");
111
+ lines.push(` 'use_sim_time': ${useSimTime ? "True" : "False"},`);
112
+ lines.push(" }],");
113
+ lines.push(" output='screen',");
114
+ lines.push(" )");
115
+ lines.push("");
116
+ if (rviz) {
117
+ lines.push(" # RViz2");
118
+ lines.push(' rviz_config = os.path.join(pkg_share, "config", "display.rviz")');
119
+ lines.push(" rviz = Node(");
120
+ lines.push(" package='rviz2',");
121
+ lines.push(" executable='rviz2',");
122
+ lines.push(" arguments=['-d', rviz_config],");
123
+ lines.push(` parameters=[{'use_sim_time': ${useSimTime ? "True" : "False"}}],`);
124
+ lines.push(" output='screen',");
125
+ lines.push(" )");
126
+ lines.push("");
127
+ }
128
+ if (gazebo) {
129
+ lines.push(" # Gazebo");
130
+ lines.push(" gazebo = IncludeLaunchDescription(");
131
+ lines.push(" PythonLaunchDescriptionSource([");
132
+ lines.push(" FindPackageShare('ros_gz_sim'),");
133
+ lines.push(" '/launch/gz_sim.launch.py',");
134
+ lines.push(" ]),");
135
+ lines.push(" launch_arguments={'gz_args': '-r empty.sdf'}.items(),");
136
+ lines.push(" )");
137
+ lines.push("");
138
+ lines.push(" # Spawn robot");
139
+ lines.push(" spawn_entity = Node(");
140
+ lines.push(" package='ros_gz_sim',");
141
+ lines.push(" executable='create',");
142
+ lines.push(
143
+ " arguments=['-topic', 'robot_description', '-name', '" + packageName + "'],"
144
+ );
145
+ lines.push(" output='screen',");
146
+ lines.push(" )");
147
+ lines.push("");
148
+ }
149
+ for (const controller of controllers) {
150
+ const varName = controller.replace(/-/g, "_");
151
+ lines.push(` # ${controller}`);
152
+ lines.push(` ${varName}_spawner = Node(`);
153
+ lines.push(" package='controller_manager',");
154
+ lines.push(" executable='spawner',");
155
+ lines.push(` arguments=['${controller}'],`);
156
+ lines.push(" output='screen',");
157
+ lines.push(" )");
158
+ lines.push("");
159
+ }
160
+ lines.push(" return LaunchDescription([");
161
+ lines.push(" robot_state_publisher,");
162
+ if (rviz) lines.push(" rviz,");
163
+ if (gazebo) {
164
+ lines.push(" gazebo,");
165
+ lines.push(" spawn_entity,");
166
+ }
167
+ for (const controller of controllers) {
168
+ lines.push(` ${controller.replace(/-/g, "_")}_spawner,`);
169
+ }
170
+ lines.push(" ])");
171
+ return lines.join("\n");
172
+ }
173
+ function generateControllersYaml(robotName, jointNames, options) {
174
+ const controllerType = options?.controllerType ?? "joint_trajectory_controller/JointTrajectoryController";
175
+ const publishRate = options?.publishRate ?? 50;
176
+ const lines = [];
177
+ lines.push("# Auto-generated by HoloScript URDFCompiler");
178
+ lines.push(`# Robot: ${robotName}`);
179
+ lines.push("");
180
+ lines.push("controller_manager:");
181
+ lines.push(" ros__parameters:");
182
+ lines.push(` update_rate: ${publishRate}`);
183
+ lines.push("");
184
+ lines.push(" joint_state_broadcaster:");
185
+ lines.push(" type: joint_state_broadcaster/JointStateBroadcaster");
186
+ lines.push("");
187
+ lines.push(" joint_trajectory_controller:");
188
+ lines.push(` type: ${controllerType}`);
189
+ lines.push("");
190
+ lines.push("joint_trajectory_controller:");
191
+ lines.push(" ros__parameters:");
192
+ lines.push(" joints:");
193
+ for (const joint of jointNames) {
194
+ lines.push(` - ${joint}`);
195
+ }
196
+ lines.push(" command_interfaces:");
197
+ lines.push(" - position");
198
+ lines.push(" state_interfaces:");
199
+ lines.push(" - position");
200
+ lines.push(" - velocity");
201
+ return lines.join("\n");
202
+ }
203
+ var URDFCompiler, URDFCompiler_default;
204
+ var init_URDFCompiler = __esm({
205
+ "src/compiler/URDFCompiler.ts"() {
206
+ init_CompilerBase();
207
+ init_DomainBlockCompilerMixin();
208
+ URDFCompiler = class extends CompilerBase {
209
+ constructor(options = {}) {
210
+ super();
211
+ this.compilerName = "URDFCompiler";
212
+ this.lines = [];
213
+ this.indentLevel = 0;
214
+ this.links = [];
215
+ this.joints = [];
216
+ this.materials = /* @__PURE__ */ new Map();
217
+ this.sensors = [];
218
+ this.transmissions = [];
219
+ this.ros2Controls = [];
220
+ this.isaacSimSensors = [];
221
+ this.loopJoints = [];
222
+ this.fixedFrames = [];
223
+ this.options = {
224
+ robotName: options.robotName || "HoloScriptRobot",
225
+ includeVisual: options.includeVisual ?? true,
226
+ includeCollision: options.includeCollision ?? true,
227
+ includeInertial: options.includeInertial ?? true,
228
+ defaultMass: options.defaultMass ?? 1,
229
+ meshPathPrefix: options.meshPathPrefix || "package://meshes/",
230
+ includeHoloExtensions: options.includeHoloExtensions ?? true,
231
+ includeGazeboPlugins: options.includeGazeboPlugins ?? false,
232
+ includeROS2Control: options.includeROS2Control ?? false,
233
+ gazeboVersion: options.gazeboVersion ?? "classic",
234
+ gazeboPhysicsEngine: options.gazeboPhysicsEngine ?? "ode",
235
+ defaultMu1: options.defaultMu1 ?? 0.5,
236
+ defaultMu2: options.defaultMu2 ?? 0.5,
237
+ defaultKp: options.defaultKp ?? 1e6,
238
+ defaultKd: options.defaultKd ?? 100,
239
+ enableSelfCollision: options.enableSelfCollision ?? false,
240
+ packageName: options.packageName ?? "holoscript_robot",
241
+ includeIsaacSimExtensions: options.includeIsaacSimExtensions ?? false,
242
+ isaacSimDriveType: options.isaacSimDriveType ?? "acceleration",
243
+ isaacSimTargetType: options.isaacSimTargetType ?? "position",
244
+ isaacSimSolverPositionIterations: options.isaacSimSolverPositionIterations ?? 8,
245
+ isaacSimSolverVelocityIterations: options.isaacSimSolverVelocityIterations ?? 4
246
+ };
247
+ }
248
+ getRequiredCapability() {
249
+ return ANSCapabilityPath.URDF;
250
+ }
251
+ // ===========================================================================
252
+ // HELPER METHODS
253
+ // ===========================================================================
254
+ /** Get trait name from either string or object format */
255
+ getTraitName(trait) {
256
+ return typeof trait === "string" ? trait : trait.name;
257
+ }
258
+ /** Check if object has a specific trait */
259
+ hasTrait(obj, traitName) {
260
+ return obj.traits?.some((t) => this.getTraitName(t) === traitName) ?? false;
261
+ }
262
+ /** Get trait configuration object */
263
+ getTraitConfig(obj, traitName) {
264
+ const trait = obj.traits?.find((t) => this.getTraitName(t) === traitName);
265
+ if (!trait) return void 0;
266
+ if (typeof trait === "string") return {};
267
+ const { name: _name, ...config } = trait;
268
+ return config;
269
+ }
270
+ /** Map HoloScript joint types to URDF joint types */
271
+ mapJointType(holoType) {
272
+ switch (holoType) {
273
+ case "hinge":
274
+ case "revolute":
275
+ return "revolute";
276
+ case "slider":
277
+ case "prismatic":
278
+ return "prismatic";
279
+ case "ball":
280
+ case "floating":
281
+ return "floating";
282
+ case "fixed":
283
+ return "fixed";
284
+ case "continuous":
285
+ return "continuous";
286
+ case "planar":
287
+ return "planar";
288
+ default:
289
+ return "fixed";
290
+ }
291
+ }
292
+ /** Sanitize name for URDF element names (Isaac Sim compatible) */
293
+ sanitizeName(name) {
294
+ let sanitized = name.replace(/[^a-zA-Z0-9_]/g, "_").toLowerCase();
295
+ if (sanitized.startsWith("_")) {
296
+ sanitized = "a" + sanitized;
297
+ }
298
+ return sanitized;
299
+ }
300
+ /** Escape special characters for XML attribute values */
301
+ escapeXml(str) {
302
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
303
+ }
304
+ /** Emit a line with current indent */
305
+ emit(line) {
306
+ const indent = " ".repeat(this.indentLevel);
307
+ this.lines.push(indent + line);
308
+ }
309
+ /** Emit empty line */
310
+ emitBlank() {
311
+ this.lines.push("");
312
+ }
313
+ /** Convert HoloValue to string */
314
+ getStringValue(value) {
315
+ if (typeof value === "string") return value;
316
+ if (typeof value === "number") return String(value);
317
+ if (typeof value === "boolean") return String(value);
318
+ return "";
319
+ }
320
+ /** Parse hex color string to RGBA components */
321
+ parseColor(color) {
322
+ if (color.startsWith("#")) {
323
+ const hex = color.slice(1);
324
+ return {
325
+ r: parseInt(hex.slice(0, 2), 16) / 255,
326
+ g: parseInt(hex.slice(2, 4), 16) / 255,
327
+ b: parseInt(hex.slice(4, 6), 16) / 255,
328
+ a: hex.length > 6 ? parseInt(hex.slice(6, 8), 16) / 255 : 1
329
+ };
330
+ }
331
+ const colors = {
332
+ red: { r: 1, g: 0, b: 0, a: 1 },
333
+ green: { r: 0, g: 0.8, b: 0, a: 1 },
334
+ blue: { r: 0, g: 0, b: 1, a: 1 },
335
+ white: { r: 1, g: 1, b: 1, a: 1 },
336
+ black: { r: 0, g: 0, b: 0, a: 1 },
337
+ yellow: { r: 1, g: 1, b: 0, a: 1 },
338
+ cyan: { r: 0, g: 1, b: 1, a: 1 },
339
+ magenta: { r: 1, g: 0, b: 1, a: 1 },
340
+ orange: { r: 1, g: 0.65, b: 0, a: 1 },
341
+ gray: { r: 0.5, g: 0.5, b: 0.5, a: 1 },
342
+ grey: { r: 0.5, g: 0.5, b: 0.5, a: 1 }
343
+ };
344
+ return colors[color.toLowerCase()] || { r: 0.8, g: 0.8, b: 0.8, a: 1 };
345
+ }
346
+ // ===========================================================================
347
+ // EXTRACTION METHODS
348
+ // ===========================================================================
349
+ /** Extract position from object properties */
350
+ extractPosition(obj) {
351
+ const posProp = obj.properties.find((p) => p.key === "position");
352
+ if (posProp && Array.isArray(posProp.value)) {
353
+ return [
354
+ Number(posProp.value[0]) || 0,
355
+ Number(posProp.value[1]) || 0,
356
+ Number(posProp.value[2]) || 0
357
+ ];
358
+ }
359
+ return [0, 0, 0];
360
+ }
361
+ /** Extract rotation from object properties (degrees -> radians) */
362
+ extractRotation(obj) {
363
+ const rotProp = obj.properties.find((p) => p.key === "rotation");
364
+ if (rotProp && Array.isArray(rotProp.value)) {
365
+ return [
366
+ (Number(rotProp.value[0]) || 0) * Math.PI / 180,
367
+ (Number(rotProp.value[1]) || 0) * Math.PI / 180,
368
+ (Number(rotProp.value[2]) || 0) * Math.PI / 180
369
+ ];
370
+ }
371
+ return [0, 0, 0];
372
+ }
373
+ /** Extract uniform scale value from object properties */
374
+ extractScale(obj) {
375
+ const scaleProp = obj.properties.find((p) => p.key === "scale");
376
+ if (scaleProp) {
377
+ if (typeof scaleProp.value === "number") {
378
+ return scaleProp.value;
379
+ }
380
+ if (Array.isArray(scaleProp.value)) {
381
+ return Number(scaleProp.value[0]) || 1;
382
+ }
383
+ }
384
+ return 1;
385
+ }
386
+ /** Extract 3D scale from object properties */
387
+ extractScale3D(obj) {
388
+ const scaleProp = obj.properties.find((p) => p.key === "scale");
389
+ if (scaleProp) {
390
+ if (typeof scaleProp.value === "number") {
391
+ return [scaleProp.value, scaleProp.value, scaleProp.value];
392
+ }
393
+ if (Array.isArray(scaleProp.value) && scaleProp.value.length >= 3) {
394
+ return [
395
+ Number(scaleProp.value[0]) || 1,
396
+ Number(scaleProp.value[1]) || 1,
397
+ Number(scaleProp.value[2]) || 1
398
+ ];
399
+ }
400
+ }
401
+ return [1, 1, 1];
402
+ }
403
+ /** Extract color from object properties */
404
+ extractColor(obj) {
405
+ const colorProp = obj.properties.find((p) => p.key === "color");
406
+ return colorProp ? this.getStringValue(colorProp.value) : void 0;
407
+ }
408
+ /** Extract mass from physics property or trait */
409
+ extractMass(obj) {
410
+ const physicsProp = obj.properties.find((p) => p.key === "physics");
411
+ if (physicsProp && typeof physicsProp.value === "object" && !Array.isArray(physicsProp.value)) {
412
+ const massEntry = physicsProp.value.mass;
413
+ if (typeof massEntry === "number") return massEntry;
414
+ }
415
+ const massProp = obj.properties.find((p) => p.key === "mass");
416
+ if (massProp && typeof massProp.value === "number") return massProp.value;
417
+ return void 0;
418
+ }
419
+ /** Extract geometry type and dimensions from object */
420
+ extractGeometry(obj) {
421
+ const geometryProp = obj.properties.find((p) => p.key === "geometry");
422
+ if (!geometryProp) return void 0;
423
+ const geometryValue = this.getStringValue(geometryProp.value);
424
+ const scale = this.extractScale(obj);
425
+ switch (geometryValue) {
426
+ case "cube":
427
+ case "box":
428
+ return { type: "box", size: [scale, scale, scale] };
429
+ case "sphere":
430
+ return { type: "sphere", radius: scale / 2 };
431
+ case "cylinder":
432
+ return { type: "cylinder", radius: scale / 2, length: scale };
433
+ case "cone":
434
+ return { type: "cylinder", radius: scale / 2, length: scale };
435
+ case "capsule":
436
+ return { type: "cylinder", radius: scale / 3, length: scale };
437
+ case "plane":
438
+ return { type: "box", size: [scale, 0.01, scale] };
439
+ default:
440
+ if (geometryValue.endsWith(".glb") || geometryValue.endsWith(".dae") || geometryValue.endsWith(".stl") || geometryValue.endsWith(".obj")) {
441
+ const filename = geometryValue.replace(".glb", ".stl").replace(".dae", ".stl").replace(".obj", ".stl");
442
+ return {
443
+ type: "mesh",
444
+ filename: `${this.options.meshPathPrefix}${filename}`,
445
+ scale: this.extractScale3D(obj)
446
+ };
447
+ }
448
+ return { type: "box", size: [scale, scale, scale] };
449
+ }
450
+ }
451
+ /** Calculate inertia tensor from geometry and mass */
452
+ calculateInertia(geometry, mass) {
453
+ let ixx = mass * (1 + 1) / 12;
454
+ let iyy = mass * (1 + 1) / 12;
455
+ let izz = mass * (1 + 1) / 12;
456
+ if (geometry) {
457
+ switch (geometry.type) {
458
+ case "box": {
459
+ const [w, h, d] = geometry.size || [1, 1, 1];
460
+ ixx = mass * (h * h + d * d) / 12;
461
+ iyy = mass * (w * w + d * d) / 12;
462
+ izz = mass * (w * w + h * h) / 12;
463
+ break;
464
+ }
465
+ case "sphere": {
466
+ const r = geometry.radius || 0.5;
467
+ ixx = iyy = izz = 2 / 5 * mass * r * r;
468
+ break;
469
+ }
470
+ case "cylinder": {
471
+ const r = geometry.radius || 0.5;
472
+ const l = geometry.length || 1;
473
+ ixx = iyy = mass * (3 * r * r + l * l) / 12;
474
+ izz = mass * r * r / 2;
475
+ break;
476
+ }
477
+ }
478
+ }
479
+ return {
480
+ mass,
481
+ inertia: { ixx, ixy: 0, ixz: 0, iyy, iyz: 0, izz }
482
+ };
483
+ }
484
+ // ===========================================================================
485
+ // COMPILATION
486
+ // ===========================================================================
487
+ /**
488
+ * Compile HoloScript composition to URDF XML
489
+ */
490
+ compile(composition, agentToken, outputPath) {
491
+ if (agentToken) {
492
+ this.validateCompilerAccess(agentToken, outputPath);
493
+ }
494
+ this.lines = [];
495
+ this.links = [];
496
+ this.joints = [];
497
+ this.materials.clear();
498
+ this.sensors = [];
499
+ this.transmissions = [];
500
+ this.ros2Controls = [];
501
+ this.isaacSimSensors = [];
502
+ this.loopJoints = [];
503
+ this.fixedFrames = [];
504
+ this.indentLevel = 0;
505
+ this.extractFromComposition(composition);
506
+ this.emit('<?xml version="1.0"?>');
507
+ this.emit(`<!-- Auto-generated by HoloScript URDFCompiler v2.0 -->`);
508
+ this.emit(
509
+ `<!-- Source: composition "${this.escapeStringValue(composition.name, "TypeScript")}" -->`
510
+ );
511
+ this.emit(`<!-- Target: ROS 2 / Gazebo / MoveIt 2 / RViz2 -->`);
512
+ this.emitBlank();
513
+ this.emit(`<robot name="${this.escapeXml(this.options.robotName)}">`);
514
+ this.indentLevel++;
515
+ this.emitMaterials();
516
+ for (const link of this.links) {
517
+ this.emitLink(link);
518
+ }
519
+ for (const joint of this.joints) {
520
+ this.emitJoint(joint);
521
+ }
522
+ if (this.transmissions.length > 0) {
523
+ this.emitBlank();
524
+ this.emit("<!-- Transmissions -->");
525
+ for (const transmission of this.transmissions) {
526
+ this.emitTransmission(transmission);
527
+ }
528
+ }
529
+ if (this.options.includeROS2Control && this.ros2Controls.length > 0) {
530
+ this.emitBlank();
531
+ this.emit("<!-- ROS 2 Control Hardware Interface -->");
532
+ for (const control of this.ros2Controls) {
533
+ this.emitROS2Control(control);
534
+ }
535
+ }
536
+ if (this.options.includeGazeboPlugins) {
537
+ this.emitBlank();
538
+ this.emitGazeboPlugins(composition);
539
+ }
540
+ if (this.sensors.length > 0 && this.options.includeGazeboPlugins) {
541
+ for (const sensor of this.sensors) {
542
+ this.emitGazeboSensor(sensor);
543
+ }
544
+ }
545
+ if (this.options.includeIsaacSimExtensions) {
546
+ this.emitIsaacSimExtensions();
547
+ }
548
+ if (this.options.includeHoloExtensions) {
549
+ this.emitHoloExtensions(composition);
550
+ }
551
+ this.emitDomainBlocks(composition);
552
+ this.indentLevel--;
553
+ this.emit("</robot>");
554
+ return this.lines.join("\n");
555
+ }
556
+ emitDomainBlocks(composition) {
557
+ const domainBlocks = composition.domainBlocks ?? [];
558
+ if (domainBlocks.length === 0) return;
559
+ this.emitBlank();
560
+ this.emit("<!-- v4.2 Domain Blocks -->");
561
+ const compiled = compileDomainBlocks(
562
+ domainBlocks,
563
+ {
564
+ material: (block) => {
565
+ const mat = compileMaterialBlock(block);
566
+ const lines = [];
567
+ lines.push(
568
+ `<material name="${this.escapeStringValue(mat.name, "TypeScript")}">`
569
+ );
570
+ if (mat.baseColor) {
571
+ const h = mat.baseColor.replace("#", "");
572
+ const r = (parseInt(h.substring(0, 2), 16) / 255).toFixed(3);
573
+ const g = (parseInt(h.substring(2, 4), 16) / 255).toFixed(3);
574
+ const b = (parseInt(h.substring(4, 6), 16) / 255).toFixed(3);
575
+ lines.push(` <color rgba="${r} ${g} ${b} ${mat.opacity ?? 1}"/>`);
576
+ }
577
+ for (const [mapType, path] of Object.entries(mat.textureMaps)) {
578
+ if (mapType === "albedo_map") {
579
+ lines.push(` <texture filename="${path}"/>`);
580
+ }
581
+ }
582
+ lines.push("</material>");
583
+ return lines.join("\n");
584
+ },
585
+ physics: (block) => {
586
+ const phys = compilePhysicsBlock(block);
587
+ return physicsToURDF(phys);
588
+ },
589
+ audio: (block) => {
590
+ const audio = compileAudioSourceBlock(block);
591
+ return `<!-- Audio: ${this.escapeStringValue(audio.name, "TypeScript")} (${audio.keyword}) clip="${audio.properties.clip || ""}" volume="${audio.properties.volume ?? 1}" -->`;
592
+ },
593
+ weather: (block) => {
594
+ const weather = compileWeatherBlock(block);
595
+ return `<!-- Weather: ${weather.keyword} "${weather.name || ""}" layers: ${weather.layers.map((l) => l.type).join(", ")} -->`;
596
+ }
597
+ },
598
+ (block) => `<!-- Domain block: ${block.domain}/${block.keyword} "${this.escapeStringValue(block.name, "TypeScript")}" -->`
599
+ );
600
+ for (const output of compiled) {
601
+ for (const line of output.split("\n")) {
602
+ this.emit(line);
603
+ }
604
+ }
605
+ }
606
+ // ===========================================================================
607
+ // EXTRACTION FROM COMPOSITION
608
+ // ===========================================================================
609
+ extractFromComposition(composition) {
610
+ this.materials.set("default", {
611
+ name: "default",
612
+ color: { r: 0.8, g: 0.8, b: 0.8, a: 1 }
613
+ });
614
+ this.links.push({
615
+ name: "base_link",
616
+ visual: void 0,
617
+ collision: void 0,
618
+ inertial: {
619
+ mass: 1e-3,
620
+ inertia: { ixx: 1e-3, ixy: 0, ixz: 0, iyy: 1e-3, iyz: 0, izz: 1e-3 }
621
+ }
622
+ });
623
+ const actuatedJoints = [];
624
+ if (composition.objects) {
625
+ for (const obj of composition.objects) {
626
+ this.processObject(obj, "base_link", actuatedJoints);
627
+ }
628
+ }
629
+ if (composition.spatialGroups) {
630
+ for (const group of composition.spatialGroups) {
631
+ this.processSpatialGroup(group, "base_link", actuatedJoints);
632
+ }
633
+ }
634
+ if (this.options.includeROS2Control && actuatedJoints.length > 0) {
635
+ this.ros2Controls.push({
636
+ name: `${this.sanitizeName(this.options.robotName)}_ros2_control`,
637
+ type: "system",
638
+ hardwarePlugin: "gz_ros2_control/GazeboSimSystem",
639
+ joints: actuatedJoints
640
+ });
641
+ }
642
+ }
643
+ processObject(obj, parentLink, actuatedJoints) {
644
+ const linkName = this.sanitizeName(obj.name);
645
+ const hasPhysics = this.hasTrait(obj, "physics") || this.hasTrait(obj, "rigid");
646
+ const hasCollider = this.hasTrait(obj, "collidable") || this.hasTrait(obj, "trigger");
647
+ const jointConfig = this.getTraitConfig(obj, "joint");
648
+ const sensorConfig = this.getTraitConfig(obj, "sensor");
649
+ const actuatorConfig = this.getTraitConfig(obj, "actuator");
650
+ const geometry = this.extractGeometry(obj);
651
+ const position = this.extractPosition(obj);
652
+ const rotation = this.extractRotation(obj);
653
+ const color = this.extractColor(obj);
654
+ if (color) {
655
+ const colorHash = color.replace(/[^a-zA-Z0-9]/g, "");
656
+ const matName = `material_${linkName}_${colorHash}`;
657
+ const rgba = this.parseColor(color);
658
+ this.materials.set(matName, {
659
+ name: matName,
660
+ color: rgba
661
+ });
662
+ }
663
+ const link = {
664
+ name: linkName,
665
+ origin: {
666
+ xyz: position,
667
+ rpy: rotation
668
+ }
669
+ };
670
+ if (this.options.includeVisual && geometry) {
671
+ link.visual = { ...geometry, color };
672
+ }
673
+ if (this.options.includeCollision && (hasCollider || hasPhysics) && geometry) {
674
+ link.collision = geometry;
675
+ }
676
+ if (this.options.includeInertial) {
677
+ const mass = this.extractMass(obj) || this.options.defaultMass;
678
+ link.inertial = this.calculateInertia(geometry, mass);
679
+ }
680
+ this.links.push(link);
681
+ const joint = {
682
+ name: `${parentLink}_to_${linkName}_joint`,
683
+ type: "fixed",
684
+ parent: parentLink,
685
+ child: linkName,
686
+ origin: {
687
+ xyz: position,
688
+ rpy: rotation
689
+ }
690
+ };
691
+ if (jointConfig) {
692
+ if (jointConfig.jointType) {
693
+ joint.type = this.mapJointType(jointConfig.jointType);
694
+ }
695
+ if (jointConfig.axis) {
696
+ const axis = jointConfig.axis;
697
+ joint.axis = Array.isArray(axis) ? [axis[0] ?? 0, axis[1] ?? 0, axis[2] ?? 1] : [axis[0] ?? 0, axis[1] ?? 0, axis[2] ?? 1];
698
+ }
699
+ if (jointConfig.limits && (joint.type === "revolute" || joint.type === "prismatic")) {
700
+ const limitsConfig = jointConfig.limits;
701
+ joint.limits = {
702
+ lower: joint.type === "revolute" ? (limitsConfig.min ?? -180) * Math.PI / 180 : limitsConfig.min ?? -1,
703
+ upper: joint.type === "revolute" ? (limitsConfig.max ?? 180) * Math.PI / 180 : limitsConfig.max ?? 1,
704
+ effort: limitsConfig.effort ?? 100,
705
+ velocity: limitsConfig.velocity ?? 1
706
+ };
707
+ }
708
+ if (jointConfig.damping !== void 0) {
709
+ joint.dynamics = {
710
+ damping: jointConfig.damping,
711
+ friction: jointConfig.friction ?? 0
712
+ };
713
+ }
714
+ if (jointConfig.mimic) {
715
+ const mimicConfig = jointConfig.mimic;
716
+ joint.mimic = {
717
+ joint: mimicConfig.joint,
718
+ multiplier: mimicConfig.multiplier ?? 1,
719
+ offset: mimicConfig.offset ?? 0
720
+ };
721
+ }
722
+ if (jointConfig.safetyController) {
723
+ const safety = jointConfig.safetyController;
724
+ joint.safetyController = {
725
+ softLowerLimit: safety.softLowerLimit ?? 0,
726
+ softUpperLimit: safety.softUpperLimit ?? 0,
727
+ kPosition: safety.kPosition ?? 100,
728
+ kVelocity: safety.kVelocity ?? 10
729
+ };
730
+ }
731
+ if (jointConfig.connectedBody) {
732
+ const newParent = this.sanitizeName(jointConfig.connectedBody);
733
+ joint.parent = newParent;
734
+ joint.name = `${newParent}_to_${linkName}_joint`;
735
+ }
736
+ if (joint.type !== "fixed" && this.options.includeROS2Control) {
737
+ const interfaces = this.getJointInterfaces(joint.type);
738
+ const actuatedEntry = {
739
+ name: joint.name,
740
+ type: joint.type,
741
+ ...interfaces
742
+ };
743
+ if (joint.mimic) {
744
+ actuatedEntry.mimic = joint.mimic;
745
+ }
746
+ actuatedJoints.push(actuatedEntry);
747
+ }
748
+ }
749
+ this.joints.push(joint);
750
+ if (sensorConfig) {
751
+ this.processSensorTrait(sensorConfig, linkName);
752
+ }
753
+ if (actuatorConfig) {
754
+ this.processActuatorTrait(actuatorConfig, joint.name, linkName);
755
+ }
756
+ }
757
+ processSpatialGroup(group, parentLink, actuatedJoints) {
758
+ const groupLinkName = this.sanitizeName(group.name);
759
+ this.links.push({
760
+ name: groupLinkName,
761
+ inertial: {
762
+ mass: 1e-3,
763
+ inertia: { ixx: 1e-3, ixy: 0, ixz: 0, iyy: 1e-3, iyz: 0, izz: 1e-3 }
764
+ }
765
+ });
766
+ this.joints.push({
767
+ name: `${parentLink}_to_${groupLinkName}_joint`,
768
+ type: "fixed",
769
+ parent: parentLink,
770
+ child: groupLinkName
771
+ });
772
+ if (group.objects) {
773
+ for (const obj of group.objects) {
774
+ this.processObject(obj, groupLinkName, actuatedJoints);
775
+ }
776
+ }
777
+ }
778
+ /** Process @sensor trait into sensor definition */
779
+ processSensorTrait(config, parentLink) {
780
+ const sensorType = config.sensorType || config.type || "camera";
781
+ const name = config.name || `${parentLink}_${sensorType}_sensor`;
782
+ const sensor = {
783
+ name: this.sanitizeName(name),
784
+ type: this.mapSensorType(sensorType),
785
+ parentLink,
786
+ updateRate: config.updateRate ?? 30,
787
+ topicName: config.topic ?? `/${this.sanitizeName(name)}`,
788
+ frameName: config.frameName ?? `${parentLink}_${sensorType}_frame`
789
+ };
790
+ if (sensor.type === "camera" || sensor.type === "depth_camera") {
791
+ sensor.camera = {
792
+ horizontalFov: config.fov ?? 1.3962634,
793
+ imageWidth: config.width ?? 640,
794
+ imageHeight: config.height ?? 480,
795
+ clipNear: config.clipNear ?? 0.1,
796
+ clipFar: config.clipFar ?? 100,
797
+ format: config.format ?? "R8G8B8"
798
+ };
799
+ }
800
+ if (sensor.type === "lidar" || sensor.type === "ray") {
801
+ sensor.lidar = {
802
+ samples: config.samples ?? 360,
803
+ resolution: config.resolution ?? 1,
804
+ minAngle: config.minAngle ?? -Math.PI,
805
+ maxAngle: config.maxAngle ?? Math.PI,
806
+ minRange: config.minRange ?? 0.1,
807
+ maxRange: config.maxRange ?? 30
808
+ };
809
+ }
810
+ if (sensor.type === "imu") {
811
+ sensor.imu = {
812
+ gaussianNoise: config.noise ?? 0
813
+ };
814
+ }
815
+ this.sensors.push(sensor);
816
+ }
817
+ /** Map sensor type strings to URDF sensor types */
818
+ mapSensorType(type) {
819
+ switch (type.toLowerCase()) {
820
+ case "camera":
821
+ case "rgb_camera":
822
+ return "camera";
823
+ case "depth":
824
+ case "depth_camera":
825
+ case "rgbd":
826
+ return "depth_camera";
827
+ case "imu":
828
+ return "imu";
829
+ case "lidar":
830
+ case "laser":
831
+ return "lidar";
832
+ case "ray":
833
+ return "ray";
834
+ case "force_torque":
835
+ case "ft":
836
+ return "force_torque";
837
+ case "contact":
838
+ case "bumper":
839
+ return "contact";
840
+ case "gps":
841
+ case "navsat":
842
+ return "gps";
843
+ default:
844
+ return "camera";
845
+ }
846
+ }
847
+ /** Process @actuator trait into transmission definition */
848
+ processActuatorTrait(config, jointName, linkName) {
849
+ const transmission = {
850
+ name: `${linkName}_transmission`,
851
+ type: config.transmissionType ?? "transmission_interface/SimpleTransmission",
852
+ jointName,
853
+ actuatorName: config.actuatorName ?? `${linkName}_actuator`,
854
+ hardwareInterface: config.hardwareInterface ?? "hardware_interface/PositionJointInterface",
855
+ mechanicalReduction: config.mechanicalReduction
856
+ };
857
+ this.transmissions.push(transmission);
858
+ }
859
+ /** Get command and state interfaces for ros2_control based on joint type */
860
+ getJointInterfaces(jointType) {
861
+ switch (jointType) {
862
+ case "revolute":
863
+ case "continuous":
864
+ return {
865
+ commandInterfaces: ["position"],
866
+ stateInterfaces: ["position", "velocity"]
867
+ };
868
+ case "prismatic":
869
+ return {
870
+ commandInterfaces: ["position"],
871
+ stateInterfaces: ["position", "velocity"]
872
+ };
873
+ default:
874
+ return {
875
+ commandInterfaces: ["position"],
876
+ stateInterfaces: ["position"]
877
+ };
878
+ }
879
+ }
880
+ // ===========================================================================
881
+ // EMISSION METHODS
882
+ // ===========================================================================
883
+ /** Emit all materials */
884
+ emitMaterials() {
885
+ this.emit("<!-- Materials -->");
886
+ for (const [_key, mat] of this.materials) {
887
+ this.emit(`<material name="${this.escapeStringValue(mat.name, "TypeScript")}">`);
888
+ this.indentLevel++;
889
+ this.emit(`<color rgba="${mat.color.r} ${mat.color.g} ${mat.color.b} ${mat.color.a}"/>`);
890
+ if (mat.texture) {
891
+ this.emit(`<texture filename="${mat.texture}"/>`);
892
+ }
893
+ this.indentLevel--;
894
+ this.emit("</material>");
895
+ }
896
+ this.emitBlank();
897
+ }
898
+ /** Emit a single link element */
899
+ emitLink(link) {
900
+ this.emit(`<link name="${this.escapeStringValue(link.name, "TypeScript")}">`);
901
+ this.indentLevel++;
902
+ if (link.visual) {
903
+ this.emit("<visual>");
904
+ this.indentLevel++;
905
+ if (link.origin) {
906
+ this.emitOrigin(link.origin);
907
+ }
908
+ this.emitGeometry(link.visual);
909
+ if (link.visual.color) {
910
+ const colorHash = link.visual.color.replace(/[^a-zA-Z0-9]/g, "");
911
+ const matName = `material_${this.escapeStringValue(link.name, "TypeScript")}_${colorHash}`;
912
+ if (this.materials.has(matName)) {
913
+ this.emit(`<material name="${matName}"/>`);
914
+ } else {
915
+ this.emit('<material name="default"/>');
916
+ }
917
+ } else {
918
+ this.emit('<material name="default"/>');
919
+ }
920
+ this.indentLevel--;
921
+ this.emit("</visual>");
922
+ }
923
+ if (link.collision) {
924
+ this.emit("<collision>");
925
+ this.indentLevel++;
926
+ if (link.origin) {
927
+ this.emitOrigin(link.origin);
928
+ }
929
+ this.emitGeometry(link.collision);
930
+ this.indentLevel--;
931
+ this.emit("</collision>");
932
+ }
933
+ if (link.inertial) {
934
+ this.emit("<inertial>");
935
+ this.indentLevel++;
936
+ if (link.inertial.origin) {
937
+ this.emitOrigin(link.inertial.origin);
938
+ }
939
+ this.emit(`<mass value="${link.inertial.mass}"/>`);
940
+ const i = link.inertial.inertia;
941
+ this.emit(
942
+ `<inertia ixx="${i.ixx.toFixed(6)}" ixy="${i.ixy}" ixz="${i.ixz}" iyy="${i.iyy.toFixed(6)}" iyz="${i.iyz}" izz="${i.izz.toFixed(6)}"/>`
943
+ );
944
+ this.indentLevel--;
945
+ this.emit("</inertial>");
946
+ }
947
+ this.indentLevel--;
948
+ this.emit("</link>");
949
+ this.emitBlank();
950
+ }
951
+ /** Emit a single joint element */
952
+ emitJoint(joint) {
953
+ this.emit(
954
+ `<joint name="${this.escapeStringValue(joint.name, "TypeScript")}" type="${joint.type}">`
955
+ );
956
+ this.indentLevel++;
957
+ this.emit(`<parent link="${joint.parent}"/>`);
958
+ this.emit(`<child link="${joint.child}"/>`);
959
+ if (joint.origin) {
960
+ this.emitOrigin(joint.origin);
961
+ }
962
+ if (joint.axis) {
963
+ this.emit(`<axis xyz="${joint.axis.join(" ")}"/>`);
964
+ }
965
+ if (joint.limits) {
966
+ this.emit(
967
+ `<limit lower="${joint.limits.lower}" upper="${joint.limits.upper}" effort="${joint.limits.effort}" velocity="${joint.limits.velocity}"/>`
968
+ );
969
+ }
970
+ if (joint.dynamics) {
971
+ this.emit(
972
+ `<dynamics damping="${joint.dynamics.damping}" friction="${joint.dynamics.friction}"/>`
973
+ );
974
+ }
975
+ if (joint.mimic) {
976
+ this.emit(
977
+ `<mimic joint="${joint.mimic.joint}" multiplier="${joint.mimic.multiplier}" offset="${joint.mimic.offset}"/>`
978
+ );
979
+ }
980
+ if (joint.safetyController) {
981
+ this.emit(
982
+ `<safety_controller soft_lower_limit="${joint.safetyController.softLowerLimit}" soft_upper_limit="${joint.safetyController.softUpperLimit}" k_position="${joint.safetyController.kPosition}" k_velocity="${joint.safetyController.kVelocity}"/>`
983
+ );
984
+ }
985
+ this.indentLevel--;
986
+ this.emit("</joint>");
987
+ this.emitBlank();
988
+ }
989
+ /** Emit geometry element */
990
+ emitGeometry(geom) {
991
+ this.emit("<geometry>");
992
+ this.indentLevel++;
993
+ switch (geom.type) {
994
+ case "box":
995
+ this.emit(`<box size="${(geom.size || [1, 1, 1]).join(" ")}"/>`);
996
+ break;
997
+ case "sphere":
998
+ this.emit(`<sphere radius="${geom.radius || 0.5}"/>`);
999
+ break;
1000
+ case "cylinder":
1001
+ this.emit(`<cylinder radius="${geom.radius || 0.5}" length="${geom.length || 1}"/>`);
1002
+ break;
1003
+ case "mesh":
1004
+ if (geom.scale && (geom.scale[0] !== 1 || geom.scale[1] !== 1 || geom.scale[2] !== 1)) {
1005
+ this.emit(`<mesh filename="${geom.filename}" scale="${geom.scale.join(" ")}"/>`);
1006
+ } else {
1007
+ this.emit(`<mesh filename="${geom.filename}"/>`);
1008
+ }
1009
+ break;
1010
+ }
1011
+ this.indentLevel--;
1012
+ this.emit("</geometry>");
1013
+ }
1014
+ /** Emit origin element */
1015
+ emitOrigin(origin) {
1016
+ this.emit(
1017
+ `<origin xyz="${origin.xyz.join(" ")}" rpy="${origin.rpy.map((v) => v.toFixed(6)).join(" ")}"/>`
1018
+ );
1019
+ }
1020
+ /** Emit transmission element (for ros_control) */
1021
+ emitTransmission(trans) {
1022
+ this.emit(
1023
+ `<transmission name="${this.escapeStringValue(trans.name, "TypeScript")}">`
1024
+ );
1025
+ this.indentLevel++;
1026
+ this.emit(`<type>${trans.type}</type>`);
1027
+ this.emit(`<joint name="${trans.jointName}">`);
1028
+ this.indentLevel++;
1029
+ this.emit(`<hardwareInterface>${trans.hardwareInterface}</hardwareInterface>`);
1030
+ this.indentLevel--;
1031
+ this.emit("</joint>");
1032
+ this.emit(`<actuator name="${trans.actuatorName}">`);
1033
+ this.indentLevel++;
1034
+ this.emit(`<hardwareInterface>${trans.hardwareInterface}</hardwareInterface>`);
1035
+ if (trans.mechanicalReduction !== void 0) {
1036
+ this.emit(`<mechanicalReduction>${trans.mechanicalReduction}</mechanicalReduction>`);
1037
+ }
1038
+ this.indentLevel--;
1039
+ this.emit("</actuator>");
1040
+ this.indentLevel--;
1041
+ this.emit("</transmission>");
1042
+ this.emitBlank();
1043
+ }
1044
+ /** Emit ros2_control hardware interface block */
1045
+ emitROS2Control(control) {
1046
+ this.emit(
1047
+ `<ros2_control name="${this.escapeStringValue(control.name, "TypeScript")}" type="${control.type}">`
1048
+ );
1049
+ this.indentLevel++;
1050
+ this.emit("<hardware>");
1051
+ this.indentLevel++;
1052
+ this.emit(`<plugin>${control.hardwarePlugin}</plugin>`);
1053
+ if (control.parameters) {
1054
+ for (const [key, value] of Object.entries(control.parameters)) {
1055
+ this.emit(`<param name="${key}">${value}</param>`);
1056
+ }
1057
+ }
1058
+ this.indentLevel--;
1059
+ this.emit("</hardware>");
1060
+ for (const joint of control.joints) {
1061
+ this.emit(`<joint name="${this.escapeStringValue(joint.name, "TypeScript")}">`);
1062
+ this.indentLevel++;
1063
+ for (const iface of joint.commandInterfaces) {
1064
+ this.emit(`<command_interface name="${iface}"/>`);
1065
+ }
1066
+ for (const iface of joint.stateInterfaces) {
1067
+ this.emit(`<state_interface name="${iface}"/>`);
1068
+ }
1069
+ if (joint.mimic) {
1070
+ this.emit(`<param name="mimic">${joint.mimic.joint}</param>`);
1071
+ this.emit(`<param name="multiplier">${joint.mimic.multiplier}</param>`);
1072
+ }
1073
+ this.indentLevel--;
1074
+ this.emit("</joint>");
1075
+ }
1076
+ if (control.sensors) {
1077
+ for (const sensor of control.sensors) {
1078
+ this.emit(`<sensor name="${this.escapeStringValue(sensor.name, "TypeScript")}">`);
1079
+ this.indentLevel++;
1080
+ for (const iface of sensor.stateInterfaces) {
1081
+ this.emit(`<state_interface name="${iface}"/>`);
1082
+ }
1083
+ this.indentLevel--;
1084
+ this.emit("</sensor>");
1085
+ }
1086
+ }
1087
+ this.indentLevel--;
1088
+ this.emit("</ros2_control>");
1089
+ this.emitBlank();
1090
+ }
1091
+ /** Emit Gazebo plugin tags */
1092
+ emitGazeboPlugins(composition) {
1093
+ this.emit("<!-- Gazebo Plugins -->");
1094
+ this.emit("<gazebo>");
1095
+ this.indentLevel++;
1096
+ if (this.options.enableSelfCollision) {
1097
+ this.emit("<self_collide>true</self_collide>");
1098
+ }
1099
+ if (this.options.includeROS2Control && this.ros2Controls.length > 0) {
1100
+ this.emit('<plugin filename="gz_ros2_control-system" name="gz_ros2_control">');
1101
+ this.indentLevel++;
1102
+ this.emit(
1103
+ "<parameters>$(find " + this.options.packageName + ")/config/controllers.yaml</parameters>"
1104
+ );
1105
+ this.indentLevel--;
1106
+ this.emit("</plugin>");
1107
+ }
1108
+ this.indentLevel--;
1109
+ this.emit("</gazebo>");
1110
+ this.emitBlank();
1111
+ for (const link of this.links) {
1112
+ if (link.name === "base_link" && !link.visual) continue;
1113
+ const hasSpecialConfig = link.visual?.color || link.collision;
1114
+ if (hasSpecialConfig) {
1115
+ this.emit(
1116
+ `<gazebo reference="${this.escapeStringValue(link.name, "TypeScript")}">`
1117
+ );
1118
+ this.indentLevel++;
1119
+ if (link.visual?.color) {
1120
+ const rgba = this.parseColor(link.visual.color);
1121
+ this.emit(`<material>Gazebo/${this.getGazeboColorName(rgba)}</material>`);
1122
+ }
1123
+ if (link.collision) {
1124
+ this.emit(`<mu1>${this.options.defaultMu1}</mu1>`);
1125
+ this.emit(`<mu2>${this.options.defaultMu2}</mu2>`);
1126
+ this.emit(`<kp>${this.options.defaultKp}</kp>`);
1127
+ this.emit(`<kd>${this.options.defaultKd}</kd>`);
1128
+ }
1129
+ this.indentLevel--;
1130
+ this.emit("</gazebo>");
1131
+ this.emitBlank();
1132
+ }
1133
+ }
1134
+ }
1135
+ /** Map RGBA to closest Gazebo built-in color name */
1136
+ getGazeboColorName(rgba) {
1137
+ if (rgba.r > 0.8 && rgba.g < 0.3 && rgba.b < 0.3) return "Red";
1138
+ if (rgba.r < 0.3 && rgba.g > 0.6 && rgba.b < 0.3) return "Green";
1139
+ if (rgba.r < 0.3 && rgba.g < 0.3 && rgba.b > 0.8) return "Blue";
1140
+ if (rgba.r > 0.8 && rgba.g > 0.8 && rgba.b < 0.3) return "Yellow";
1141
+ if (rgba.r < 0.3 && rgba.g > 0.8 && rgba.b > 0.8) return "Turquoise";
1142
+ if (rgba.r > 0.8 && rgba.g < 0.3 && rgba.b > 0.8) return "Purple";
1143
+ if (rgba.r > 0.8 && rgba.g > 0.5 && rgba.b < 0.2) return "Orange";
1144
+ if (rgba.r > 0.9 && rgba.g > 0.9 && rgba.b > 0.9) return "White";
1145
+ if (rgba.r < 0.1 && rgba.g < 0.1 && rgba.b < 0.1) return "Black";
1146
+ if (rgba.r > 0.4 && rgba.r < 0.6 && rgba.g > 0.4 && rgba.g < 0.6) return "Grey";
1147
+ return "DarkGrey";
1148
+ }
1149
+ /** Emit Gazebo sensor tag for a specific sensor */
1150
+ emitGazeboSensor(sensor) {
1151
+ this.emit(`<gazebo reference="${sensor.parentLink}">`);
1152
+ this.indentLevel++;
1153
+ this.emit(
1154
+ `<sensor name="${this.escapeStringValue(sensor.name, "TypeScript")}" type="${this.getGazeboSensorType(sensor.type)}">`
1155
+ );
1156
+ this.indentLevel++;
1157
+ this.emit(`<always_on>true</always_on>`);
1158
+ this.emit(`<update_rate>${sensor.updateRate ?? 30}</update_rate>`);
1159
+ this.emit(`<visualize>true</visualize>`);
1160
+ if ((sensor.type === "camera" || sensor.type === "depth_camera") && sensor.camera) {
1161
+ this.emit("<camera>");
1162
+ this.indentLevel++;
1163
+ this.emit(`<horizontal_fov>${sensor.camera.horizontalFov}</horizontal_fov>`);
1164
+ this.emit("<image>");
1165
+ this.indentLevel++;
1166
+ this.emit(`<width>${sensor.camera.imageWidth}</width>`);
1167
+ this.emit(`<height>${sensor.camera.imageHeight}</height>`);
1168
+ this.emit(`<format>${sensor.camera.format || "R8G8B8"}</format>`);
1169
+ this.indentLevel--;
1170
+ this.emit("</image>");
1171
+ this.emit("<clip>");
1172
+ this.indentLevel++;
1173
+ this.emit(`<near>${sensor.camera.clipNear}</near>`);
1174
+ this.emit(`<far>${sensor.camera.clipFar}</far>`);
1175
+ this.indentLevel--;
1176
+ this.emit("</clip>");
1177
+ this.indentLevel--;
1178
+ this.emit("</camera>");
1179
+ this.emit('<plugin name="camera_controller" filename="libgazebo_ros_camera.so">');
1180
+ this.indentLevel++;
1181
+ this.emit(`<frame_name>${sensor.frameName}</frame_name>`);
1182
+ this.indentLevel--;
1183
+ this.emit("</plugin>");
1184
+ }
1185
+ if ((sensor.type === "lidar" || sensor.type === "ray") && sensor.lidar) {
1186
+ this.emit("<ray>");
1187
+ this.indentLevel++;
1188
+ this.emit("<scan>");
1189
+ this.indentLevel++;
1190
+ this.emit("<horizontal>");
1191
+ this.indentLevel++;
1192
+ this.emit(`<samples>${sensor.lidar.samples}</samples>`);
1193
+ this.emit(`<resolution>${sensor.lidar.resolution}</resolution>`);
1194
+ this.emit(`<min_angle>${sensor.lidar.minAngle}</min_angle>`);
1195
+ this.emit(`<max_angle>${sensor.lidar.maxAngle}</max_angle>`);
1196
+ this.indentLevel--;
1197
+ this.emit("</horizontal>");
1198
+ this.indentLevel--;
1199
+ this.emit("</scan>");
1200
+ this.emit("<range>");
1201
+ this.indentLevel++;
1202
+ this.emit(`<min>${sensor.lidar.minRange}</min>`);
1203
+ this.emit(`<max>${sensor.lidar.maxRange}</max>`);
1204
+ this.emit("<resolution>0.01</resolution>");
1205
+ this.indentLevel--;
1206
+ this.emit("</range>");
1207
+ this.indentLevel--;
1208
+ this.emit("</ray>");
1209
+ this.emit('<plugin name="laser_controller" filename="libgazebo_ros_ray_sensor.so">');
1210
+ this.indentLevel++;
1211
+ this.emit(`<ros><remapping>~/out:=${sensor.topicName || "/scan"}</remapping></ros>`);
1212
+ this.emit("<output_type>sensor_msgs/LaserScan</output_type>");
1213
+ this.emit(`<frame_name>${sensor.frameName}</frame_name>`);
1214
+ this.indentLevel--;
1215
+ this.emit("</plugin>");
1216
+ }
1217
+ if (sensor.type === "imu") {
1218
+ this.emit("<imu>");
1219
+ this.indentLevel++;
1220
+ if (sensor.imu?.gaussianNoise) {
1221
+ this.emit(
1222
+ `<noise><type>gaussian</type><stddev>${sensor.imu.gaussianNoise}</stddev></noise>`
1223
+ );
1224
+ }
1225
+ this.indentLevel--;
1226
+ this.emit("</imu>");
1227
+ this.emit('<plugin name="imu_controller" filename="libgazebo_ros_imu_sensor.so">');
1228
+ this.indentLevel++;
1229
+ this.emit(`<ros><remapping>~/out:=${sensor.topicName || "/imu/data"}</remapping></ros>`);
1230
+ this.emit(`<frame_name>${sensor.frameName}</frame_name>`);
1231
+ this.indentLevel--;
1232
+ this.emit("</plugin>");
1233
+ }
1234
+ if (sensor.type === "force_torque") {
1235
+ this.emit("<force_torque>");
1236
+ this.indentLevel++;
1237
+ this.emit("<measure_direction>child_to_parent</measure_direction>");
1238
+ this.indentLevel--;
1239
+ this.emit("</force_torque>");
1240
+ }
1241
+ if (sensor.type === "contact") {
1242
+ this.emit("<contact>");
1243
+ this.indentLevel++;
1244
+ this.emit(`<collision>${sensor.parentLink}_collision</collision>`);
1245
+ this.indentLevel--;
1246
+ this.emit("</contact>");
1247
+ this.emit('<plugin name="bumper_controller" filename="libgazebo_ros_bumper.so">');
1248
+ this.indentLevel++;
1249
+ this.emit(
1250
+ `<ros><remapping>bumper_states:=${sensor.topicName || "/bumper"}</remapping></ros>`
1251
+ );
1252
+ this.emit(`<frame_name>${sensor.frameName}</frame_name>`);
1253
+ this.indentLevel--;
1254
+ this.emit("</plugin>");
1255
+ }
1256
+ if (sensor.type === "gps") {
1257
+ this.emit('<plugin name="gps_controller" filename="libgazebo_ros_gps_sensor.so">');
1258
+ this.indentLevel++;
1259
+ this.emit(`<ros><remapping>~/out:=${sensor.topicName || "/gps/fix"}</remapping></ros>`);
1260
+ this.emit(`<frame_name>${sensor.frameName}</frame_name>`);
1261
+ this.indentLevel--;
1262
+ this.emit("</plugin>");
1263
+ }
1264
+ this.indentLevel--;
1265
+ this.emit("</sensor>");
1266
+ this.indentLevel--;
1267
+ this.emit("</gazebo>");
1268
+ this.emitBlank();
1269
+ }
1270
+ /** Map sensor type to Gazebo sensor type string */
1271
+ getGazeboSensorType(type) {
1272
+ switch (type) {
1273
+ case "camera":
1274
+ return "camera";
1275
+ case "depth_camera":
1276
+ return "depth";
1277
+ case "imu":
1278
+ return "imu";
1279
+ case "lidar":
1280
+ case "ray":
1281
+ return "ray";
1282
+ case "force_torque":
1283
+ return "force_torque";
1284
+ case "contact":
1285
+ return "contact";
1286
+ case "gps":
1287
+ return "gps";
1288
+ default:
1289
+ return "camera";
1290
+ }
1291
+ }
1292
+ /** Emit HoloScript extension comments */
1293
+ emitHoloExtensions(composition) {
1294
+ this.emitBlank();
1295
+ this.emit("<!-- HoloScript Extensions -->");
1296
+ this.emit(
1297
+ `<!-- Original composition: "${this.escapeStringValue(composition.name, "TypeScript")}" -->`
1298
+ );
1299
+ const skybox = this.getEnvProp(composition, "skybox");
1300
+ if (skybox && typeof skybox === "string") {
1301
+ this.emit(`<!-- Environment skybox: ${skybox} -->`);
1302
+ }
1303
+ if (composition.templates && composition.templates.length > 0) {
1304
+ this.emit(`<!-- Templates: ${composition.templates.map((t) => t.name).join(", ")} -->`);
1305
+ }
1306
+ if (this.sensors.length > 0) {
1307
+ this.emit(
1308
+ `<!-- Sensors: ${this.sensors.map((s) => `${this.escapeStringValue(s.name, "TypeScript")} (${s.type})`).join(", ")} -->`
1309
+ );
1310
+ }
1311
+ }
1312
+ /** Helper to get environment property from either array or object format */
1313
+ getEnvProp(composition, key) {
1314
+ const env = composition.environment;
1315
+ if (!env) return void 0;
1316
+ if (Array.isArray(env.properties)) {
1317
+ const prop = env.properties.find((p) => p.key === key);
1318
+ if (prop) return prop.value;
1319
+ }
1320
+ if (key in env) {
1321
+ return env[key];
1322
+ }
1323
+ if (env.properties && typeof env.properties === "object" && !Array.isArray(env.properties)) {
1324
+ const props = env.properties;
1325
+ if (key in props) {
1326
+ return props[key];
1327
+ }
1328
+ }
1329
+ return void 0;
1330
+ }
1331
+ // ===========================================================================
1332
+ // ISAAC SIM EXTENSION EMISSION
1333
+ // ===========================================================================
1334
+ /** Emit Isaac Sim sensor extension tag */
1335
+ emitIsaacSimSensor(sensor) {
1336
+ this.emit(
1337
+ `<sensor name="${this.escapeStringValue(sensor.name, "TypeScript")}" type="${sensor.type}" isaac_sim_config="${sensor.isaacSimConfig}">`
1338
+ );
1339
+ this.indentLevel++;
1340
+ this.emit(`<parent link="${sensor.parentLink}"/>`);
1341
+ if (sensor.origin) {
1342
+ this.emitOrigin(sensor.origin);
1343
+ }
1344
+ this.indentLevel--;
1345
+ this.emit("</sensor>");
1346
+ }
1347
+ /** Emit Isaac Sim loop joint extension tag */
1348
+ emitLoopJoint(loopJoint) {
1349
+ this.emit(
1350
+ `<loop_joint name="${this.escapeStringValue(loopJoint.name, "TypeScript")}" type="${loopJoint.type}">`
1351
+ );
1352
+ this.indentLevel++;
1353
+ this.emit(
1354
+ `<link1 link="${loopJoint.link1.link}" rpy="${loopJoint.link1.rpy.join(" ")}" xyz="${loopJoint.link1.xyz.join(" ")}"/>`
1355
+ );
1356
+ this.emit(
1357
+ `<link1 link="${loopJoint.link2.link}" rpy="${loopJoint.link2.rpy.join(" ")}" xyz="${loopJoint.link2.xyz.join(" ")}"/>`
1358
+ );
1359
+ this.indentLevel--;
1360
+ this.emit("</loop_joint>");
1361
+ }
1362
+ /** Emit Isaac Sim fixed frame extension tag */
1363
+ emitFixedFrame(frame) {
1364
+ this.emit(`<fixed_frame name="${this.escapeStringValue(frame.name, "TypeScript")}">`);
1365
+ this.indentLevel++;
1366
+ this.emit(`<parent link="${frame.parentLink}"/>`);
1367
+ this.emitOrigin(frame.origin);
1368
+ this.indentLevel--;
1369
+ this.emit("</fixed_frame>");
1370
+ }
1371
+ /** Emit Isaac Sim PhysX configuration comments */
1372
+ emitIsaacSimExtensions() {
1373
+ if (!this.options.includeIsaacSimExtensions) return;
1374
+ this.emitBlank();
1375
+ this.emit("<!-- Isaac Sim Extensions -->");
1376
+ for (const sensor of this.isaacSimSensors) {
1377
+ this.emitIsaacSimSensor(sensor);
1378
+ }
1379
+ for (const loopJoint of this.loopJoints) {
1380
+ this.emitLoopJoint(loopJoint);
1381
+ }
1382
+ for (const fixedFrame of this.fixedFrames) {
1383
+ this.emitFixedFrame(fixedFrame);
1384
+ }
1385
+ this.emit(
1386
+ `<!-- isaac_sim_config: drive_type=${this.options.isaacSimDriveType} target_type=${this.options.isaacSimTargetType} -->`
1387
+ );
1388
+ this.emit(
1389
+ `<!-- isaac_sim_config: solver_position_iterations=${this.options.isaacSimSolverPositionIterations} solver_velocity_iterations=${this.options.isaacSimSolverVelocityIterations} -->`
1390
+ );
1391
+ }
1392
+ };
1393
+ URDFCompiler_default = URDFCompiler;
1394
+ }
1395
+ });
1396
+
1397
+ export { URDFCompiler, URDFCompiler_default, URDFCompiler_exports, compileForGazebo, compileForIsaacSim, compileForROS2, compileToURDF, createURDFCompiler, generateControllersYaml, generateROS2LaunchFile, init_URDFCompiler };
1398
+ //# sourceMappingURL=chunk-HZTDET3N.js.map
1399
+ //# sourceMappingURL=chunk-HZTDET3N.js.map