ros-visualization / rviz

ROS 3D Robot Visualizer
BSD 3-Clause "New" or "Revised" License
831 stars 463 forks source link

avoid Ogre::ItemIItemIdentityException in Ogre 1.12 when the same material is used multiple times #1746

Closed lucasw closed 2 years ago

lucasw commented 2 years ago

Description

The issue can be shown by building rviz with Ogre 1.12 and launching https://github.com/lucasw/gazebo_ros_demos/blob/noetic-devel/rrbot_description/launch/rrbot_rviz.launch then add a second RobotModel to rviz (probably two instance of any RobotModel that uses the _original postfix code path will fail in the same way):

terminate called after throwing an instance of 'Ogre::ItemIdentityException'
  what():  ItemIdentityException: Material with the name package://rrbot_description/meshes/hokuyo.daeMaterial0_original already exists. in ResourceManager::add at ./OgreMain/src/OgreResourceManager.cpp (line 148)
[rviz-3] process has died [pid 9096, exit code -6, cmd /home/lucasw/base_catkin_ws/devel/lib/rviz/rviz -d /home/lucasw/base_catkin_ws/src/ros/gazebo_ros_demos/rrbot_description/launch/rrbot.rviz __name:=rviz __log:=/home/lucasw/.ros/log/affefeb0-d77c-11ec-9be6-b72d65a8c914/rviz-3.log].
log file: /home/lucasw/.ros/log/affefeb0-d77c-11ec-9be6-b72d65a8c914/rviz-3*.log

The solution is similar to material_count used in https://github.com/ros2/rviz/blob/ros2/rviz_default_plugins/src/rviz_default_plugins/robot/robot_link.cpp#L708-L751

Checklist

rhaschke commented 2 years ago

Thanks for pointing out this issue. I think I found a better way to avoid duplicate material names: #1750.