personalrobotics / or_rviz

OpenRAVE viewer plugin that publishes the environment to RViz as InteractiveMarkers.
BSD 2-Clause "Simplified" License
5 stars 5 forks source link

Loading empty meshes as render geometry causes a hard crash. #25

Open psigen opened 9 years ago

psigen commented 9 years ago

The attached empty.iv file, when loaded in or_rviz, crashes OGRE when used as a render mesh. It works fine in OpenRAVE's qtcoin viewer.

https://gist.github.com/psigen/19d7fe6d9c8d5c824a3d

[LinkMarker.cpp:323 CreateVisualGeometry] Loaded one or more meshes OpenRAVE because this format is not supported by RViz. This may be slow for large files.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffbaed5700 (LWP 5789)]
0x00007fffd380a650 in Ogre::Material::getTechnique(unsigned short) ()
   from /usr/lib/x86_64-linux-gnu/libOgreMain.so.1.8.1
(gdb) bt
#0  0x00007fffd380a650 in Ogre::Material::getTechnique(unsigned short) ()
   from /usr/lib/x86_64-linux-gnu/libOgreMain.so.1.8.1
#1  0x00007fffd3f9f3dc in rviz::InteractiveMarkerControl::addHighlightPass(std::set<Ogre::MaterialPtr, std::less<Ogre::MaterialPtr>, std::allocator<Ogre::MaterialPtr> >) () from /opt/ros/indigo/lib/libdefault_plugin.so
#2  0x00007fffd3f9fc46 in rviz::InteractiveMarkerControl::makeMarkers(visualization_msgs::InteractiveMarkerControl_<std::allocator<void> > const&) ()
   from /opt/ros/indigo/lib/libdefault_plugin.so
#3  0x00007fffd3fa07f2 in rviz::InteractiveMarkerControl::processMessage(visualization_msgs::InteractiveMarkerControl_<std::allocator<void> > const&) ()
   from /opt/ros/indigo/lib/libdefault_plugin.so
#4  0x00007fffd3fa5ba3 in rviz::InteractiveMarker::processMessage(visualization_msgs::InteractiveMarker_<std::allocator<void> > const&) ()
   from /opt/ros/indigo/lib/libdefault_plugin.so
psigen commented 9 years ago

This issue also occurs with empty STL files, such as the following:

https://www.dropbox.com/s/whja8woux0xk4i8/empty.stl?dl=0

what():  OGRE EXCEPTION(2:InvalidParametersException): No data defined to convert to a mesh. in ManualObject::convertToMesh at /build/buildd/ogre-1.8-1.8.1+dfsg/OgreMain/src/OgreManualObject.cpp (line 782)
mkoval commented 9 years ago

I can easily fix this for .iv files. These are not natively supported by RViz, so we load the mesh using OpenRAVE and convert it to a TRIANGLE_LIST type. I can simply skip the conversion if indices is empty. I will add this check.

Unfortunately, this isn't as easy for .stl files. We pass these directly to RViz using the MESH_RESOURCE type without ever loading them in OpenRAVE. We would have to load the model from disk in OpenRAVE just to do this check.

I'm not sure if it's worth it to add the .stl check for a few reasons:

  1. This is a bug in RViz, not or_rviz
  2. We have no way of checking for empty .dae files, which will also most likely crash RViz
  3. OpenRAVE now supports the none geometry type (https://github.com/rdiankov/openrave/pull/306)
psigen commented 9 years ago

The none geometry type is pretty useless for the case of having collision-only trimesh geometry. It seems to only be useful for links that have no geometry at all.

I agree that fixing this for STLs might be something we have to send upstream.

mkoval commented 9 years ago

You're right. none solves the opposite problem (render geometry, but no collision geometry).

My understanding was that qtcoin and or_rviz only rendered visual meshes and did not fall back on rendering primitive objects (e.g. https://github.com/personalrobotics/or_urdf/issues/5). That doesn't seem to the case, so I need to look into that bug. Maybe we can use the same trick to avoid using empty mesh files. :smile:

mklingen commented 9 years ago

when the user adds a "RobotModel" display, what happens in RVIZ when the URDF includes an empty .stl file as visual geometry?

psigen commented 8 years ago

@mklingen: I'm not sure, it either loads nothing or falls back on a collision mesh. I guess it makes sense to try and keep the same logic here.