@holoscript/core 7.0.0 → 8.0.1

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