ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

RViz ignores COLLADA mesh colours

asked 2014-12-03 22:12:26 -0600

Bidski gravatar image

I have a COLLADA (.dae) file that I have exported from blender. Its just a cube that has been shaded green.

However, whenever I try to get rviz to display this mesh (using a Marker display) all I get is a white cube.

I have set the marker colours to RGBA = {0, 0, 0, 0} in the message. I have set /mesh_use_embedded_materials to true. I read somewhere that if there is an ambient colour in the mesh file with one of its components set to 0 that rviz wont render it properly, I checked that and there were no zeros.

This link has the mesh file and screenshots from blender and rviz.

Can someone tell me how to get rviz to render my mesh using the coulours specified in the mesh file?

I am using the lastest version of Blender (2.72, downloaded just the other day). I am running Ubuntu 14.04 and ROS Indigo 1.11.9

Bidski

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2015-02-06 03:16:42 -0600

VictorLamoine gravatar image

updated 2016-02-21 16:44:44 -0600

Blender export materials with a null ambient lightning, this is probably why your meshes don't look like expected.

Manually

I do not know what to change in the Blender material to set the ambient so I manually edit the exported dae files; Replace

<ambient>
  <color sid="ambient">0 0 0 1</color>
</ambient>

with

<ambient>
  <color sid="ambient">0.1 0.1 0.1 1</color>
</ambient>

Python script

Here is a script that copies the diffuse color to the ambient color, first edit a new script file (this is for Nemo, not Nautilus):

gedit ~/.local/share/nemo/scripts/RViz\ collada

Use the following script:

#!/bin/bash

# Check if xml-twig-tools is installed
pkg_ok=$(dpkg-query -W --showformat='${Status}\n' xml-twig-tools|grep "install ok installed")
if [ "" == "$pkg_ok" ]; then
    notify-send "Missing package" -t 1 "Please install xml-twig-tools"
    exit 0
fi

count=0

# Reads Nautilus / nemo arguments to detect which file have to processed
# Processes only selected files with .dae extension (case insensitive)
for file in $(find ${NEMO_SCRIPT_SELECTED_FILE_PATHS} -iname '*.dae'); do
    # Fetches all "diffuse" properties from materials accross the file into a single string
    diffuse_properties=`xml_grep 'diffuse' $file --text_only`

    # Splits diffuse_properties string into an array of strings
    readarray -t properties_array <<<"$diffuse_properties"

    # Replaces only the first occurence in the file each time
    for element in "${properties_array[@]}"
    do
        sed -i "0,/ambient\">0\ 0\ 0\ 1/s//ambient\">$element/" $file
    done

    ((count++))
done

# Notify user
notify-send "RViz collada" -t 1 "$count files tweaked"
exit 0

Make the script executable:

chmod +x ~/.local/share/nemo/scripts/*
edit flag offensive delete link more

Comments

See also rviz/issues/836.

gvdhoorn gravatar image gvdhoorn  ( 2015-02-06 03:33:14 -0600 )edit
0

answered 2014-12-04 01:16:38 -0600

gvdhoorn gravatar image
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-12-03 22:12:26 -0600

Seen: 2,857 times

Last updated: Feb 21 '16