Skip to content
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

Merged
merged 4 commits into from
Jan 30, 2019

Conversation

rhaschke
Copy link
Contributor

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)

So far, only the first visual in visual_array got the correct MaterialPtr assigned.
else
{
CONSOLE_BRIDGE_logError("link '%s' material '%s' undefined.", link_name,visual->material_name.c_str());
model.reset();
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

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.

@eisoku9618
Copy link

+1

Could you merge and release this?

Signed-off-by: Chris Lalancette <[email protected]>
Copy link
Contributor Author

@rhaschke rhaschke left a 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();
Copy link
Contributor Author

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());
Copy link
Contributor Author

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.

@clalancette
Copy link
Contributor

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.

This makes sense to me. Thanks for the detailed explanation.

@rhaschke
Copy link
Contributor Author

Ping @scpeters, @clalancette. Can we merge this bug fix and get that a new release anytime soon?
I think this is also related to Chris' cleanup in #104. It's so sad that the latter PR is already dangling there for more than a year.

@scpeters scpeters merged commit 3ffc4ee into ros:master Jan 30, 2019
@rhaschke
Copy link
Contributor Author

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?

@scpeters
Copy link
Contributor

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

@rhaschke
Copy link
Contributor Author

should be able to get into the new debian

What do you mean by this exactly? A .deb package or the Debian distribution?
How would the newly released lib enter my ROS ecosystem? Is it released via the ROS release / distribution mechanism, i.e. bloom too?

@rhaschke rhaschke deleted the fix-material-assignment branch January 30, 2019 23:53
rhaschke added a commit to rhaschke/rviz that referenced this pull request Feb 10, 2019
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.
rhaschke added a commit to rhaschke/rviz that referenced this pull request Feb 17, 2019
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants