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

Visualization markers ignore color and show everything as white #1120

Closed
gaya- opened this issue Jul 6, 2017 · 31 comments · Fixed by #1424
Closed

Visualization markers ignore color and show everything as white #1120

gaya- opened this issue Jul 6, 2017 · 31 comments · Fixed by #1424
Labels

Comments

@gaya-
Copy link

gaya- commented Jul 6, 2017

After the last update on Indigo visualization markers started to appear white.
The message is the same as before and has correct color data.
I suspect it was one of the latest commits about collada file visualization.
Do I understand it correctly that the color information from the Collada file has now higher precedence than the visualization marker message color? If so, what is the reasoning behind that?

@wjwwood
Copy link
Member

wjwwood commented Jul 11, 2017

@gaya- sorry for the regression. That code has been tricky, I'll have a look and see if I can just revert those changes for now and do another release.

@wjwwood wjwwood added the bug label Jul 12, 2017
@wjwwood
Copy link
Member

wjwwood commented Jul 12, 2017

@gaya- I'm guessing it is this pr: #1084

Can you provide a script or bag file (with mesh file) which causes this problem for you?

@wjwwood
Copy link
Member

wjwwood commented Jul 12, 2017

@gaya-
Copy link
Author

gaya- commented Jul 14, 2017

Unfortunately the cad models that created this problem are proprietary so I cannot share them :/
And we have a big deadline in 2 weeks, so no time to look deeper into this.
If no one else comes up with a test case I can look into this after the deadline and see what makes our meshes so special and maybe create a similar mesh to test...

@wjwwood
Copy link
Member

wjwwood commented Jul 25, 2017

I just spent some time trying to reproduce this with Indigo, but I cannot. The behavior in #1084 seems correct to me and seems to still be the case with the latest version of rviz for Indigo. (btw @gaya- exactly which version of rviz are you using?)

I'm going to wait until either @gaya- or someone else can provide me with a bag file or simple Python script to reproduce it.

@ghost
Copy link

ghost commented Jul 31, 2017

Hey! I have the very same problem.
I am simply using this code:

marker.header.frame_id = "base_footprint";
    marker.header.stamp = ros::Time::now();
    marker.ns = "basic_shapes";
    marker.id = 0;
    marker.type = visualization_msgs::Marker::MESH_RESOURCE;
    marker.action = visualization_msgs::Marker::ADD;
    marker.mesh_resource = "package://autonomous_grasping/mesh/Gripper_Assy.stl";
    marker.mesh_use_embedded_materials = false;
    marker.color.r = 0.4;
    marker.color.g = 0.4;
    marker.color.b = 0.4;
    marker.color.a = 1.0;
    marker.scale.x = 0.0012;
    marker.scale.y = 0.0012;
    marker.scale.z = 0.0012;

Which I believe is the normal code for spawning a mesh as Marker (the position is separately set). Still, it appears white, and it didn't until a month ago. It is white with any .stl model I tried. It is gray (as I want it) sometimes, like when I run it after restarting the pc, but then it goes back to white. This thing is driving me crazy.

@wjwwood
Copy link
Member

wjwwood commented Jul 31, 2017

@HenrySleek what version of rviz are you using?

Unfortunately your snippet isn't very helpful without the mesh and the rest of the surrounding code. I'll try to use it as a template to test this out. I was testing with dae before.

@wjwwood
Copy link
Member

wjwwood commented Jul 31, 2017

Ok, I can reproduce this, but only on Kinetic (Xenial). I can also fix by (re?)applying #1084 to kinetic-devel. I was trying Indigo before, but I think the patch that fixes the issue is already present on the latest version of Indigo:

handler_.reset(new MarkerSelectionHandler(this, MarkerID(new_message->ns, new_message->id), context_));
handler_->addTrackedObject(entity_);
}
else
{
// underlying mesh resource has not changed but if the color has
// then we need to update the materials color
if (new_message->mesh_use_embedded_materials == false
&& (!old_message
|| old_message->mesh_use_embedded_materials == true
|| old_message->color.r != new_message->color.r
|| old_message->color.g != new_message->color.g
|| old_message->color.b != new_message->color.b
|| old_message->color.a != new_message->color.a))
{
update_color = true;
}
}

