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