-
Notifications
You must be signed in to change notification settings - Fork 216
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
Map colors looks wrong/inverted on npm package, but ok for compiled version #574
Comments
A lot of questions... You are now comparing different versions of the library from different sources. Which isn't a good way to find the bug. So I suggest you stick to one source and then check different releases. So we can determine when the bug was introduced. Good luck. I am curious to the results. |
I found the issue. Old code (OccupancyGrid class) transforms occupancy value [0, 100] to a grayscale value of [0, 255]; current code directly uses occupancy value to get RGBA values directly, which is wrong. Here is a snippet of the old code for generating RGB values from occupancy data:
The specific code for transforming occupancy values to grayscale values:
In the new code, we have: ros3djs/src/navigation/OccupancyGrid.js Lines 76 to 79 in 65ea47c
And as you can see in the definition, it straight up uses the occupancy value as: ros3djs/src/navigation/OccupancyGrid.js Lines 119 to 126 in 65ea47c
The fix for this should be easy. Just put the code for transforming occupancy value to grayscale value in getColor(), then use that to get RGBA values. |
Related PRs: #235, #339 and #343. I think we both agree the alpha channel is not the problem here. But the problem is that the colour is inverted anymore. The old implementation only allowed 3 levels (white, gray and black). I think we should come up with a function which makes this continues. Something like @wakoko79 could you test if the current opacity option of the OccupancyGrid does work? Otherwise we could fix that too. |
The alpha channel was properly handled. The issue lies with the ros3djs/src/navigation/OccupancyGrid.js Lines 119 to 126 in 65ea47c
The equations there for conversion of Now, occupancy data from ros message is 0 for not occupied, and 100 for surely occupied. And from intuition, an occupied pixel should be black. The reason that the current code inverts the colors is that getColor() directly uses occupancy data, instead of transforming it first to a grayscale value. For it to work as before, getColor() should go something like this:
On the other note @MatthijsBurgh, opacity is fine. |
@wakoko79 I made a typo in my previous message. The alpha channel is indeed not the problem. Could you edit your last message based on this. P.S. thanks for testing the opacity. |
In my case using npm and downloading the component from github, the occupancyGrid color is still inverted. Maybe the ros3d.cjs.js has not been updated?
` |
Description
Map colors looks wrong/inverted on npm package, but ok for compiled version.
Longer Description
So I tried to use ros3d, we first tried the tutorial from ROS.
There are multiple imports I tried, and the only version that has correct colors is from the compiled full/min import from robotwebtools.
We are using reactjs for this.
Here is a snippet for the react component (ros3d was imported in index.html which is not shown here):
When importing from node_modules/ros3d, I just uncomment the import line above then change the names for Viewer, OccupancyGridClient, etc.
If I import from package from npm (that has pre-built files) by install with
npm i ros3d
, the colors seems to be inverted.This is also true when I tried to install directly from github with
npm i RobotWebTools/ros3djs
.When I also tried to import from the recommended links in the read me from jsdelivr and from github release, it is also inverted.
I would like to use the latest one (from github or npm) but it has wrong colors.
So, is there a change of usage of the package that is not published in ROS?
Or have I done anything wrong?
Why is the release from robotwebtools different from the one in github and npm?
Here are some screenshots.
From importing robotwebtools link1_full or link2_min:
From importing from npm package (npm i ros3d, or from this github repository, npm_page
The text was updated successfully, but these errors were encountered: