urdf-loader 0.10.3 → 0.10.5

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/README.md CHANGED
@@ -1,579 +1,578 @@
1
- # urdf-loader
2
-
3
- [![npm version](https://img.shields.io/npm/v/urdf-loader.svg?style=flat-square)](https://www.npmjs.com/package/urdf-loader)
4
- [![build](https://img.shields.io/github/workflow/status/gkjohnson/urdf-loaders/Node.js%20CI?style=flat-square&label=build)](https://github.com/gkjohnson/urdf-loaders/actions)
5
- [![lgtm code quality](https://img.shields.io/lgtm/grade/javascript/g/gkjohnson/urdf-loaders.svg?style=flat-square&label=code-quality)](https://lgtm.com/projects/g/gkjohnson/urdf-loaders/)
6
-
7
- Utilities for loading URDF files into THREE.js and a Web Component that loads and renders the model.
8
-
9
- [Basic loader example here!](https://gkjohnson.github.io/urdf-loaders/javascript/example/bundle/simple.html)
10
-
11
- [VR example here!](https://gkjohnson.github.io/urdf-loaders/javascript/example/bundle/vr.html)
12
-
13
- [Drag and drop web component tool here!](https://gkjohnson.github.io/urdf-loaders/javascript/example/bundle/index.html)
14
-
15
- ![Example](/javascript/docs/javascript-example.gif)
16
-
17
- # Use
18
-
19
- #### Basic Use
20
-
21
- Loading a URDF file from a server.
22
-
23
- ```js
24
- import { LoadingManager } from 'three';
25
- import URDFLoader from 'urdf-loader';
26
-
27
- // ...init three.js scene...
28
-
29
- const manager = new LoadingManager();
30
- const loader = new URDFLoader( manager );
31
- loader.packages = {
32
- packageName : './package/dir/' // The equivalent of a (list of) ROS package(s):// directory
33
- };
34
- loader.load(
35
- 'T12/urdf/T12.URDF', // The path to the URDF within the package OR absolute
36
- robot => {
37
-
38
- // The robot is loaded!
39
- scene.add( robot );
40
-
41
- }
42
- );
43
- ```
44
-
45
- #### Custom Mesh Loader & Error Handling
46
-
47
- Implementing custom error handling and / or adding a custom loader for meshes can be done using the [loadMeshCb](#loadMeshCb) callback.
48
-
49
- ```js
50
- import { GLTFLoader } from 'three/examples/loaders/GLTFLoader.js';
51
- import URDFLoader from 'urdf-loader';
52
-
53
- // ...init three.js scene...
54
-
55
- const loader = new URDFLoader();
56
- loader.loadMeshCb = function( path, manager, onComplete ) {
57
-
58
- const gltfLoader = new GLTFLoader( manager );
59
- gltfLoader.load(
60
- path,
61
- result => {
62
-
63
- onComplete( result.scene );
64
-
65
- },
66
- undefined,
67
- err => {
68
-
69
- // try to load again, notify user, etc
70
-
71
- onComplete( null, err );
72
-
73
- }
74
- );
75
-
76
- };
77
- loader.load( 'T12/urdf/T12.URDF', robot => {
78
-
79
- // The robot is loaded!
80
- scene.add( robot );
81
-
82
- } );
83
-
84
- ```
85
-
86
- #### From Xacro
87
-
88
- Using [XacroParser](https://github.com/gkjohnson/xacro-parser) to process a Xacro URDF file and then parse it.
89
-
90
- ```js
91
- import { LoaderUtils } from 'three';
92
- import { XacroLoader } from 'xacro-parser';
93
- import URDFLoader from 'urdf-loader';
94
-
95
- // ...init three.js scene...
96
-
97
- const url = './path/to/file.xacro';
98
- const xacroLoader = new XacroLoader();
99
- xacroLoader.load( url, xml => {
100
-
101
- const urdfLoader = new URDFLoader();
102
- urdfLoader.workingPath = LoaderUtils.extractUrlBase( url );
103
-
104
- const robot = urdfLoader.parse( xml );
105
- scene.add( robot );
106
-
107
- } );
108
- ```
109
-
110
- ## Limitations
111
- - Only `prismatic`, `continuous`, `revolute`, and `fixed` joints are supported.
112
-
113
- # API
114
-
115
- ## URDFOptions
116
-
117
- List of options available on the URDFLoader class.
118
-
119
- ### .packages
120
-
121
- ```js
122
- packages = '' : String | Object | ( pkg : String ) => String
123
- ```
124
-
125
- The path representing the `package://` directory(s) to load `package://` relative files.
126
-
127
- If the argument is a string, then it is used to replace the `package://` prefix when loading geometry.
128
-
129
- To specify multiple packages an object syntax is used defining the package name to the package path:
130
- ```js
131
- {
132
- "package1": "./path/to/package1",
133
- "package2": "./path/to/package2",
134
- ...
135
- }
136
- ```
137
-
138
- If the setting is set to a function then it takes the package name and is expected to return the package path.
139
-
140
- ### .loadMeshCb
141
-
142
- ```js
143
- loadMeshCb = null :
144
- (
145
- pathToModel : string,
146
- manager : LoadingManager,
147
- onComplete : ( obj : Object3D, err ?: Error ) => void
148
- ) => void
149
- ```
150
-
151
- An optional function that can be used to override the default mesh loading functionality. The default loader is specified at `URDFLoader.defaultMeshLoader`.
152
-
153
- `pathToModel` is the url to load the model from.
154
-
155
- `manager` is the THREE.js `LoadingManager` used by the `URDFLoader`.
156
-
157
- `onComplete` is called with the mesh once the geometry has been loaded.
158
-
159
- ### .fetchOptions
160
-
161
- ```js
162
- fetchOptions = null : Object
163
- ```
164
-
165
- An optional object with the set of options to pass to the `fetch` function call used to load the URDF file.
166
-
167
- ### .workingPath
168
-
169
- ```js
170
- workingPath = '' : string
171
- ```
172
-
173
- The path to load geometry relative to.
174
-
175
- Defaults to the path relative to the loaded URDF file.
176
-
177
- ### .parseVisual
178
-
179
- ```js
180
- parseVisual = true : boolean
181
- ```
182
-
183
- An optional value that can be used to enable / disable loading meshes for links from the `visual` nodes. Defaults to true.
184
-
185
- ### .parseCollision
186
-
187
- ```js
188
- parseCollision = false : boolean
189
- ```
190
-
191
- An optional value that can be used to enable / disable loading meshes for links from the `collision` nodes. Defaults to false.
192
-
193
- ## URDFLoader
194
-
195
- ### .constructor
196
-
197
- ```js
198
- constructor( manager : LoadingManager )
199
- ```
200
-
201
- Constructor. Manager is used for transforming load URLs and tracking downloads.
202
-
203
- ### .load
204
-
205
- ```js
206
- load(
207
- urdfpath : string,
208
- onComplete : (robot : URDFRobot) => void,
209
- onProgress? : () => void,
210
- onError? : (error : Error) => void
211
- ) : void
212
- ```
213
-
214
- Loads and builds the specified URDF robot in THREE.js.
215
-
216
- Takes a path to load the urdf file from, a func to call when the robot has loaded, and a set of options.
217
-
218
- ### .loadAsync
219
-
220
- ```js
221
- loadAsync( urdfpath : string ) : Promise<URDFRobot>
222
- ```
223
-
224
- Promise-wrapped version of `load`.
225
-
226
- ### .parse
227
-
228
- ```js
229
- parse( urdfContent : string | Document | Element ) : URDFRobot
230
- ```
231
-
232
- Parses URDF content and returns the robot model. Takes an XML string to parse and a set of options.
233
-
234
- If the XML document has already been parsed using `DOMParser` then either the returned `Document` or root `Element` can be passed into this function in place of the string, as well.
235
-
236
- Note that geometry will not necessarily be loaded when the robot is returned.
237
-
238
- ## URDFJoint
239
-
240
- _extends Object3D_
241
-
242
- An object representing a robot joint.
243
-
244
- ### .name
245
-
246
- ```js
247
- name : string
248
- ```
249
-
250
- The name of the joint.
251
-
252
- ### .jointType
253
-
254
- ```js
255
- .jointType : string
256
- ```
257
-
258
- The type of joint. Can only be the URDF types of joints.
259
-
260
- ### .limit
261
-
262
- ```js
263
- .limit : { lower : number, upper : number }
264
- ```
265
-
266
- An object containing the `lower` and `upper` constraints for the joint.
267
-
268
- ### .axis
269
-
270
- ```js
271
- axis : Vector3
272
- ```
273
-
274
- The axis described for the joint.
275
-
276
- ### .angle
277
-
278
- _readonly_
279
-
280
- ```js
281
- angle : number
282
- ```
283
-
284
- The current position or angle for joint.
285
-
286
- ### .ignoreLimits
287
-
288
- ```js
289
- ignoreLimits : boolean
290
- ```
291
-
292
- Whether or not to ignore the joint limits when setting a the joint position.
293
-
294
- ### .mimicJoints
295
-
296
- ```js
297
- mimicJoints : URDFMimicJoints[]
298
- ```
299
-
300
- A list of joints which mimic this joint. These joints are updated whenever this joint is.
301
-
302
- ### .setJointValue
303
-
304
- ```js
305
- setJointValue( jointValue : number ) : Boolean
306
- ```
307
-
308
- Sets the joint value for the given joint. The interpretation of the value depends on the joint type. If the joint value specifies an angle it must be in radians.
309
-
310
- Returns true if the joint or any of its mimicking joints changed.
311
-
312
- ## URDFMimicJoint
313
-
314
- _extends URDFJoint_
315
-
316
- An object representing a robot joint which mimics another existing joint. The value of this joint can be computed as `value = multiplier * other_joint_value + offset`.
317
-
318
- ### .mimicJoint
319
-
320
- ```js
321
- mimicJoint : String
322
- ```
323
-
324
- The name of the joint which this joint mimics.
325
-
326
- ### .offset
327
-
328
- ```js
329
- offset : Number
330
- ```
331
-
332
- Specifies the offset to add in the formula above. Defaults to 0 (radians for revolute joints, meters for prismatic joints).
333
-
334
- ### .multiplier
335
-
336
- ```js
337
- multiplier : Number
338
- ```
339
-
340
- Specifies the multiplicative factor in the formula above. Defaults to 1.0.
341
-
342
- ## URDFLink
343
-
344
- _extends Object3D_
345
-
346
- ### .name
347
-
348
- ```js
349
- name : string
350
- ```
351
-
352
- The name of the link.
353
-
354
- ## URDFRobot
355
-
356
- _extends [URDFLink](#URDFLink)_
357
-
358
- Object that describes the URDF Robot.
359
-
360
- ### .robotName
361
-
362
- ```js
363
- robotName : string
364
- ```
365
-
366
- The name of the robot described in the `<robot>` tag.
367
-
368
- ### .links
369
-
370
- ```js
371
- links : { [key] : URDFLink }
372
- ```
373
-
374
- A dictionary of `linkName : URDFLink` with all links in the robot.
375
-
376
- ### .joints
377
-
378
- ```js
379
- joints : { [key] : URDFJoint }
380
- ```
381
-
382
- A dictionary of `jointName : URDFJoint` with all joints in the robot.
383
-
384
- ### .colliders
385
-
386
- ```js
387
- colliders : { [key] : Object3D }
388
- ```
389
-
390
- A dictionary of `colliderName : Object3D` with all collision nodes in the robot.
391
-
392
- ### .visual
393
-
394
- ```js
395
- visual : { [key] : Object3D }
396
- ```
397
-
398
- A dictionary of `visualName : Object3D` with all visual nodes in the robot.
399
-
400
- ### .frames
401
-
402
- ```js
403
- joints : { [key] : URDFJoint }
404
- ```
405
-
406
- A dictionary of all the named frames in the robot including links, joints, colliders, and visual.
407
-
408
- ### .setJointValue
409
-
410
- ```js
411
- setJointValue( name : String, value : Number ) : Boolean
412
- ```
413
-
414
- Sets the joint value of the joint with the given name. Returns true if the joint changed.
415
-
416
- ### .setJointValues
417
-
418
- ```js
419
- setJointValues( jointValueDictionary : Object ) : Boolean
420
- ```
421
-
422
- Sets the joint values for all the joints in the dictionary indexed by joint name. Returns true if a joint changed.
423
-
424
- ## urdf-viewer Element
425
- ```html
426
- <!-- Register the Element -->
427
- <script href=".../urdf-viewer-element.js"></script>
428
- <script>customElements.define('urdf-viewer', URDFViewer)</script>
429
-
430
- <body>
431
- <urdf-viewer package=".../package/dir/" urdf="T12/urdf/T12.URDF" up="Z+" display-shadow ambient-color="red"></urdf-viewer>
432
- </body>
433
- ```
434
-
435
- ### Attributes
436
-
437
- #### package
438
-
439
- Corresponds to the `package` parameter in `URDFLoader.load`. Supported are:
440
-
441
- 1. Single package:
442
-
443
- ```html
444
- <!-- 1. Example for single package named `default_package` -->
445
- <urdf-viewer package=".../path/to/default_package" ...></urdf-viewer>
446
- ```
447
-
448
- Fallback within 1: If the target package within the `package://` relative files do not match the default path it is assumed that the default path is the parent folder that contains the target package(s).
449
-
450
- ```html
451
- <!-- 1. Example for single package named `default_package` with fallback: -->
452
- <urdf-viewer package=".../path/to/parent" ...></urdf-viewer>
453
- <!-- since `parent` does not match `default_package`
454
- the path ".../path/to/parent/default_package" is assumed -->
455
- ```
456
-
457
- 2. Serialized package map:
458
-
459
- E.g. if the meshes of a URDF are distributed over mutliple packages.
460
-
461
- ```html
462
- <!-- 2. Example for serialized package map that contains `package1` and `package2` -->
463
- <urdf-viewer package="package1:.../path/to/package1, package2:.../path/to/package1" ...></urdf-viewer>
464
- ```
465
-
466
- #### urdf
467
-
468
- Corresponds to the `urdfpath` parameter in `URDFLoader.load`.
469
-
470
- The element uses fetch options `{ mode: 'cors', credentials: 'same-origin' }` to load the urdf file.
471
-
472
- #### ignore-limits
473
-
474
- Whether or not hte display should ignore the joint limits specified in the model when updating angles.
475
-
476
- #### up
477
-
478
- The axis to associate with "up" in THREE.js. Values can be [+-][XYZ].
479
-
480
- #### display-shadow
481
-
482
- Whether or not the render the shadow under the robot.
483
-
484
- #### ambient-color
485
-
486
- The color of the ambient light specified with css colors.
487
-
488
- #### auto-redraw
489
-
490
- Automatically redraw the model every frame instead of waiting to be dirtied.
491
-
492
- #### no-auto-recenter
493
-
494
- Recenter the camera only after loading the model.
495
-
496
- ### Properties
497
-
498
- All of the above attributes have corresponding camel case properties.
499
-
500
- #### .jointValues
501
-
502
- ```js
503
- jointValues : Object
504
- ```
505
-
506
- Sets or gets the jointValues of the robot as a dictionary of `joint-name` to `radian` pairs.
507
-
508
- ### Functions
509
-
510
- #### .setJointValue
511
-
512
- ```js
513
- setJointValue( jointName : String, jointValue : Number ) : void
514
- ```
515
-
516
- Sets the given joint to the provided angle in radians.
517
-
518
- #### .setJointValues
519
-
520
- ```js
521
- setJointValues( jointValueDictionary : Object ) : void
522
- ```
523
-
524
- Sets all joint names specified as keys to radian angle value.
525
-
526
- #### .redraw
527
-
528
- ```js
529
- redraw() : void
530
- ```
531
-
532
- Dirty the renderer so the element will redraw next frame.
533
-
534
- #### .recenter
535
-
536
- ```js
537
- recenter() : void
538
- ```
539
-
540
- Recenter the camera to the model and redraw.
541
-
542
- ### Events
543
-
544
- #### 'urdf-change'
545
-
546
- Fires when the URDF has changed and a new one is starting to load.
547
-
548
- #### 'ignore-limits-change'
549
-
550
- Fires when the `ignore-limits` attribute changes.
551
-
552
- #### 'urdf-processed'
553
-
554
- Fires when the URDF has finished loading and getting processed.
555
-
556
- #### 'geometry-loaded'
557
-
558
- Fires when all the geometry has been fully loaded.
559
-
560
- # Running the Example
561
-
562
- Install Node.js and NPM.
563
-
564
- Run `npm install`.
565
-
566
- Run `npm start`.
567
-
568
- Visit `localhost:9080/javascript/example/dev-bundle/` to view the page.
569
-
570
- # LICENSE
571
-
572
- The software is available under the [Apache V2.0 license](../LICENSE).
573
-
574
- Copyright © 2020 California Institute of Technology. ALL RIGHTS
575
- RESERVED. United States Government Sponsorship Acknowledged.
576
- Neither the name of Caltech nor its operating division, the
577
- Jet Propulsion Laboratory, nor the names of its contributors may be
578
- used to endorse or promote products derived from this software
579
- without specific prior written permission.
1
+ # urdf-loader
2
+
3
+ [![npm version](https://img.shields.io/npm/v/urdf-loader.svg?style=flat-square)](https://www.npmjs.com/package/urdf-loader)
4
+ [![build](https://img.shields.io/github/actions/workflow/status/gkjohnson/urdf-loaders/node.js.yml?style=flat-square&label=build&branch=master)](https://github.com/gkjohnson/urdf-loaders/actions)
5
+
6
+ Utilities for loading URDF files into THREE.js and a Web Component that loads and renders the model.
7
+
8
+ [Basic loader example here!](https://gkjohnson.github.io/urdf-loaders/javascript/example/bundle/simple.html)
9
+
10
+ [VR example here!](https://gkjohnson.github.io/urdf-loaders/javascript/example/bundle/vr.html)
11
+
12
+ [Drag and drop web component tool here!](https://gkjohnson.github.io/urdf-loaders/javascript/example/bundle/index.html)
13
+
14
+ ![Example](/javascript/docs/javascript-example.gif)
15
+
16
+ # Use
17
+
18
+ #### Basic Use
19
+
20
+ Loading a URDF file from a server.
21
+
22
+ ```js
23
+ import { LoadingManager } from 'three';
24
+ import URDFLoader from 'urdf-loader';
25
+
26
+ // ...init three.js scene...
27
+
28
+ const manager = new LoadingManager();
29
+ const loader = new URDFLoader( manager );
30
+ loader.packages = {
31
+ packageName : './package/dir/' // The equivalent of a (list of) ROS package(s):// directory
32
+ };
33
+ loader.load(
34
+ 'T12/urdf/T12.URDF', // The path to the URDF within the package OR absolute
35
+ robot => {
36
+
37
+ // The robot is loaded!
38
+ scene.add( robot );
39
+
40
+ }
41
+ );
42
+ ```
43
+
44
+ #### Custom Mesh Loader & Error Handling
45
+
46
+ Implementing custom error handling and / or adding a custom loader for meshes can be done using the [loadMeshCb](#loadMeshCb) callback.
47
+
48
+ ```js
49
+ import { GLTFLoader } from 'three/examples/loaders/GLTFLoader.js';
50
+ import URDFLoader from 'urdf-loader';
51
+
52
+ // ...init three.js scene...
53
+
54
+ const loader = new URDFLoader();
55
+ loader.loadMeshCb = function( path, manager, onComplete ) {
56
+
57
+ const gltfLoader = new GLTFLoader( manager );
58
+ gltfLoader.load(
59
+ path,
60
+ result => {
61
+
62
+ onComplete( result.scene );
63
+
64
+ },
65
+ undefined,
66
+ err => {
67
+
68
+ // try to load again, notify user, etc
69
+
70
+ onComplete( null, err );
71
+
72
+ }
73
+ );
74
+
75
+ };
76
+ loader.load( 'T12/urdf/T12.URDF', robot => {
77
+
78
+ // The robot is loaded!
79
+ scene.add( robot );
80
+
81
+ } );
82
+
83
+ ```
84
+
85
+ #### From Xacro
86
+
87
+ Using [XacroParser](https://github.com/gkjohnson/xacro-parser) to process a Xacro URDF file and then parse it.
88
+
89
+ ```js
90
+ import { LoaderUtils } from 'three';
91
+ import { XacroLoader } from 'xacro-parser';
92
+ import URDFLoader from 'urdf-loader';
93
+
94
+ // ...init three.js scene...
95
+
96
+ const url = './path/to/file.xacro';
97
+ const xacroLoader = new XacroLoader();
98
+ xacroLoader.load( url, xml => {
99
+
100
+ const urdfLoader = new URDFLoader();
101
+ urdfLoader.workingPath = LoaderUtils.extractUrlBase( url );
102
+
103
+ const robot = urdfLoader.parse( xml );
104
+ scene.add( robot );
105
+
106
+ } );
107
+ ```
108
+
109
+ ## Limitations
110
+ - Only `prismatic`, `continuous`, `revolute`, and `fixed` joints are supported.
111
+
112
+ # API
113
+
114
+ ## URDFOptions
115
+
116
+ List of options available on the URDFLoader class.
117
+
118
+ ### .packages
119
+
120
+ ```js
121
+ packages = '' : String | Object | ( pkg : String ) => String
122
+ ```
123
+
124
+ The path representing the `package://` directory(s) to load `package://` relative files.
125
+
126
+ If the argument is a string, then it is used to replace the `package://` prefix when loading geometry.
127
+
128
+ To specify multiple packages an object syntax is used defining the package name to the package path:
129
+ ```js
130
+ {
131
+ "package1": "./path/to/package1",
132
+ "package2": "./path/to/package2",
133
+ ...
134
+ }
135
+ ```
136
+
137
+ If the setting is set to a function then it takes the package name and is expected to return the package path.
138
+
139
+ ### .loadMeshCb
140
+
141
+ ```js
142
+ loadMeshCb = null :
143
+ (
144
+ pathToModel : string,
145
+ manager : LoadingManager,
146
+ onComplete : ( obj : Object3D, err ?: Error ) => void
147
+ ) => void
148
+ ```
149
+
150
+ An optional function that can be used to override the default mesh loading functionality. The default loader is specified at `URDFLoader.defaultMeshLoader`.
151
+
152
+ `pathToModel` is the url to load the model from.
153
+
154
+ `manager` is the THREE.js `LoadingManager` used by the `URDFLoader`.
155
+
156
+ `onComplete` is called with the mesh once the geometry has been loaded.
157
+
158
+ ### .fetchOptions
159
+
160
+ ```js
161
+ fetchOptions = null : Object
162
+ ```
163
+
164
+ An optional object with the set of options to pass to the `fetch` function call used to load the URDF file.
165
+
166
+ ### .workingPath
167
+
168
+ ```js
169
+ workingPath = '' : string
170
+ ```
171
+
172
+ The path to load geometry relative to.
173
+
174
+ Defaults to the path relative to the loaded URDF file.
175
+
176
+ ### .parseVisual
177
+
178
+ ```js
179
+ parseVisual = true : boolean
180
+ ```
181
+
182
+ An optional value that can be used to enable / disable loading meshes for links from the `visual` nodes. Defaults to true.
183
+
184
+ ### .parseCollision
185
+
186
+ ```js
187
+ parseCollision = false : boolean
188
+ ```
189
+
190
+ An optional value that can be used to enable / disable loading meshes for links from the `collision` nodes. Defaults to false.
191
+
192
+ ## URDFLoader
193
+
194
+ ### .constructor
195
+
196
+ ```js
197
+ constructor( manager : LoadingManager )
198
+ ```
199
+
200
+ Constructor. Manager is used for transforming load URLs and tracking downloads.
201
+
202
+ ### .load
203
+
204
+ ```js
205
+ load(
206
+ urdfpath : string,
207
+ onComplete : (robot : URDFRobot) => void,
208
+ onProgress? : () => void,
209
+ onError? : (error : Error) => void
210
+ ) : void
211
+ ```
212
+
213
+ Loads and builds the specified URDF robot in THREE.js.
214
+
215
+ Takes a path to load the urdf file from, a func to call when the robot has loaded, and a set of options.
216
+
217
+ ### .loadAsync
218
+
219
+ ```js
220
+ loadAsync( urdfpath : string ) : Promise<URDFRobot>
221
+ ```
222
+
223
+ Promise-wrapped version of `load`.
224
+
225
+ ### .parse
226
+
227
+ ```js
228
+ parse( urdfContent : string | Document | Element ) : URDFRobot
229
+ ```
230
+
231
+ Parses URDF content and returns the robot model. Takes an XML string to parse and a set of options.
232
+
233
+ If the XML document has already been parsed using `DOMParser` then either the returned `Document` or root `Element` can be passed into this function in place of the string, as well.
234
+
235
+ Note that geometry will not necessarily be loaded when the robot is returned.
236
+
237
+ ## URDFJoint
238
+
239
+ _extends Object3D_
240
+
241
+ An object representing a robot joint.
242
+
243
+ ### .name
244
+
245
+ ```js
246
+ name : string
247
+ ```
248
+
249
+ The name of the joint.
250
+
251
+ ### .jointType
252
+
253
+ ```js
254
+ .jointType : string
255
+ ```
256
+
257
+ The type of joint. Can only be the URDF types of joints.
258
+
259
+ ### .limit
260
+
261
+ ```js
262
+ .limit : { lower : number, upper : number }
263
+ ```
264
+
265
+ An object containing the `lower` and `upper` constraints for the joint.
266
+
267
+ ### .axis
268
+
269
+ ```js
270
+ axis : Vector3
271
+ ```
272
+
273
+ The axis described for the joint.
274
+
275
+ ### .angle
276
+
277
+ _readonly_
278
+
279
+ ```js
280
+ angle : number
281
+ ```
282
+
283
+ The current position or angle for joint.
284
+
285
+ ### .ignoreLimits
286
+
287
+ ```js
288
+ ignoreLimits : boolean
289
+ ```
290
+
291
+ Whether or not to ignore the joint limits when setting a the joint position.
292
+
293
+ ### .mimicJoints
294
+
295
+ ```js
296
+ mimicJoints : URDFMimicJoints[]
297
+ ```
298
+
299
+ A list of joints which mimic this joint. These joints are updated whenever this joint is.
300
+
301
+ ### .setJointValue
302
+
303
+ ```js
304
+ setJointValue( jointValue : number ) : Boolean
305
+ ```
306
+
307
+ Sets the joint value for the given joint. The interpretation of the value depends on the joint type. If the joint value specifies an angle it must be in radians.
308
+
309
+ Returns true if the joint or any of its mimicking joints changed.
310
+
311
+ ## URDFMimicJoint
312
+
313
+ _extends URDFJoint_
314
+
315
+ An object representing a robot joint which mimics another existing joint. The value of this joint can be computed as `value = multiplier * other_joint_value + offset`.
316
+
317
+ ### .mimicJoint
318
+
319
+ ```js
320
+ mimicJoint : String
321
+ ```
322
+
323
+ The name of the joint which this joint mimics.
324
+
325
+ ### .offset
326
+
327
+ ```js
328
+ offset : Number
329
+ ```
330
+
331
+ Specifies the offset to add in the formula above. Defaults to 0 (radians for revolute joints, meters for prismatic joints).
332
+
333
+ ### .multiplier
334
+
335
+ ```js
336
+ multiplier : Number
337
+ ```
338
+
339
+ Specifies the multiplicative factor in the formula above. Defaults to 1.0.
340
+
341
+ ## URDFLink
342
+
343
+ _extends Object3D_
344
+
345
+ ### .name
346
+
347
+ ```js
348
+ name : string
349
+ ```
350
+
351
+ The name of the link.
352
+
353
+ ## URDFRobot
354
+
355
+ _extends [URDFLink](#URDFLink)_
356
+
357
+ Object that describes the URDF Robot.
358
+
359
+ ### .robotName
360
+
361
+ ```js
362
+ robotName : string
363
+ ```
364
+
365
+ The name of the robot described in the `<robot>` tag.
366
+
367
+ ### .links
368
+
369
+ ```js
370
+ links : { [key] : URDFLink }
371
+ ```
372
+
373
+ A dictionary of `linkName : URDFLink` with all links in the robot.
374
+
375
+ ### .joints
376
+
377
+ ```js
378
+ joints : { [key] : URDFJoint }
379
+ ```
380
+
381
+ A dictionary of `jointName : URDFJoint` with all joints in the robot.
382
+
383
+ ### .colliders
384
+
385
+ ```js
386
+ colliders : { [key] : Object3D }
387
+ ```
388
+
389
+ A dictionary of `colliderName : Object3D` with all collision nodes in the robot.
390
+
391
+ ### .visual
392
+
393
+ ```js
394
+ visual : { [key] : Object3D }
395
+ ```
396
+
397
+ A dictionary of `visualName : Object3D` with all visual nodes in the robot.
398
+
399
+ ### .frames
400
+
401
+ ```js
402
+ joints : { [key] : URDFJoint }
403
+ ```
404
+
405
+ A dictionary of all the named frames in the robot including links, joints, colliders, and visual.
406
+
407
+ ### .setJointValue
408
+
409
+ ```js
410
+ setJointValue( name : String, value : Number ) : Boolean
411
+ ```
412
+
413
+ Sets the joint value of the joint with the given name. Returns true if the joint changed.
414
+
415
+ ### .setJointValues
416
+
417
+ ```js
418
+ setJointValues( jointValueDictionary : Object ) : Boolean
419
+ ```
420
+
421
+ Sets the joint values for all the joints in the dictionary indexed by joint name. Returns true if a joint changed.
422
+
423
+ ## urdf-viewer Element
424
+ ```html
425
+ <!-- Register the Element -->
426
+ <script href=".../urdf-viewer-element.js"></script>
427
+ <script>customElements.define('urdf-viewer', URDFViewer)</script>
428
+
429
+ <body>
430
+ <urdf-viewer package=".../package/dir/" urdf="T12/urdf/T12.URDF" up="Z+" display-shadow ambient-color="red"></urdf-viewer>
431
+ </body>
432
+ ```
433
+
434
+ ### Attributes
435
+
436
+ #### package
437
+
438
+ Corresponds to the `package` parameter in `URDFLoader.load`. Supported are:
439
+
440
+ 1. Single package:
441
+
442
+ ```html
443
+ <!-- 1. Example for single package named `default_package` -->
444
+ <urdf-viewer package=".../path/to/default_package" ...></urdf-viewer>
445
+ ```
446
+
447
+ Fallback within 1: If the target package within the `package://` relative files do not match the default path it is assumed that the default path is the parent folder that contains the target package(s).
448
+
449
+ ```html
450
+ <!-- 1. Example for single package named `default_package` with fallback: -->
451
+ <urdf-viewer package=".../path/to/parent" ...></urdf-viewer>
452
+ <!-- since `parent` does not match `default_package`
453
+ the path ".../path/to/parent/default_package" is assumed -->
454
+ ```
455
+
456
+ 2. Serialized package map:
457
+
458
+ E.g. if the meshes of a URDF are distributed over mutliple packages.
459
+
460
+ ```html
461
+ <!-- 2. Example for serialized package map that contains `package1` and `package2` -->
462
+ <urdf-viewer package="package1:.../path/to/package1, package2:.../path/to/package1" ...></urdf-viewer>
463
+ ```
464
+
465
+ #### urdf
466
+
467
+ Corresponds to the `urdfpath` parameter in `URDFLoader.load`.
468
+
469
+ The element uses fetch options `{ mode: 'cors', credentials: 'same-origin' }` to load the urdf file.
470
+
471
+ #### ignore-limits
472
+
473
+ Whether or not hte display should ignore the joint limits specified in the model when updating angles.
474
+
475
+ #### up
476
+
477
+ The axis to associate with "up" in THREE.js. Values can be [+-][XYZ].
478
+
479
+ #### display-shadow
480
+
481
+ Whether or not the render the shadow under the robot.
482
+
483
+ #### ambient-color
484
+
485
+ The color of the ambient light specified with css colors.
486
+
487
+ #### auto-redraw
488
+
489
+ Automatically redraw the model every frame instead of waiting to be dirtied.
490
+
491
+ #### no-auto-recenter
492
+
493
+ Recenter the camera only after loading the model.
494
+
495
+ ### Properties
496
+
497
+ All of the above attributes have corresponding camel case properties.
498
+
499
+ #### .jointValues
500
+
501
+ ```js
502
+ jointValues : Object
503
+ ```
504
+
505
+ Sets or gets the jointValues of the robot as a dictionary of `joint-name` to `radian` pairs.
506
+
507
+ ### Functions
508
+
509
+ #### .setJointValue
510
+
511
+ ```js
512
+ setJointValue( jointName : String, jointValue : Number ) : void
513
+ ```
514
+
515
+ Sets the given joint to the provided angle in radians.
516
+
517
+ #### .setJointValues
518
+
519
+ ```js
520
+ setJointValues( jointValueDictionary : Object ) : void
521
+ ```
522
+
523
+ Sets all joint names specified as keys to radian angle value.
524
+
525
+ #### .redraw
526
+
527
+ ```js
528
+ redraw() : void
529
+ ```
530
+
531
+ Dirty the renderer so the element will redraw next frame.
532
+
533
+ #### .recenter
534
+
535
+ ```js
536
+ recenter() : void
537
+ ```
538
+
539
+ Recenter the camera to the model and redraw.
540
+
541
+ ### Events
542
+
543
+ #### 'urdf-change'
544
+
545
+ Fires when the URDF has changed and a new one is starting to load.
546
+
547
+ #### 'ignore-limits-change'
548
+
549
+ Fires when the `ignore-limits` attribute changes.
550
+
551
+ #### 'urdf-processed'
552
+
553
+ Fires when the URDF has finished loading and getting processed.
554
+
555
+ #### 'geometry-loaded'
556
+
557
+ Fires when all the geometry has been fully loaded.
558
+
559
+ # Running the Example
560
+
561
+ Install Node.js and NPM.
562
+
563
+ Run `npm install`.
564
+
565
+ Run `npm start`.
566
+
567
+ Visit `localhost:9080/javascript/example/dev-bundle/` to view the page.
568
+
569
+ # LICENSE
570
+
571
+ The software is available under the [Apache V2.0 license](../LICENSE).
572
+
573
+ Copyright © 2020 California Institute of Technology. ALL RIGHTS
574
+ RESERVED. United States Government Sponsorship Acknowledged.
575
+ Neither the name of Caltech nor its operating division, the
576
+ Jet Propulsion Laboratory, nor the names of its contributors may be
577
+ used to endorse or promote products derived from this software
578
+ without specific prior written permission.