@gaya-, I'll ask again which version of rviz exactly are you using on Indigo?

@wjwwood
Copy link
Member

wjwwood commented Jul 31, 2017

I merged #1129, so if anyone with this problem on Kinetic could try it out that would be great.

I'm still looking into Indigo's issues.

@gaya-
Copy link
Author

gaya- commented Aug 1, 2017

I'm using version 1.11.16.

Here is a sample python code with a sample collada mesh:
https://github.com/gaya-/marker_test
The mesh was exported from blender.

And here's a screenshot of rviz:
https://github.com/gaya-/marker_test/blob/master/marker.png

You run the script like this:
rosrun marker_test marker_test.py

Running Ubuntu 14.04, ROS Indigo, GeForce GTX 980 graphics card, NVidia driver, nothing all that special.

@wjwwood
Copy link
Member

wjwwood commented Aug 3, 2017

Ok, I've narrowed down the issue. There must be a problem with the code that sets the color initially. @gaya- if you start rviz, start your example, visualize it in rviz (it will be white), then edit your example to change the color or alpha, then run it again (without closing rviz) then it will render correctly.

I'm still tracking down the source of logic error, but at least I've narrowed down/reproduced the issue.

@wjwwood wjwwood mentioned this issue Aug 3, 2017
@wjwwood
Copy link
Member

wjwwood commented Aug 4, 2017

@gaya- and @HenrySleek can any of you try the patch in #1132?

@gaya-
Copy link
Author

gaya- commented Aug 7, 2017

The bug is gone in version 1.11.17 of indigo-devel.
Thanks a lot for looking into this.

@gaya- gaya- closed this as completed Aug 7, 2017
@ejalaa12
Copy link

ejalaa12 commented Jan 23, 2018

@wjwwood
Hello, I have the same issue. When I try to use a collada file it appears as white. I saw various same Issues and PRs #751 #1129 #1084 . And I still don't get it.
I am using ROS Kinetic 1.12.12, and Rviz 1.12.15.
Here is the code snippet that I tried:

#!/usr/bin/env python
import rospy
from std_msgs.msg import ColorRGBA
from visualization_msgs.msg import Marker, MarkerArray
from geometry_msgs.msg import Point, Vector3, Quaternion


def createMarker(frame, mtype, m_id, position=Point(0, 0, 0), orientation=Quaternion(0, 0, 0, 1),
                 scale=Vector3(1, 1, 1), rgba=None):
    """
    :rtype: Marker
    :return:
    """
    marker = Marker()
    marker.header.frame_id = frame
    marker.type = mtype
    marker.id = m_id
    marker.action = Marker.MODIFY

    marker.pose.position = position
    marker.pose.orientation = orientation
    marker.scale = scale
    if rgba:
        r, g, b, a = rgba
        r, g, b = r / 256., g / 256., b / 256.
    else:
        r, g, b, a = 0, 0, 0, 0
    marker.color = ColorRGBA(r, g, b, a)

    return marker


if __name__ == '__main__':
    # node init
    rospy.init_node('marker_dae_test')
    rate = rospy.Rate(1)
    # publishers
    pub = rospy.Publisher('markers', MarkerArray, queue_size=1)
    # --------------------------------------------------------- Markers -
    msg = MarkerArray()
    # cube
    cube = createMarker('world', Marker.MESH_RESOURCE, 1)
    cube.mesh_resource = "package://env_3d/data/nil_link_mesh.dae"
    cube.mesh_use_embedded_materials = True
    # add markers to list
    msg.markers.append(cube)
    while not rospy.is_shutdown():
        pub.publish(msg)
        rate.sleep()

And here is the .dae file.

Also, when I use another mesh_resource:

cube.mesh_resource = "package://rviz/src/test/meshes/pr2-base.dae"

