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