1

I am trying to display aruco marker on one (only one) side of the cube in Gazebo. I am using the following model, that is pasted in a world file:

    <model name='charger'>
    <static>true</static>
    <link name='charger_link'>
        <collision name='charger_collision'>
            <geometry>
                <box>
                    <size>1 1 1</size>
                </box>
            </geometry>
        </collision>
        <visual name='charger_visual'>
            <geometry>
                <box>
                    <size>1 1 1</size>
                </box>
            </geometry>
            <material>
                <script>
                    <uri>file://../models/aruco_markers/aruco_marker_42.png</uri>
                    <name>charger_material</name>
                </script>
                <ambient>1 1 1 1</ambient>
                <diffuse>1 1 1 1</diffuse>
                <specular>0 0 0 1</specular>
                <emissive>1 1 1 0</emissive>
                <shader type='vertex'>
                  <normal_map>__default__</normal_map>
                </shader>                    
            </material>
        </visual>
    </link>
    <pose>0 7.7 0.5 0 0 0</pose>
</model>

The directory structure is:

src

src/worlds (this is where world file is)

src/models

src/models/aruco_markers (this is where images are)

Nevertheless, all I see is a cube, with no image on its sides. Any suggestions?

Steve Brown
  • 369
  • 1
  • 3
  • 12

2 Answers2

0

You are using a <script> tag inside the <material>, use the <texture> tag, be sure that the file aruco_marker_42.png is in the proper directory src/models/aruco_markers and the model definition below should work.

<model name='charger'>
  <static>true</static>
  <link name='charger_link'>
    <collision name='charger_collision'>
      <geometry>
        <box>
          <size>1 1 1</size>
        </box>
      </geometry>
    </collision>
    <visual name='charger_visual'>
      <geometry>
        <box>
          <size>1 1 1</size>
        </box>
      </geometry>
      <material>
        <ambient>1 1 1 1</ambient>
        <diffuse>1 1 1 1</diffuse>
        <specular>0 0 0 1</specular>
        <emissive>1 1 1 0</emissive>
        <shader type='vertex'>
          <normal_map>__default__</normal_map>
        </shader>
        <texture>
          <diffuse>
            <uri>file://../models/aruco_markers/aruco_marker_42.png</uri>
          </diffuse>
        </texture>
      </material>
    </visual>
  </link>
  <pose>0 7.7 0.5 0 0 0</pose>
</model>
Saxtheowl
  • 4,136
  • 5
  • 23
  • 32
  • Thank you. But it is still not working. No errors in the output, and white cube with no images. – Steve Brown Apr 09 '23 at 11:51
  • Just in case: I have uploaded the entire project here: (https://drive.google.com/file/d/1aAWSEaaNINA5F4NOLTdLXxHNTbAEH46c/view?usp=sharing) It is a zip file that should be unpacked into the src subfolder of a ROS2 workspace. It has maps, models - everything, and should, in theory, run as is. – Steve Brown Apr 09 '23 at 17:41
  • To run it ("harsh" is a workspace, and I wasn't able to add new lines): ~/.../harsh$ colcon build --packages-select navigation_bot_10 ~/.../harsh$ source install/setup.bash ~/.../harsh$ ros2 launch navigation_bot_10 main_simulation_launch.py world:=src/worlds/maze_with_charger.sdf map:='/home/svartanov/ros_projects/harsh/src/maps/map.yaml' slam:=False keepout_mask:=src/maps/keepout_mask.yaml – Steve Brown Apr 09 '23 at 17:44
0

Ok, I have found a solution. Looks a bit strange, but definitely works:

<model name='charger'>
    <static>true</static>
    <link name='charger_link'>
        <collision name='charger_collision'>
            <geometry>
                <box>
                    <size>1 1 1</size>
                </box>
            </geometry>
        </collision>
        <visual name='charger_visual'>
            <geometry>
                <box>
                    <size>1 1 1</size>
                </box>
            </geometry>
            <material>
<script>
  <uri>model://aruco_markers/materials/scripts</uri>
  <uri>model://aruco_markers/textures/aruco_marker_42.png</uri>
  <name>aruco_marker_42</name>
</script>
                
            </material>                
        </visual>
    </link>
    <pose>0 7.7 0.5 0 0 0</pose>
</model> 

In CMakeLists.txt:

install(DIRECTORY 
  ../models
  DESTINATION 
  share/${PROJECT_NAME}/..)

In "export" section of package.xml:

<gazebo_ros gazebo_model_path="${prefix}/../models"/>

In aruco_marker_42.material:

material aruco_marker_42
{
  technique
  {
    pass
    {
      texture_unit
      {
        texture aruco_marker_42.png
        scale 1 1
      }
    }
  }
}

Looks like it can be simplified... but at least it shows the image.

Steve Brown
  • 369
  • 1
  • 3
  • 12