chrono icon indicating copy to clipboard operation
chrono copied to clipboard

Add color setting for the Viper Rover

Open JasperGrant opened this issue 7 months ago • 2 comments

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!

JasperGrant avatar Jun 06 '25 19:06 JasperGrant

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.

rserban avatar Jun 08 '25 08:06 rserban

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

JasperGrant avatar Jun 09 '25 15:06 JasperGrant