npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

urdf-exporter

v0.4.0

Published

THREE.js utility for exporting object trees as a URDF file.

Downloads

7

Readme

urdf-exporter-js

npm version build github twitter sponsors

Utility for exporting a three.js object hierarchy as a URDF.

Use

Exporting a model constructed from URDF classes like URDFLink and URDFJoint.

import { URDFExporter } from 'urdf-exporter';
import { STLExporter } from 'three/examples/jsm/exporters/STLExporter.js';

let urdfModel;
// ... create a model using the URDF classes for export

const models = {};
const exporter = new URDFExporter();
exporter.processGeometryCallback = ( model, link ) => {

	const name = `${ link.name }_mesh.stl`;
	models[ name ] = new STLExporter().parse( model );
	return name;

};

urdfModel.updateMatrixWorld();
const urdf = exporter.parse( urdfModel );

// ... urdf content ready!

Converting an existing model to one made with the appropriate classes.

import { URDFConverter, URDFRobot, URDFLink, URDFJoint, URDFVisual } from 'urdf-exporter';

let model;

// ... create or load a model

const convert = new URDFConverter();
converter.generateCallback = child => {

  let result;
  if ( child.linkData ) {
  
    if ( child === model ) {
    
      result = new URDFRobot();
      result.robotName = 'my-robot-urdf';
    
    } else {
    
      result = new URDFLink();
    
    }
    
    result.name = child.linkData.name;
  
  } else if ( child.jointData ) {
  
    result = new URDFJoint();
    result.name = child.jointData.name;
    result.jointType = 'revolute';
    result.limit.lower = - Math.PI / 2;
    result.limit.upper = Math.PI / 2;
  
  } else if ( child.isMesh ) {
  
    result = new URDFVisual()
    result.add( child.clone() );
  
  } else {
  
      result = new Group();
  
  }
  
  result.position.copy( child.position );
  result.quaternion.copy( child.quaternion );
  result.scale.copy( child.scale );

};

const urdfModel = converter.generate( model );

// ... urdf class hierarchy!

API

URDFConverter

Utility class to enable convenient conversion from three.js objects to URDF classes for export.

.generateCallback

generateCallback : ( object : Object3D ) => Object3D

Callback used for generating URDF class equivalents. The function is expected to return a cloned version of the provided mesh or a URDF class describing the analogous object. The returned object must be the child object that will have children added to it. The generator will then find the root parent to add to the previously processed object.

For example a custom three.js joint type could converted into a joint and link connection which can be run through the URDFExporter.

.postprocessCallback

postprocessCallback : ( object : URDFRobot ) => void

A function that takes the generated URDF result to enable fixups and other types of postprocessing that might be needed.

.generate

generate( object : Object3D ) : URDFRobot

Traverses the given hierarchy and generates a converted URDF hierarchy.

URDFExporter

.indent

indent = '\t' : string

The set of indentation characters to use.

.processGeometryCallback

processGeometryCallback : ( node : Object3D, link : URDFLink ) => string

The callback for to use when processing geometry. Geometry must be processed and cached in order to be exported. A file path is returned from the function.

.parse

parse( root : URDFRobot ) : string

Parses the object into a urdf file. Returns the URDF contents as a string. The hierarchy matrix world must be updated before calling this function.

URDFLimit

Class containing values to export for joint limits.

.upper

upper = 0 : Number

.lower

lower = 0 : Number

.velocity

velocity = 0 : Number

.effort

effort = 0 : Number

URDFInertialFrame

Class containing values for the link inertial frame.

.position

position : Vector3

.rotation

rotation : Euler

.mass

mass = 0 : Number

inertia

inertial : Matrix3

The upper triangular matrix is used to define the xx, yy, zz, xy, yz, and xz fields.

URDFLink

extends THREE.Object3D

When this field is encountered a new link is created in the URDF file.

.inertial

inertial : URDFInertialFrame

URDFJoint

extends THREE.Object3D

When this field is encountered a new joint is created in the URDF file.

.jointType

jointType = 'fixed' : string

.axis

axis : Vector3

.limit

limit : URDFLimit

URDFRobot

extends URDFLink

A class describing the root of the URDF Robot.

.robotName

robotName = '' : string

URDFVisual

extends THREE.Object3D

URDFCollider

extends THREE.Object3D