Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate URDF XML Parsing #172

Open
gkjohnson opened this issue Jun 25, 2020 · 2 comments
Open

Separate URDF XML Parsing #172

gkjohnson opened this issue Jun 25, 2020 · 2 comments
Labels
help wanted Extra attention is needed three.js

Comments

@gkjohnson
Copy link
Owner

gkjohnson commented Jun 25, 2020

Separate the URDF XML parsing to provide a clean, fully defaulted json representation of the URDF data so it can be used to implement loaders in other engines including Babylon.js. The structure from the 3DTilesRenderer could be reused -- ie a base and three folder to denote reusable and platform/engine-specific code.

Related to #168.

@gkjohnson gkjohnson added the help wanted Extra attention is needed label Apr 16, 2021
@jhurliman
Copy link

I'm interested in helping with this since I'd like to use the URDF loader with Worldview (https://webviz.io/worldview/) instead of three.js. I noticed that three.js math types such as Vector3 and Quaternion are used during loading, what would you recommend in place of those for removing the three.js dependency from the core loader?

@gkjohnson
Copy link
Owner Author

gkjohnson commented Jul 11, 2021

Hello @jhurliman! If the parser is going to be restructured to separate some of the parser logic I think I'd like to see a URDFLoaderBase class that just implements the XML parsing and returns a simpler JS object with defaults filled in and file paths resolved so rendering-engine-specific implementations can be simplified. The returned object could be structured like so:

{
  namedMaterials: [ /* material data ... */ ],
  links: [ /* link data ... */ ],
  joints: [ /* joint data ... */ ],
  // ... etc
}

And the current URDFLoader can be split into two files:

// src/base/URDFLoaderBase.js
class URDFLoaderBase {
  load( url ) {
    /* ... */
  }

  // returns parsed URDF XML as javascript object
  parse( xmlOrString ) {
    /* ... */
  }  
}

// src/three/URDFLoader.js
class URDFLoader extends URDFLoaderBase {
  parse( ...args ) {
    const urdfData = super.parse( ...args );
    /* ... generate three.js URDFRobot, etc */
  }
}

See the 3DTilesRendererJS B3DMLoaderBase and three.js-specific B3DMLoader for a rough model of how I'm imagining this being structured. To that end I don't think any math functions will be required in the base parser and will just be required for engine-specific implementations which is probably for the best so we can keep the dependency list low.

With that approach I don't believe the result of the current URDFLoader should have to change and it should make it easier to produce other engine-specific urdf model loader implementations.

Let me know how that sounds to you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed three.js
Projects
None yet
Development

No branches or pull requests

2 participants