@holoscript/core 6.0.4 → 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 (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +3 -2
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/index.d.ts +501 -19
  7. package/dist/paper-0c-spike/index.d.ts +29 -0
  8. package/dist/reconstruction/index.d.ts +78 -0
  9. package/dist/tools/index.d.ts +22 -1
  10. package/dist/traitDocs/traitDocs.d.ts +69 -0
  11. package/dist/traits/index.d.ts +61 -0
  12. package/package.json +105 -57
  13. package/dist/GLTFPipeline-DEN36VNK.js +0 -12
  14. package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
  15. package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
  16. package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
  17. package/dist/USDZExporter-NTMBNTDB.js +0 -707
  18. package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
  19. package/dist/chunk-27LWW5FU.cjs +0 -410
  20. package/dist/chunk-2CWOLHTE.js +0 -69
  21. package/dist/chunk-33LSUQDD.cjs +0 -835
  22. package/dist/chunk-3FJCK5XA.js +0 -2232
  23. package/dist/chunk-3FXV5S25.cjs +0 -633
  24. package/dist/chunk-3FYZOR7S.cjs +0 -69
  25. package/dist/chunk-3SAK5KFL.cjs +0 -83
  26. package/dist/chunk-4XSNJCLC.cjs +0 -1859
  27. package/dist/chunk-54FHG2MX.js +0 -655
  28. package/dist/chunk-56IF4NTA.js +0 -56
  29. package/dist/chunk-5BGSECRJ.cjs +0 -2237
  30. package/dist/chunk-5GLCTO44.js +0 -161
  31. package/dist/chunk-5O6TQC6M.cjs +0 -1871
  32. package/dist/chunk-5OEOHAAW.cjs +0 -682
  33. package/dist/chunk-5TOFIR6L.js +0 -407
  34. package/dist/chunk-5WUNN6ZN.cjs +0 -428
  35. package/dist/chunk-6TZPZCOJ.cjs +0 -1404
  36. package/dist/chunk-6UEHYZ7V.cjs +0 -773
  37. package/dist/chunk-6XSERL6L.js +0 -5678
  38. package/dist/chunk-72EQECGT.cjs +0 -908
  39. package/dist/chunk-7AGYRWKW.cjs +0 -507
  40. package/dist/chunk-7LCYLPW2.cjs +0 -663
  41. package/dist/chunk-A7PIMZGU.js +0 -263
  42. package/dist/chunk-ATSKSYVE.cjs +0 -51683
  43. package/dist/chunk-B5TCIAPQ.cjs +0 -117
  44. package/dist/chunk-BF2235SI.cjs +0 -5714
  45. package/dist/chunk-BKIGPPVM.js +0 -629
  46. package/dist/chunk-BND3ST2K.cjs +0 -662
  47. package/dist/chunk-BU7VWW2K.js +0 -2522
  48. package/dist/chunk-BWFJEM5A.js +0 -5419
  49. package/dist/chunk-CAUCGUEA.cjs +0 -130
  50. package/dist/chunk-CBJSLA2E.cjs +0 -5423
  51. package/dist/chunk-CDPGV4DN.js +0 -114
  52. package/dist/chunk-CLYEIWA5.cjs +0 -408
  53. package/dist/chunk-CS2EMTGF.js +0 -1966
  54. package/dist/chunk-DMG7C4H2.js +0 -975
  55. package/dist/chunk-DXJQDCFL.js +0 -468
  56. package/dist/chunk-E3FWRT3Z.js +0 -608
  57. package/dist/chunk-E3UALNFA.js +0 -421
  58. package/dist/chunk-EONILVMF.js +0 -762
  59. package/dist/chunk-EQV4R3EV.cjs +0 -769
  60. package/dist/chunk-F3HH56EB.cjs +0 -5538
  61. package/dist/chunk-F4IULT7N.js +0 -1488
  62. package/dist/chunk-FF3Q7ADR.js +0 -380
  63. package/dist/chunk-FFKU7BTK.cjs +0 -1046
  64. package/dist/chunk-FHQVYCH2.js +0 -70
  65. package/dist/chunk-FSF7EQVA.cjs +0 -1974
  66. package/dist/chunk-G4VZTCIB.js +0 -659
  67. package/dist/chunk-G7CT3EMP.cjs +0 -1002
  68. package/dist/chunk-GGHSW2NN.js +0 -51334
  69. package/dist/chunk-GVUR45UF.cjs +0 -777
  70. package/dist/chunk-H5Z7NASB.js +0 -9662
  71. package/dist/chunk-HE7ULERA.cjs +0 -697
  72. package/dist/chunk-HJJLD366.js +0 -1169
  73. package/dist/chunk-HPS76H7Q.js +0 -309
  74. package/dist/chunk-HQUEA5R6.cjs +0 -424
  75. package/dist/chunk-HYNTS5CP.js +0 -422
  76. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  77. package/dist/chunk-IBDG74G2.cjs +0 -1219
  78. package/dist/chunk-IFNQFCTM.js +0 -3098
  79. package/dist/chunk-IHOUYQIA.js +0 -406
  80. package/dist/chunk-ILRBGFVD.cjs +0 -72
  81. package/dist/chunk-IWI6J7FX.js +0 -421
  82. package/dist/chunk-K3JDKWGI.cjs +0 -270
  83. package/dist/chunk-K6EKD26I.js +0 -630
  84. package/dist/chunk-KCQ5NDYC.cjs +0 -3172
  85. package/dist/chunk-KED34ILP.js +0 -832
  86. package/dist/chunk-KSGXLT74.cjs +0 -457
  87. package/dist/chunk-L4G4RLXX.js +0 -767
  88. package/dist/chunk-LDP5OK6G.js +0 -1216
  89. package/dist/chunk-LGGRPKTV.cjs +0 -735
  90. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  91. package/dist/chunk-LSW7P7ML.js +0 -3675
  92. package/dist/chunk-LXJ4667L.cjs +0 -3874
  93. package/dist/chunk-LZ266PCM.cjs +0 -4499
  94. package/dist/chunk-MD6KDHVE.cjs +0 -237
  95. package/dist/chunk-MEASWI2Y.js +0 -126
  96. package/dist/chunk-MPXBVFHQ.js +0 -768
  97. package/dist/chunk-N5FTS757.cjs +0 -415
  98. package/dist/chunk-NCUKG4SK.cjs +0 -3075
  99. package/dist/chunk-NDQNIJEH.js +0 -1715
  100. package/dist/chunk-NOZZ46QU.js +0 -168
  101. package/dist/chunk-OFKWH2IP.js +0 -449
  102. package/dist/chunk-PHENW4MQ.js +0 -65
  103. package/dist/chunk-PMGODDJA.cjs +0 -319
  104. package/dist/chunk-Q4QX3AET.cjs +0 -1505
  105. package/dist/chunk-Q56TT7IL.js +0 -483
  106. package/dist/chunk-Q5JT3YML.cjs +0 -129
  107. package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
  108. package/dist/chunk-QGKNANZ3.js +0 -3071
  109. package/dist/chunk-QLEAOI3Q.cjs +0 -424
  110. package/dist/chunk-R7MA7QWV.js +0 -732
  111. package/dist/chunk-RVYPEYPX.js +0 -678
  112. package/dist/chunk-S2N5TNMA.js +0 -1855
  113. package/dist/chunk-S565K7NK.js +0 -752
  114. package/dist/chunk-SDAMZIRE.js +0 -765
  115. package/dist/chunk-T36DDXSF.js +0 -4250
  116. package/dist/chunk-T4NKMBDL.js +0 -5474
  117. package/dist/chunk-T7LEXZUZ.cjs +0 -2526
  118. package/dist/chunk-TEWCN33Y.js +0 -694
  119. package/dist/chunk-TQSZUOW5.cjs +0 -793
  120. package/dist/chunk-TSH3MSQU.cjs +0 -129
  121. package/dist/chunk-UERJ3YJV.js +0 -504
  122. package/dist/chunk-UPJBDCVF.js +0 -1395
  123. package/dist/chunk-V3NN3HPP.js +0 -4462
  124. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  125. package/dist/chunk-WB4Z63GG.js +0 -229
  126. package/dist/chunk-WDW67DZB.cjs +0 -9728
  127. package/dist/chunk-WGMEAYBG.js +0 -126
  128. package/dist/chunk-X4ZF6CNE.cjs +0 -473
  129. package/dist/chunk-X6SEAXAX.cjs +0 -3681
  130. package/dist/chunk-XCWFGZAA.js +0 -1043
  131. package/dist/chunk-XD6IYDUX.js +0 -903
  132. package/dist/chunk-XG23EUQX.cjs +0 -1717
  133. package/dist/chunk-XRKWN5PL.cjs +0 -173
  134. package/dist/chunk-XUILI4KB.cjs +0 -430
  135. package/dist/chunk-XUTX5CBW.js +0 -126
  136. package/dist/chunk-XWPNTWDN.cjs +0 -755
  137. package/dist/chunk-XXINBTZK.cjs +0 -633
  138. package/dist/chunk-YCXFCXDS.js +0 -1868
  139. package/dist/chunk-YQK5JNFK.js +0 -3725
  140. package/dist/chunk-YYXH45E2.js +0 -426
  141. package/dist/chunk-Z34RLXRA.cjs +0 -612
  142. package/dist/chunk-ZP4D3CSX.cjs +0 -72
  143. package/dist/cli/holoscript-runner.cjs +0 -2259
  144. package/dist/cli/holoscript-runner.js +0 -2234
  145. package/dist/codebase/index.cjs +0 -336
  146. package/dist/codebase/index.js +0 -331
  147. package/dist/compiler/agent-inference.cjs +0 -28
  148. package/dist/compiler/agent-inference.js +0 -5
  149. package/dist/compiler/android-xr.cjs +0 -19
  150. package/dist/compiler/android-xr.js +0 -9
  151. package/dist/compiler/android.cjs +0 -20
  152. package/dist/compiler/android.js +0 -10
  153. package/dist/compiler/ar.cjs +0 -20
  154. package/dist/compiler/ar.js +0 -8
  155. package/dist/compiler/babylon.cjs +0 -17
  156. package/dist/compiler/babylon.js +0 -11
  157. package/dist/compiler/coco.cjs +0 -27
  158. package/dist/compiler/coco.js +0 -4
  159. package/dist/compiler/domain-block-utils.cjs +0 -602
  160. package/dist/compiler/domain-block-utils.js +0 -8
  161. package/dist/compiler/dtdl.cjs +0 -24
  162. package/dist/compiler/dtdl.js +0 -8
  163. package/dist/compiler/gltf-pipeline.cjs +0 -39
  164. package/dist/compiler/gltf-pipeline.js +0 -4
  165. package/dist/compiler/godot.cjs +0 -15
  166. package/dist/compiler/godot.js +0 -9
  167. package/dist/compiler/incremental.cjs +0 -29
  168. package/dist/compiler/incremental.js +0 -4
  169. package/dist/compiler/index.cjs +0 -2578
  170. package/dist/compiler/index.js +0 -2383
  171. package/dist/compiler/ios.cjs +0 -20
  172. package/dist/compiler/ios.js +0 -10
  173. package/dist/compiler/multi-layer.cjs +0 -20
  174. package/dist/compiler/multi-layer.js +0 -11
  175. package/dist/compiler/nodetoy.cjs +0 -23
  176. package/dist/compiler/nodetoy.js +0 -4
  177. package/dist/compiler/openxr.cjs +0 -15
  178. package/dist/compiler/openxr.js +0 -9
  179. package/dist/compiler/playcanvas.cjs +0 -16
  180. package/dist/compiler/playcanvas.js +0 -10
  181. package/dist/compiler/r3f.cjs +0 -34
  182. package/dist/compiler/r3f.js +0 -12
  183. package/dist/compiler/remotion.cjs +0 -23
  184. package/dist/compiler/remotion.js +0 -4
  185. package/dist/compiler/reproducibility.cjs +0 -39
  186. package/dist/compiler/reproducibility.js +0 -4
  187. package/dist/compiler/sdf.cjs +0 -21
  188. package/dist/compiler/sdf.js +0 -9
  189. package/dist/compiler/semantic-scene.cjs +0 -31
  190. package/dist/compiler/semantic-scene.js +0 -4
  191. package/dist/compiler/state.cjs +0 -17
  192. package/dist/compiler/state.js +0 -7
  193. package/dist/compiler/trait-composition.cjs +0 -26
  194. package/dist/compiler/trait-composition.js +0 -5
  195. package/dist/compiler/unity.cjs +0 -15
  196. package/dist/compiler/unity.js +0 -9
  197. package/dist/compiler/unreal.cjs +0 -19
  198. package/dist/compiler/unreal.js +0 -9
  199. package/dist/compiler/urdf.cjs +0 -45
  200. package/dist/compiler/urdf.js +0 -9
  201. package/dist/compiler/usd-physics.cjs +0 -23
  202. package/dist/compiler/usd-physics.js +0 -6
  203. package/dist/compiler/visionos.cjs +0 -15
  204. package/dist/compiler/visionos.js +0 -9
  205. package/dist/compiler/vrchat.cjs +0 -19
  206. package/dist/compiler/vrchat.js +0 -9
  207. package/dist/compiler/vrr.cjs +0 -21
  208. package/dist/compiler/vrr.js +0 -9
  209. package/dist/compiler/wasm.cjs +0 -33
  210. package/dist/compiler/wasm.js +0 -9
  211. package/dist/compiler/webgpu.cjs +0 -15
  212. package/dist/compiler/webgpu.js +0 -9
  213. package/dist/debugger.cjs +0 -21
  214. package/dist/debugger.js +0 -8
  215. package/dist/entries/interop.cjs +0 -62
  216. package/dist/entries/interop.js +0 -5
  217. package/dist/entries/scripting.cjs +0 -68
  218. package/dist/entries/scripting.js +0 -11
  219. package/dist/index.cjs +0 -40921
  220. package/dist/index.js +0 -37763
  221. package/dist/math/vec3.cjs +0 -57
  222. package/dist/math/vec3.js +0 -4
  223. package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
  224. package/dist/ml-dsa-WYLJHJO6.js +0 -1178
  225. package/dist/parser.cjs +0 -27
  226. package/dist/parser.js +0 -10
  227. package/dist/playwright-5OSAPTNH.js +0 -98660
  228. package/dist/playwright-RL6GY4F7.cjs +0 -98673
  229. package/dist/runtime.cjs +0 -16
  230. package/dist/runtime.js +0 -7
  231. package/dist/storage/index.cjs +0 -37
  232. package/dist/storage/index.js +0 -4
  233. package/dist/traits/index.cjs +0 -14649
  234. package/dist/traits/index.js +0 -12243
  235. package/dist/type-checker.cjs +0 -18
  236. package/dist/type-checker.js +0 -5
@@ -1,1404 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkLXJ4667L_cjs = require('./chunk-LXJ4667L.cjs');
4
- var chunkBF2235SI_cjs = require('./chunk-BF2235SI.cjs');
5
- var chunk3SAK5KFL_cjs = require('./chunk-3SAK5KFL.cjs');
6
- var platform = require('@holoscript/platform');
7
-
8
- // src/compiler/URDFCompiler.ts
9
- var URDFCompiler_exports = {};
10
- chunk3SAK5KFL_cjs.__export(URDFCompiler_exports, {
11
- URDFCompiler: () => exports.URDFCompiler,
12
- compileForGazebo: () => compileForGazebo,
13
- compileForIsaacSim: () => compileForIsaacSim,
14
- compileForROS2: () => compileForROS2,
15
- compileToURDF: () => compileToURDF,
16
- default: () => exports.URDFCompiler_default,
17
- generateControllersYaml: () => generateControllersYaml,
18
- generateROS2LaunchFile: () => generateROS2LaunchFile
19
- });
20
- function compileToURDF(composition, options) {
21
- const compiler = new exports.URDFCompiler(options);
22
- return compiler.compile(composition);
23
- }
24
- function compileForROS2(composition, options) {
25
- const ros2Options = {
26
- includeGazeboPlugins: true,
27
- includeROS2Control: true,
28
- includeVisual: true,
29
- includeCollision: true,
30
- includeInertial: true,
31
- ...options
32
- };
33
- const compiler = new exports.URDFCompiler(ros2Options);
34
- return compiler.compile(composition);
35
- }
36
- function compileForGazebo(composition, options) {
37
- const gazeboOptions = {
38
- includeGazeboPlugins: true,
39
- gazeboVersion: "classic",
40
- includeVisual: true,
41
- includeCollision: true,
42
- includeInertial: true,
43
- ...options
44
- };
45
- const compiler = new exports.URDFCompiler(gazeboOptions);
46
- return compiler.compile(composition);
47
- }
48
- function compileForIsaacSim(composition, options) {
49
- const isaacOptions = {
50
- includeVisual: true,
51
- includeCollision: true,
52
- includeInertial: true,
53
- includeGazeboPlugins: false,
54
- // Isaac Sim uses PhysX, not Gazebo plugins
55
- includeROS2Control: true,
56
- includeIsaacSimExtensions: true,
57
- isaacSimDriveType: "acceleration",
58
- isaacSimTargetType: "position",
59
- isaacSimSolverPositionIterations: 8,
60
- isaacSimSolverVelocityIterations: 4,
61
- ...options
62
- };
63
- const compiler = new exports.URDFCompiler(isaacOptions);
64
- return compiler.compile(composition);
65
- }
66
- function generateROS2LaunchFile(packageName, urdfFilename, options) {
67
- const useSimTime = options?.useSimTime ?? true;
68
- const rviz = options?.rviz ?? true;
69
- const gazebo = options?.gazebo ?? true;
70
- const controllers = options?.controllers ?? [
71
- "joint_state_broadcaster",
72
- "joint_trajectory_controller"
73
- ];
74
- const lines = [];
75
- lines.push('"""');
76
- lines.push(`ROS 2 Launch file for ${packageName}`);
77
- lines.push("Auto-generated by HoloScript URDFCompiler");
78
- lines.push('"""');
79
- lines.push("");
80
- lines.push("import os");
81
- lines.push("from ament_index_python.packages import get_package_share_directory");
82
- lines.push("from launch import LaunchDescription");
83
- lines.push(
84
- "from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, RegisterEventHandler"
85
- );
86
- lines.push("from launch.conditions import IfCondition");
87
- lines.push("from launch.event_handlers import OnProcessExit");
88
- lines.push("from launch.launch_description_sources import PythonLaunchDescriptionSource");
89
- lines.push(
90
- "from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution"
91
- );
92
- lines.push("from launch_ros.actions import Node");
93
- lines.push("from launch_ros.substitutions import FindPackageShare");
94
- lines.push("");
95
- lines.push("");
96
- lines.push("def generate_launch_description():");
97
- lines.push(` pkg_share = get_package_share_directory('${packageName}')`);
98
- lines.push(` urdf_file = os.path.join(pkg_share, 'urdf', '${urdfFilename}')`);
99
- lines.push("");
100
- lines.push(' with open(urdf_file, "r") as f:');
101
- lines.push(" robot_description = f.read()");
102
- lines.push("");
103
- lines.push(" # Robot State Publisher");
104
- lines.push(" robot_state_publisher = Node(");
105
- lines.push(" package='robot_state_publisher',");
106
- lines.push(" executable='robot_state_publisher',");
107
- lines.push(" parameters=[{");
108
- lines.push(" 'robot_description': robot_description,");
109
- lines.push(` 'use_sim_time': ${useSimTime ? "True" : "False"},`);
110
- lines.push(" }],");
111
- lines.push(" output='screen',");
112
- lines.push(" )");
113
- lines.push("");
114
- if (rviz) {
115
- lines.push(" # RViz2");
116
- lines.push(' rviz_config = os.path.join(pkg_share, "config", "display.rviz")');
117
- lines.push(" rviz = Node(");
118
- lines.push(" package='rviz2',");
119
- lines.push(" executable='rviz2',");
120
- lines.push(" arguments=['-d', rviz_config],");
121
- lines.push(` parameters=[{'use_sim_time': ${useSimTime ? "True" : "False"}}],`);
122
- lines.push(" output='screen',");
123
- lines.push(" )");
124
- lines.push("");
125
- }
126
- if (gazebo) {
127
- lines.push(" # Gazebo");
128
- lines.push(" gazebo = IncludeLaunchDescription(");
129
- lines.push(" PythonLaunchDescriptionSource([");
130
- lines.push(" FindPackageShare('ros_gz_sim'),");
131
- lines.push(" '/launch/gz_sim.launch.py',");
132
- lines.push(" ]),");
133
- lines.push(" launch_arguments={'gz_args': '-r empty.sdf'}.items(),");
134
- lines.push(" )");
135
- lines.push("");
136
- lines.push(" # Spawn robot");
137
- lines.push(" spawn_entity = Node(");
138
- lines.push(" package='ros_gz_sim',");
139
- lines.push(" executable='create',");
140
- lines.push(
141
- " arguments=['-topic', 'robot_description', '-name', '" + packageName + "'],"
142
- );
143
- lines.push(" output='screen',");
144
- lines.push(" )");
145
- lines.push("");
146
- }
147
- for (const controller of controllers) {
148
- const varName = controller.replace(/-/g, "_");
149
- lines.push(` # ${controller}`);
150
- lines.push(` ${varName}_spawner = Node(`);
151
- lines.push(" package='controller_manager',");
152
- lines.push(" executable='spawner',");
153
- lines.push(` arguments=['${controller}'],`);
154
- lines.push(" output='screen',");
155
- lines.push(" )");
156
- lines.push("");
157
- }
158
- lines.push(" return LaunchDescription([");
159
- lines.push(" robot_state_publisher,");
160
- if (rviz) lines.push(" rviz,");
161
- if (gazebo) {
162
- lines.push(" gazebo,");
163
- lines.push(" spawn_entity,");
164
- }
165
- for (const controller of controllers) {
166
- lines.push(` ${controller.replace(/-/g, "_")}_spawner,`);
167
- }
168
- lines.push(" ])");
169
- return lines.join("\n");
170
- }
171
- function generateControllersYaml(robotName, jointNames, options) {
172
- const controllerType = options?.controllerType ?? "joint_trajectory_controller/JointTrajectoryController";
173
- const publishRate = options?.publishRate ?? 50;
174
- const lines = [];
175
- lines.push("# Auto-generated by HoloScript URDFCompiler");
176
- lines.push(`# Robot: ${robotName}`);
177
- lines.push("");
178
- lines.push("controller_manager:");
179
- lines.push(" ros__parameters:");
180
- lines.push(` update_rate: ${publishRate}`);
181
- lines.push("");
182
- lines.push(" joint_state_broadcaster:");
183
- lines.push(" type: joint_state_broadcaster/JointStateBroadcaster");
184
- lines.push("");
185
- lines.push(" joint_trajectory_controller:");
186
- lines.push(` type: ${controllerType}`);
187
- lines.push("");
188
- lines.push("joint_trajectory_controller:");
189
- lines.push(" ros__parameters:");
190
- lines.push(" joints:");
191
- for (const joint of jointNames) {
192
- lines.push(` - ${joint}`);
193
- }
194
- lines.push(" command_interfaces:");
195
- lines.push(" - position");
196
- lines.push(" state_interfaces:");
197
- lines.push(" - position");
198
- lines.push(" - velocity");
199
- return lines.join("\n");
200
- }
201
- exports.URDFCompiler = void 0; exports.URDFCompiler_default = void 0;
202
- var init_URDFCompiler = chunk3SAK5KFL_cjs.__esm({
203
- "src/compiler/URDFCompiler.ts"() {
204
- chunkBF2235SI_cjs.init_CompilerBase();
205
- chunkLXJ4667L_cjs.init_DomainBlockCompilerMixin();
206
- exports.URDFCompiler = class extends chunkBF2235SI_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 platform.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 = chunkLXJ4667L_cjs.compileDomainBlocks(
560
- domainBlocks,
561
- {
562
- material: (block) => {
563
- const mat = chunkLXJ4667L_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 = chunkLXJ4667L_cjs.compilePhysicsBlock(block);
585
- return chunkLXJ4667L_cjs.physicsToURDF(phys);
586
- },
587
- audio: (block) => {
588
- const audio = chunkLXJ4667L_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 = chunkLXJ4667L_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-6TZPZCOJ.cjs.map
1404
- //# sourceMappingURL=chunk-6TZPZCOJ.cjs.map