Then the texture is correctly displayed.

Am I missing something ?

@exo-core
Copy link

I just ran into the same issue.

This is how my mesh is supposed to look like (screenshot from Blender):
mesh_blender

And this is how it appears in RVIZ, build 1.12.15-0xenial-20180105-172609-0800 amd64:
mesh_rviz

Code of my mesh:

<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
  <asset>
    <contributor>
      <author>Blender User</author>
      <authoring_tool>Blender 2.79.0</authoring_tool>
    </contributor>
    <created>2018-01-29T13:36:13</created>
    <modified>2018-01-29T13:36:13</modified>
    <unit name="meter" meter="1"/>
    <up_axis>Z_UP</up_axis>
  </asset>
  <library_images/>
  <library_effects>
    <effect id="red-effect">
      <profile_COMMON>
        <technique sid="common">
          <phong>
            <emission>
              <color sid="emission">0 0 0 1</color>
            </emission>
            <ambient>
              <color sid="ambient">0 0 0 1</color>
            </ambient>
            <diffuse>
              <color sid="diffuse">1 0 0 1</color>
            </diffuse>
            <specular>
              <color sid="specular">0.25 0.25 0.25 1</color>
            </specular>
            <shininess>
              <float sid="shininess">50</float>
            </shininess>
            <index_of_refraction>
              <float sid="index_of_refraction">1</float>
            </index_of_refraction>
          </phong>
        </technique>
      </profile_COMMON>
    </effect>
    <effect id="green-effect">
      <profile_COMMON>
        <technique sid="common">
          <phong>
            <emission>
              <color sid="emission">0 0 0 1</color>
            </emission>
            <ambient>
              <color sid="ambient">0 0 0 1</color>
            </ambient>
            <diffuse>
              <color sid="diffuse">0 0.8 0 1</color>
            </diffuse>
            <specular>
              <color sid="specular">0.25 0.25 0.25 1</color>
            </specular>
            <shininess>
              <float sid="shininess">50</float>
            </shininess>
            <index_of_refraction>
              <float sid="index_of_refraction">1</float>
            </index_of_refraction>
          </phong>
        </technique>
      </profile_COMMON>
    </effect>
    <effect id="blue-effect">
      <profile_COMMON>
        <technique sid="common">
          <phong>
            <emission>
              <color sid="emission">0 0 0 1</color>
            </emission>
            <ambient>
              <color sid="ambient">0 0 0 1</color>
            </ambient>
            <diffuse>
              <color sid="diffuse">0 0 1 1</color>
            </diffuse>
            <specular>
              <color sid="specular">0.25 0.25 0.25 1</color>
            </specular>
            <shininess>
              <float sid="shininess">50</float>
            </shininess>
            <index_of_refraction>
              <float sid="index_of_refraction">1</float>
            </index_of_refraction>
          </phong>
        </technique>
      </profile_COMMON>
    </effect>
  </library_effects>
  <library_materials>
    <material id="red-material" name="red">
      <instance_effect url="#red-effect"/>
    </material>
    <material id="green-material" name="green">
      <instance_effect url="#green-effect"/>
    </material>
    <material id="blue-material" name="blue">
      <instance_effect url="#blue-effect"/>
    </material>
  </library_materials>
  <library_geometries>
    <geometry id="Cylinder-mesh" name="Cylinder">
      <mesh>
        <source id="Cylinder-mesh-positions">
          <float_array id="Cylinder-mesh-positions-array" count="144">0 0.04999995 0 0 0.04999995 1 0.03535526 0.03535526 0 0.03535526 0.03535526 1 0.04999995 0 0 0.04999995 0 1 0.03535526 -0.03535526 0 0.03535526 -0.03535526 1 0 -0.04999995 0 0 -0.04999995 1 -0.03535526 -0.03535526 0 -0.03535526 -0.03535526 1 -0.04999995 0 0 -0.04999995 0 1 -0.03535526 0.03535526 0 -0.03535526 0.03535526 1 0 0.04999989 0 1 0.05000007 0 0 0.03535521 -0.03535538 1 0.03535532 -0.03535532 0 0 -0.05000007 1 0 -0.05000001 0 -0.03535532 -0.03535538 1 -0.03535521 -0.03535532 0 -0.05000007 0 1 -0.04999989 0 0 -0.03535532 0.03535521 1 -0.03535521 0.03535526 0 0 0.04999989 1 0 0.04999995 0 0.03535521 0.03535521 1 0.03535532 0.03535526 -0.05000001 0 0 -0.05000013 1 0 -0.03535532 0 -0.03535538 -0.03535538 1 -0.03535532 0 0 -0.05000007 0 1 -0.05000001 0.03535526 0 -0.03535538 0.03535521 1 -0.03535532 0.04999995 0 0 0.04999989 1 0 0.03535526 0 0.03535521 0.03535521 1 0.03535526 0 0 0.04999989 0 1 0.04999995 -0.03535526 0 0.03535521 -0.03535532 1 0.03535526</float_array>
          <technique_common>
            <accessor source="#Cylinder-mesh-positions-array" count="48" stride="3">
              <param name="X" type="float"/>
              <param name="Y" type="float"/>
              <param name="Z" type="float"/>
            </accessor>
          </technique_common>
        </source>
        <source id="Cylinder-mesh-normals">
          <float_array id="Cylinder-mesh-normals-array" count="138">-1.67314e-7 0.9238802 -0.382682 0 0.3826835 -0.9238795 0 -0.3826824 -0.9238801 1.36893e-7 -0.9238798 -0.382683 1.68836e-7 -0.923879 0.382685 0 -0.3826823 0.9238801 1 0 0 0 0.3826839 0.9238794 -1.81004e-7 0.9238792 0.3826845 -1 0 0 0 0.9238795 -0.3826835 0 0.3826823 -0.9238801 0 -0.3826834 -0.9238796 1.67314e-7 -0.9238799 -0.3826825 0 -0.9238798 0.3826828 0 -0.3826835 0.9238796 -1.21422e-7 0.3826824 0.9238801 -1.68835e-7 0.9238792 0.3826845 -0.9238803 0 -0.3826817 -0.3826824 0 -0.9238801 0.3826832 0 -0.9238798 0.9238803 0 -0.3826818 0.9238796 0 0.3826835 0.3826829 0 0.9238798 0 1 0 -0.3826829 0 0.9238798 -0.923879 0 0.3826848 0 -1 0 -0.9238795 0 -0.3826837 -0.3826818 0 -0.9238803 0.3826833 0 -0.9238796 0.9238801 0 -0.3826824 0.9238798 0 0.3826829 0.3826835 0 0.9238796 -0.3826824 0 0.9238801 -0.9238787 0 0.3826856 0.3826829 0.9238798 0 0.9238798 0.3826829 0 0.9238798 -0.3826829 0 0.3826829 -0.9238798 0 -0.3826829 -0.9238798 0 -0.9238798 -0.3826829 0 0 0 1 -0.9238798 0.3826829 0 -0.3826829 0.9238798 0 0 0 -1</float_array>
          <technique_common>
            <accessor source="#Cylinder-mesh-normals-array" count="46" stride="3">
              <param name="X" type="float"/>
              <param name="Y" type="float"/>
              <param name="Z" type="float"/>
            </accessor>
          </technique_common>
        </source>
        <vertices id="Cylinder-mesh-vertices">
          <input semantic="POSITION" source="#Cylinder-mesh-positions"/>
        </vertices>
        <triangles material="red-material" count="28">
          <input semantic="VERTEX" source="#Cylinder-mesh-vertices" offset="0"/>
          <input semantic="NORMAL" source="#Cylinder-mesh-normals" offset="1"/>
          <p>17 0 18 0 16 0 19 1 20 1 18 1 21 2 22 2 20 2 23 3 24 3 22 3 25 4 26 4 24 4 27 5 28 5 26 5 29 6 25 6 21 6 29 7 30 7 28 7 31 8 16 8 30 8 22 9 28 9 30 9 17 10 19 10 18 10 19 11 21 11 20 11 21 12 23 12 22 12 23 13 25 13 24 13 25 14 27 14 26 14 27 15 29 15 28 15 21 6 19 6 17 6 17 6 31 6 29 6 29 6 27 6 25 6 25 6 23 6 21 6 21 6 17 6 29 6 29 16 31 16 30 16 31 17 17 17 16 17 30 9 16 9 22 9 18 9 20 9 22 9 22 9 24 9 26 9 26 9 28 9 22 9 16 9 18 9 22 9</p>
        </triangles>
        <triangles material="green-material" count="28">
          <input semantic="VERTEX" source="#Cylinder-mesh-vertices" offset="0"/>
          <input semantic="NORMAL" source="#Cylinder-mesh-normals" offset="1"/>
          <p>33 18 34 18 32 18 35 19 36 19 34 19 37 20 38 20 36 20 39 21 40 21 38 21 41 22 42 22 40 22 43 23 44 23 42 23 45 24 41 24 37 24 45 25 46 25 44 25 47 26 32 26 46 26 40 27 42 27 46 27 33 28 35 28 34 28 35 29 37 29 36 29 37 30 39 30 38 30 39 31 41 31 40 31 41 32 43 32 42 32 43 33 45 33 44 33 37 24 35 24 33 24 33 24 47 24 37 24 45 24 43 24 41 24 41 24 39 24 37 24 37 24 47 24 45 24 45 34 47 34 46 34 47 35 33 35 32 35 46 27 32 27 34 27 34 27 36 27 46 27 38 27 40 27 46 27 42 27 44 27 46 27 46 27 36 27 38 27</p>
        </triangles>
        <triangles material="blue-material" count="28">
          <input semantic="VERTEX" source="#Cylinder-mesh-vertices" offset="0"/>
          <input semantic="NORMAL" source="#Cylinder-mesh-normals" offset="1"/>
          <p>1 36 2 36 0 36 3 37 4 37 2 37 5 38 6 38 4 38 7 39 8 39 6 39 9 40 10 40 8 40 11 41 12 41 10 41 13 42 9 42 1 42 13 43 14 43 12 43 15 44 0 44 14 44 8 45 10 45 14 45 1 36 3 36 2 36 3 37 5 37 4 37 5 38 7 38 6 38 7 39 9 39 8 39 9 40 11 40 10 40 11 41 13 41 12 41 5 42 3 42 1 42 1 42 15 42 13 42 13 42 11 42 9 42 9 42 7 42 5 42 5 42 1 42 9 42 13 43 15 43 14 43 15 44 1 44 0 44 14 45 0 45 6 45 2 45 4 45 6 45 6 45 8 45 14 45 10 45 12 45 14 45 0 45 2 45 6 45</p>
        </triangles>
      </mesh>
    </geometry>
  </library_geometries>
  <library_controllers/>
  <library_visual_scenes>
    <visual_scene id="Scene" name="Scene">
      <node id="Cylinder" name="Cylinder" type="NODE">
        <matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix>
        <instance_geometry url="#Cylinder-mesh" name="Cylinder">
          <bind_material>
            <technique_common>
              <instance_material symbol="red-material" target="#red-material"/>
              <instance_material symbol="green-material" target="#green-material"/>
              <instance_material symbol="blue-material" target="#blue-material"/>
            </technique_common>
          </bind_material>
        </instance_geometry>
      </node>
    </visual_scene>
  </library_visual_scenes>
  <scene>
    <instance_visual_scene url="#Scene"/>
  </scene>
