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

Bug about mesh loading in simulation #2028

Closed
sj-li opened this issue Oct 16, 2017 · 4 comments
Closed

Bug about mesh loading in simulation #2028

sj-li opened this issue Oct 16, 2017 · 4 comments

Comments

@sj-li
Copy link

sj-li commented Oct 16, 2017

Your Environment

  • Operating System and version: Ubuntu 16.04
  • Compiler: GCC 5.4
  • PCL Version: Latest

Expected Behavior

Input a mesh with color, hoping to display it with color.

Current Behavior

The displayed mesh is always in red color.

Possible Solution

In pcl/simulation/src/model.cpp.

change line 119
from
if (plg->cloud.fields[i].name.compare ("rgb") == 0)
to
if (plg->cloud.fields[i].name.compare ("rgb") == 1)

Context

I use simulation module to display a mesh with color.
But the mesh color is always in red.
I find that when loading mesh, the condition to judge the color existing may be wrong.
I change the condition and the result goes as expected

@taketwo
Copy link
Member

taketwo commented Oct 16, 2017

Good catch! But the fix is wrong and works by accident ;)

Observe that compare function is used to check if the name of the field matches "rgb". According to the documentation, this function returns 0 when strings are equal. So the existing code is correct.

I think the problem might be that your mesh contains colors in the "rgba" field. Can you try to test if this field exists?

@taketwo taketwo added the needs: author reply Specify why not closed/merged yet label Oct 16, 2017
@sj-li
Copy link
Author

sj-li commented Oct 20, 2017

Well, you are right, the filed is "rgba".

So how can I load the color?

@taketwo
Copy link
Member

taketwo commented Oct 20, 2017

Just change the line to

if (plg->cloud.fields[i].name.compare ("rgb") == 0 || plg->cloud.fields[i].name.compare ("rgba") == 0)

@sj-li
Copy link
Author

sj-li commented Oct 23, 2017

Ok, I add corresponding code and everything is OK.
Thanks for your help!

@sj-li sj-li closed this as completed Oct 23, 2017
@taketwo taketwo removed the needs: author reply Specify why not closed/merged yet label Oct 23, 2017
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

No branches or pull requests

2 participants