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

Revision history [back]

click to hide/show revision 1
initial version

Blender export materials with a null ambient lightning, this is probably why your meshes doesn't look like what you expect.

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>

Blender export materials with a null ambient lightning, this is probably why your meshes doesn't look like what you expect.

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/*

Blender export materials with a null ambient lightning, this is probably why your meshes doesn't don't look like what you expect.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/*