</COLLADA>

@ejalaa12
Copy link

@exo-core I also noticed that if you use image textures in Blender then Rviz displays it correctly. But everything else that uses classic colored materials doesn't work. (it can be a workaround while waiting for a correct fix)

@exo-core
Copy link

exo-core commented Jan 29, 2018

@ejalaa12 I also noticed. The textured meshes from the pr2-description package are working fine.

@wjwwood
Copy link
Member

wjwwood commented Jan 30, 2018

Either @dhood or I will try to reproduce what you've described as soon as we can.

@willcbaker
Copy link

+1, have white meshes when textured using basic material in blender (not UV map)

@wjwwood
Copy link
Member

wjwwood commented Jun 11, 2018

I think this was fixed a while back by #1132 (it claims to do so), please comment if this is not the case for someone.

@wjwwood wjwwood closed this as completed Jun 11, 2018
@ghost ghost removed the backlog label Jun 11, 2018
@wjwwood
Copy link
Member

wjwwood commented Jun 11, 2018

Ah, I already closed/reopened this... Sorry.

@wjwwood wjwwood reopened this Jun 11, 2018
@willcbaker
Copy link

willcbaker commented Jul 6, 2018

@wjwwood confused by the closed/open, this is still an issue, right? I still have white meshes in kinetic building from src and the deb
edit, this I see now #1134

