Skip to content

Commit 83ac836

Browse files
committed
work-around for buggy urdf parser for visual materials
In urdf::Link, only the first visual's material comprises actual color values, all others only have the name. Thus to correctly show the color of all visuals, we need to search for the first visual with given material name, much like ros-visualization#1079 has done. If the urdfdom fix (ros/urdfdom#114) is released, this work-around can be reverted.
1 parent 28fb778 commit 83ac836

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/rviz/robot/robot_link.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,17 @@ Ogre::MaterialPtr RobotLink::getMaterialForLink( const urdf::LinkConstSharedPtr&
442442
{
443443
Ogre::MaterialPtr mat = Ogre::MaterialPtr(new Ogre::Material(nullptr, "robot link material", 0, ROS_PACKAGE_NAME));
444444

445+
// only the first visual's material actually comprises color values, all others only have the name
446+
// hence search for the first visual with given material name (better fix the bug in urdf parser)
447+
if (material && !material->name.empty()) {
448+
for(const auto& visual : link->visual_array)
449+
{
450+
if (visual->material_name == material->name) {
451+
material = visual->material;
452+
break;
453+
}
454+
}
455+
}
445456
if (!material && link->visual && link->visual->material)
446457
material = link->visual->material; // fallback to visual's material
447458

0 commit comments

Comments
 (0)