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

urdf load with materials #965

Closed
junhyeokahn opened this issue Jan 31, 2018 · 7 comments
Closed

urdf load with materials #965

junhyeokahn opened this issue Jan 31, 2018 · 7 comments

Comments

@junhyeokahn
Copy link

Hello,
I am trying to import valkyrie model from urdf with materials.
I follow the tutorial and have a setcolormode for each body node if it has one.

void setMeshColor(dart::dynamics::SkeletonPtr robot) {
    for(std::size_t i=0; i<robot->getNumBodyNodes(); ++i) {
        dart::dynamics::BodyNode* bn = robot->getBodyNode(i);
        auto shapeNodes = bn->getShapeNodesWith<dart::dynamics::VisualAspect>();
        for(auto shapeNode : shapeNodes) {
            std::shared_ptr<dart::dynamics::MeshShape> mesh =
                std::dynamic_pointer_cast<dart::dynamics::MeshShape>(
                        shapeNode->getShape());
            if(mesh)
                mesh->setColorMode(dart::dynamics::MeshShape::SHAPE_COLOR);
        }
    }
}

However, I could only see the gray or blue robot depends on color mode.
It seems like it doesn't find the material even though correct path is written in 'dae' file.

To make it easy I made a repository with urdf and models.

  1. git clone https://github.com/junhyeokahn/dartDebug.git
  2. At the repository, mkdir build && cd build
  3. cmake ..
  4. build -j
  5. ./valkyrie

Plus, is there any way to zoom in and out in osg? The instruction says scroll the wheel but it does not work.

I apologize for the messy description and always thanks for your effort.

@mxgrey
Copy link
Member

mxgrey commented Feb 1, 2018

Note that the example expects DART version 7.0, which is currently only available by compiling the master branch from source (as far as I know).

Setting the mesh color mode to SHAPE_COLOR will use whatever color you pass to the ShapeNode that holds the shape, using ShapeNode::getVisualAspect()->setColor(~), so that mode will definitely hide the material color. You'll definitely want to use MATERIAL_COLOR.

When I run your code using MATERIAL_COLOR, it comes up as a shiny gray color (although the apparent shininess might just be caused by the geometry's curvature). I take it this is the "gray" you were referring to, which means this is not the expected material color.

There are three places where the material color might be getting lost:

  1. Assimp is parsing the .dae incorrectly

  2. dart-gui-osg is reading the material from assimp incorrectly

  3. dart-gui-osg is sending the material to osg incorrectly.

It's difficult to guess which of those it might be. The best course of action would probably be whittling down the possible causes.

If there is another application somewhere that can load and display a .dae with assimp, then you could load the model in that application and see if the materials are correct.

We could try loading the model in the older OpenGL dart-gui library and see if it handles the material properties correctly.

If both of those work, then we'll have narrowed it down to an issue in dart-gui-osg, which would be very informative.

Plus, is there any way to zoom in and out in osg? The instruction says scroll the wheel but it does not work.

Could you let us know what platform you're running on? Using Ubuntu 16.04, I had no problem using the scroll wheel to zoom in and out in the OSG window that your example produces.

@junhyeokahn
Copy link
Author

junhyeokahn commented Feb 1, 2018

Thanks for the reply. For zoom, I am currently using Mac OS Sierra.
I just realized attached dae file is loaded correctly. The difference is that the previous valkyrie dae file is pointing png file but attached dae file includes color information inside it.
leg.dae.zip
Does dart support to read png file?

@jslee02
Copy link
Member

jslee02 commented Feb 1, 2018

Does dart support to read png file?

Currently, none of OpenGL and OSG renderers of DART load texture images (only texture coordinates are parsed by the OSG renderer). I think we need to have something like this to load texture images. I confirmed this works.

image

Please note that there are several holes on the pelvis mesh, which are loaded from pelvistexture.png.

Let me submit a PR for this within a couple of days.

@junhyeokahn
Copy link
Author

I appreciate it :)

@jslee02
Copy link
Member

jslee02 commented Feb 5, 2018

I've made some progress on this. Here is an Valkyrie example with texture images:
image

A PR will be created for this soon.

Edit: #973

@junhyeokahn
Copy link
Author

Wow, it's awesome :). Thank you so much.

@jslee02
Copy link
Member

jslee02 commented Feb 13, 2018

I believe this is addressed by #973.

@jslee02 jslee02 closed this as completed Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants