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

Gazebo material format #1534

Open
Tacha-S opened this issue Jan 31, 2025 · 2 comments
Open

Gazebo material format #1534

Tacha-S opened this issue Jan 31, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Tacha-S
Copy link

Tacha-S commented Jan 31, 2025

SDF allows the use of script within the material definition, and in gz simulator, the material tag inside the gazebo tag also supports script.
However, when specifying it as follows, gz simulator requests a string upon startup.

http://sdformat.org/spec?ver=1.12&elem=material

sdformat/src/parser_urdf.cc

Lines 1317 to 1321 in 2b583cb

// material
if (strcmp(childElem->Name(), "material") == 0)
{
sdf->material = GetKeyValueAsString(childElem);
}

<gazebo reference="link1">
      <material>
        <script>
          <uri>file://media/materials/scripts/gazebo.material</uri>
          <name>Gazebo/Black</name>
        </script>
      </material>
    </gazebo>

Environment

  • OS Version: Ubuntu 24.04
  • Source or binary build: Binary 14.6.0

Description

  • Expected behavior:
    NO warning.
  • Actual behavior:
    Attribute value string not set is shown.

Steps to reproduce

  1. Set material color to a link
<gazebo reference="link1">
      <material>
        <script>
          <uri>file://media/materials/scripts/gazebo.material</uri>
          <name>Gazebo/Black</name>
        </script>
      </material>
    </gazebo>
  1. launch gz server

Output

[gazebo-1] Warning [parser_urdf.cc:1220] Attribute value string not set
[gazebo-1] Warning [parser_urdf.cc:1220] Attribute value string not set
[gazebo-1] Warning [parser_urdf.cc:1220] Attribute value string not set
[gazebo-1] Warning [parser_urdf.cc:1220] Attribute value string not set
[gazebo-1] Warning [parser_urdf.cc:1220] Attribute value string not set
[gazebo-1] Warning [parser_urdf.cc:1220] Attribute value string not set
[gazebo-1] Warning [parser_urdf.cc:1220] Attribute value string not set
[gazebo-1] Warning [parser_urdf.cc:1220] Attribute value string not set
[gazebo-1] Warning [parser_urdf.cc:1220] Attribute value string not set
[gazebo-1] Warning [parser_urdf.cc:1220] Attribute value string not set
[gazebo-1] Warning [parser_urdf.cc:1220] Attribute value string not set
@Tacha-S Tacha-S added the bug Something isn't working label Jan 31, 2025
@azeey
Copy link
Collaborator

azeey commented Jan 31, 2025

Can you please provide a full .sdf or .urdf file to try?

@azeey azeey moved this from Inbox to In progress in Core development Jan 31, 2025
@azeey azeey self-assigned this Jan 31, 2025
@Tacha-S
Copy link
Author

Tacha-S commented Feb 1, 2025

example.urdf

<?xml version="1.0" encoding="UTF-8"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="bot">
  <link name="base_footprint"/>
  <joint name="base_joint" type="fixed">
    <parent link="base_footprint"/>
    <child link="base_link"/>
    <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
  </joint>

  <link name="base_link">
    <visual>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <box size="1 1 1"/>
      </geometry>
      <material name="white">
        <color rgba="1 1 1 1"/>
      </material>
    </visual>
    <collision>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <box size="1 1 1"/>
      </geometry>
    </collision>
    <inertial>
      <mass value="1"/>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <inertia ixx="0.1" ixy="0.0" ixz="0.0" iyy="0.1" iyz="0.0" izz="0.1"/>
    </inertial>
  </link>
  <gazebo reference="base_link">
    <material>
      <script>
        <uri>file://media/materials/scripts/gazebo.material</uri>
        <name>Gazebo/Black</name>
      </script>
    </material>
  </gazebo>
</robot>
  1. launch gz server
    gz sim empty.sdf
  2. spawn example urdf
    gz service -s /world/empty/create --reqtype gz.msgs.EntityFactory --reptype gz.msgs.Boolean --timeout 1000 --req 'sdf_filename: "/path/to/example.urdf", name: "bot"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In progress
Development

No branches or pull requests

2 participants