Skip to content

Add color setting for the Viper Rover #580

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JasperGrant
Copy link
Contributor

I noticed that while individual viper parts had colors assigned they were never applied to the rover.

If it is intended for these colors to not be applied I can definitely delete this PR.

Thank you!

@rserban
Copy link
Member

rserban commented Jun 8, 2025

Thanks for looking into this.

It looks like this model was not implemented in the best way:

  • using a ChVisualShapeTriangleMesh here is overkill (and "repairing" a mesh meant for visualization only even more so)
  • using this type of visual shape is also limiting (e.g., if one also has an associated Wavefront .mat file)
  • for visualization using meshes, a much better option is using ChVisualShapeModelFile as that will automatically use a materials file if one exists (which is the proper way of providing textures and colors for such visual assets)

So, if you're interested in making some fixes, here's what I suggest:

  • include ChVisualShapeModelFile.h instead of ChVisualShapeTriangleMesh.h
  • replace the code in the if(m_visualize) block with something like:
        auto vis_mesh_file = GetChronoDataFile("robot/viper/obj/" + m_mesh_name + ".obj");
        auto shape = chrono_types::make_shared<ChVisualShapeModelFile>(vis_mesh_file);
        shape->SetMutable(false);
        m_body->AddVisualShape(shape, m_mesh_xform);
  • get rid of the ViperPart::m_color member variable altogether

By the way, the same issue is present in the Curiosity rover model, so maybe modify both?
Let me know if you intend on submitting a new PR with the fixes above. Otherwise, I will push them myself.

@JasperGrant
Copy link
Contributor Author

Hello Dr. Serban,

Happy to put some work in on this! I have added the changes you recommended to the Viper.cpp and Curiosity.cpp files to this PR and have gotten some weird visual effects. (see below)

image

image

I did notice there is not material file in the data/robot/viper or curiosity folders. Could this be why we are seeing odd gaps in the wheels and white/black colors?

Thank you,
Jasper Grant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants