ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Library for parsing stl files into rviz triangle list

asked 2018-12-13 01:27:42 -0500

GS gravatar image

updated 2018-12-19 06:00:50 -0500

Hello,

I am currently looking into loading an stl-file into rviz and be able to color some parts of the mesh differently than others (dynamically, depending on other input). To my understanding the way to do this would be to somehow parse the stl file and convert it to a triangle list. The triangles can then be colored independently depending on whatever the other input is.

So my question would be if there is already some kind of library out there that does exactly this, or will I have to implement it myself? (I saw some other threads talking about this kind of topic, but they always only linked to http://www.ros.org/wiki/rviz/DisplayT... or something similar.)

In case it is relevant: I am on ros kinetic (and optionally melodic).

If you have any other type of solution to this kind of problem I'm happy to hear it.

Thanks in advance,

Giuseppe

----------------------------------

EDIT : Thanks to @aPonza's answer i could use the geometric_shapes package to achieve my goal of loading a mesh file and convert it to a rviz triangle list. To do this i used createMeshFromResource and then read the Data out of the Mesh object that it generated.

Reading out of the Mesh Object was a little different than i expect since it uses vertex- and index-buffers but thanks to @gvdhoorn's comment with the link to the slides i was able to grasp that concept better.

edit retag flag offensive close merge delete

Comments

I think the assimp library that is already used within rviz for mesh loading can load STL files into some kind of mesh, but I'm not sure how easy it is to modify that mesh after it has been loaded.

ahendrix gravatar image ahendrix  ( 2018-12-13 02:16:53 -0500 )edit
1

Not an answer, but you may be interested in "Introducing Tools for Storing, Rendering and Annotating Triangle Meshes in ROS and RViz" (video, slides).

gvdhoorn gravatar image gvdhoorn  ( 2018-12-13 06:44:40 -0500 )edit

Also: rviz_visual_tools supports directly publising Mesh resources. I don't believe you can colour them though (in the way you describe/desire).

gvdhoorn gravatar image gvdhoorn  ( 2018-12-13 06:45:40 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-12-13 03:48:43 -0500

aPonza gravatar image

As far as I know, like @ahendrix is saying, you can use assimp via createMeshFromResource. This already gives you the triangles you're looking for, but you could also afterwards convert it to a shapes::ShapeMsg via constructMsgFromShape or its variant shape_msgs::Mesh with a further call to boost::get, more or less like it's explained in here.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-12-13 01:27:42 -0500

Seen: 278 times

Last updated: Dec 19 '18