URDF Loader for THREE.js and webcomponent viewer
Fork of gkjohnson/urdf-loaders with only the JS component.
1. npm install
2. npm run start -s
3. visit localhost:9080/example
js
import { LoadingManager } from 'three';
import URDFLoader from 'urdf-loader';const manager = new LoadingManager();
const loader = new URDFLoader(manager);
loader.load(
'T12/urdf/T12.URDF', // The path to the URDF within the package OR absolute
robot => { }, // The robot is loaded!
{
packages: {
packageName : '.../package/dir/' // The equivalent of a (list of) ROS package(s):// directory
},
loadMeshCb: (path, manager, done) => { }, // Callback for each mesh for custom mesh processing and loading code
}
);
`Limitations
- Only prismatic, continuous, revolute, and fixed joints are supported.API
URDFOptions
$3
`js
packages = '' : String | Object
`The path representing the
package:// directory(s) to load package:// relative files.If the argument is a string, then it is used to replace the
package:// prefix when loading geometry.To specify multiple packages an object syntax is used defining the package name to the package path:
`js
{
"package1": ".../path/to/package1",
"package2": ".../path/to/package2",
...
}
`$3
`js
loadMeshCb = null :
(
pathToModel : string,
manager : LoadingManager,
onComplete : ( obj : Object3D ) => void
) => void
`An optional function that can be used to override the default mesh loading functionality. The default loader is specified at
URDFLoader.defaultMeshLoader.pathToModel is the url to load the model from.manager is the THREE.js LoadingManager used by the URDFLoader.onComplete is called with the mesh once the geometry has been loaded.$3
`js
fetchOptions : Object
`An optional object with the set of options to pass to the
fetch function call used to load the URDF file.$3
`js
workingPath : string
`The path to load geometry relative to.
Defaults to the path relative to the loaded URDF file.
$3
`js
parseVisual : boolean
`An optional value that can be used to enable / disable loading meshes for links from the
visual nodes. Defaults to true.$3
`js
parseCollision : boolean
`An optional value that can be used to enable / disable loading meshes for links from the
collision nodes. Defaults to false.URDFLoader
$3
`js
constructor( manager : LoadingManager )
`Constructor. Manager is used for transforming load URLs and tracking downloads.
$3
`js
load(
urdfpath : string,
onComplete : (robot: URDFRobot) => void,
options = null : URDFOptions
) : void
`Loads and builds the specified URDF robot in THREE.js.
Takes a path to load the urdf file from, a func to call when the robot has loaded, and a set of options.
$3
`js
parse( urdfContent : string, options = null : URDFOptions) : URDFRobot
`Parses URDF content and returns the robot model. Takes an XML string to parse and a set of options.
Note that geometry will not necessarily be loaded when the robot is returned.
URDFJoint
_extends Object3D_
An object representing a robot joint.
$3
`js
name : string
`The name of the joint.
$3
`js
.jointType : string
`The type of joint. Can only be the URDF types of joints.
$3
`js
.limit : { lower : number, upper : number }
`An object containing the
lower and upper constraints for the joint.$3
`js
axis : Vector3
`The axis described for the joint.
$3
_readonly_
`js
angle : number
`The current position or angle for joint.
$3
`js
ignoreLimits : boolean
`Whether or not to ignore the joint limits when setting a the joint position.
$3
`js
setAngle( angle : number ) : void
setOffset( position : number ) : void
`Takes the position off of the starting position to rotate or move the joint to.
URDFLink
_extends Object3D_
$3
`js
name : string
`The name of the link.
URDFRobot
_extends URDFLink_
Object that describes the URDF Robot.
$3
`js
robotName : string
`The name of the robot described in the
tag.$3
`js
links : { [key] : URDFLink }
`A dictionary of
linkName : URDFLink with all links in the robot.$3
`js
joints : { [key] : URDFJoint }
`A dictionary of
jointName : URDFJoint with all joints in the robot.urdf-viewer Element
`html
`$3
#### package
Corresponds to the
package parameter in URDFLoader.load. Supported are:1. Single package:
`html
` 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).
`html
`2. Serialized package map:
E.g. if the meshes of a URDF are distributed over mutliple packages.
`html
`#### urdf
Corresponds to the
urdfpath parameter in URDFLoader.load.The element uses fetch options
{ mode: 'cors', credentials: 'same-origin' } to load the urdf file.#### ignore-limits
Whether or not hte display should ignore the joint limits specified in the model when updating angles.
#### up
The axis to associate with "up" in THREE.js. Values can be [+-][XYZ].
#### display-shadow
Whether or not the render the shadow under the robot.
#### ambient-color
The color of the ambient light specified with css colors.
#### auto-redraw
Automatically redraw the model every frame instead of waiting to be dirtied.
#### no-auto-recenter
Recenter the camera only after loading the model.
$3
All of the above attributes have corresponding camel case properties.
#### .angles
`js
angles : Object
`Sets or gets the angles of the robot as a dictionary of
joint-name to radian pairs.$3
#### setAngle
`js
setAngle( jointName : string, angle : Number ) : void
`Sets the given joint to the provided angle in radians.
#### .setAngles
`js
setAngles( jointDictionary : Object ) : void
`Sets all joint names specified as keys to radian angle value.
#### .redraw
`js
redraw() : void
`Dirty the renderer so the element will redraw next frame.
#### .recenter
`js
recenter() : void
`Recenter the camera to the model and redraw.
$3
#### 'urdf-change'
Fires when the URDF has changed and a new one is starting to load.
#### 'ignore-limits-change'
Fires when the
ignore-limits` attribute changes.#### 'urdf-processed'
Fires when the URDF has finished loading and getting processed.
#### 'geometry-loaded'
Fires when all the geometry has been fully loaded.
The software is available under the Apache V2.0 license.
Copyright © 2019 California Institute of Technology. ALL RIGHTS
RESERVED. United States Government Sponsorship Acknowledged. This software may
be subject to U.S. export control laws. By accepting this software,
the user agrees to comply with all applicable U.S. export laws and
regulations. User has the responsibility to obtain export licenses,
or other export authority as may be required before exporting such
information to foreign countries or providing access to foreign
persons. Neither the name of Caltech nor its operating division, the
Jet Propulsion Laboratory, nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.