@wjwwood
Copy link
Member

wjwwood commented Jul 9, 2018

Still an issue.

@ana-GT
Copy link

ana-GT commented Aug 10, 2018

Still an issue in ROS kinetic (white meshes for .dae meshes)

@Master-Matt
Copy link

Master-Matt commented Aug 30, 2018

Trying to view this in in Rviz shows only a white box.
I'm using Kinetic, so Gazebo 7 and Rviz 1.12.16
april_box.zip

Interestingly, viewing this in RViz works fine. The minute I edit the PNG file or change anything, it doesn't.
textured_shapes.zip

@ejalaa12
Copy link

ejalaa12 commented May 6, 2019

I've decided to have a look to understand the full issue where the problem comes from by looking at every possible scenario.

use_embedded_materials=False (works fine)

When use_embedded_materials=False, the material (texture or classical color material) is replaced by whatever color is defined in the published Marker msg

use_embedded_materials=True (issue)

r,g,b,a = 0,0,0,0

Textured materials are used correctly. But `'classical color' materials are white.

r,g,b = 0,0,0 ; alpha !=0

Textured materials and classical materials are black with alpha transparency

r,g,b != 0,0,0; alpha = 0

Everything is invisible (because alpha=0)

r,g,b,a != 0,0,0,0

Textured materials are tinted with r,g,b and have the alpha transparency
Classical materials are replaced with r,g,b, and have the alpha transparency


It's weird that this issue keeps coming back, it has been solved here apparently #752 by creating passes but his solution has disappeared since then from the source code. I tried to write it back, but my knowledge of Ogre is very limited, and I can't figure it out.

I've put the files for testing this on a gist that you can find here

xbroquer added a commit to xbroquer/rviz that referenced this issue Jul 18, 2019
…w everything as white

Re-integrate patch from ros-visualization#752 Color tinting for mesh markers

Signed-off-by: Xavier BROQUERE <xav.broquere@gmail.com>
@xbroquer
Copy link

Reproduced on Melodic, I re-integrated #752 on top of melodic branch

xbroquer@aa6f232

@rhaschke
Copy link
Contributor

rhaschke commented Sep 9, 2019

I filed a new solution for this issue: #1424. Please verify that this solution is satisfying to you.

@xbroquer
Copy link

Hi Robert,
Thanks for the fix, I can now see color-based mesh with #1424

However, I noticed that there is now a WARN message: "[ WARN] [1568279672.815047353]: Marker '/0': Marker is fully transparent (color.a is 0.0)." when I want to only use embedded color (r=g=b=a=0). Seems that this is introduced by #1275 .

#1424 handle this particular usecase with the line 182: "update_color = !(new_message->mesh_use_embedded_materials && r == 0 && g == 0 && b == 0 && a == 0);" but not #1275

Can you see if this usecase can be managed in maker_utils.cpp::checkMarkerMsg to avoid this WARN message ?

@rhaschke
Copy link
Contributor

Thanks for this hint. I will add yet another fixup to #1275 to handle this case.

@xbroquer
Copy link

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
9 participants