-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assign correct MaterialPtr to all visuals #114
Conversation
So far, only the first visual in visual_array got the correct MaterialPtr assigned.
urdf_parser/src/model.cpp
Outdated
else | ||
{ | ||
CONSOLE_BRIDGE_logError("link '%s' material '%s' undefined.", link_name,visual->material_name.c_str()); | ||
model.reset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is failing because you can't call reset
on a const reference. This looks like it should probably be a non-const reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry. Obviously I filed this PR in a rush. There was also a missing return value. Both issues should be fixed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one more open issue: The new parser is more picky about undefined materials than the old parser (which is good). However, I suggest to issue a warning only instead of an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that sounds good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up pushing 8175b16, which does some simple style cleanups. However, what I want to talk about here is the fact that the new code actually seems less picky about undefined materials. That is, it used to be that if the material was undefined, then the parser would return a nullptr from parseURDF
. The new code, while it downgrades the print from an error to a warning, lets the code go on. In other words, the boolean return value from assignMaterial
seems to be ignored. @rhaschke is this the intended behavior, and if so, could you say a bit about why this is safe/better to do here? Thanks.
69b7c56
to
b53fef5
Compare
be9e954
to
93a2bf4
Compare
+1 Could you merge and release this? |
Signed-off-by: Chris Lalancette <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @clalancette, I should have explained the situation in more detail. The old parsing was less picky in the sense that it didn't recognized references to undefined materials (see inline github comments for details).
As an example consider this example urdf, which defines materials Black
and Orange
, but also uses Grey
. The old parser doesn't complain about the missing Grey
definition - which can be easily validated with check_urdf
.
The new parser, however, complains about the issue. Because this more picky behaviour might break many existing urdf files (for example the Shadow Robot hand), I turned the error into a warning and don't bail out.
@@ -381,7 +381,7 @@ bool parseVisual(Visual &vis, TiXmlElement *config) | |||
vis.material.reset(new Material()); | |||
if (!parseMaterial(*vis.material, mat, true)) | |||
{ | |||
CONSOLE_BRIDGE_logDebug("urdfdom: material has only name, actual material definition may be in the model"); | |||
vis.material.reset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before the visual's material pointer was always well defined.
} | ||
else | ||
{ | ||
CONSOLE_BRIDGE_logError("link '%s' material '%s' undefined.", link->name.c_str(),link->visual->material_name.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the visual's material was always well-defined, this error was never printed.
This makes sense to me. Thanks for the detailed explanation. |
Ping @scpeters, @clalancette. Can we merge this bug fix and get that a new release anytime soon? |
Huh. That was a quick response! Thanks. What is your release schedule for this non-ROS lib? Is there a chance to see a new release in Bionic already? |
I made a 1.0.3 release yesterday which should be able to get into the new debian without trouble, but it's hard to get releases into bionic that aren't security fixes. cc @j-rivero |
What do you mean by this exactly? A .deb package or the Debian distribution? |
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.
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.
So far, only the first visual in visual_array got the correct MaterialPtr (from the model) assigned.
All other visual had a default-constructed Material with black color.
This required a work around in rviz, to figure out the correct material colors (#1079 or ros-visualization/rviz@ed3b0b3)