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

Problems viewing Collada files in Gazebo-ROS

asked 2015-06-25 06:26:03 -0500

updated 2015-06-25 10:14:07 -0500

I have followed the tutorial to insert a Collada .dae file into Gazebo, so that my world file is:

<?xml version="1.0" ?>
<sdf version="1.4">
<world name="test_world">
    <include>
        <uri>model://sun</uri>
    </include>
    <include>
        <uri>model://ground_plane</uri>
    </include>

<model name="duck">
    <pose>0 0 0  0 0 0</pose>
    <static>true</static>
    <link name="body">
        <visual name="visual">
            <geometry>
                <mesh><uri>file://duck.dae</uri></mesh>
            </geometry>
        </visual>
    </link>
</model>
</world>
</sdf>

If I run gazebo test_world.world I can see the duck. However, if I create the following launch file:

<?xml version="1.0" encoding="UTF-8"?>
<launch>

<include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name"   value="$(find my_package)/models/test_world.world" />
    <arg name="use_sim_time" value="true" />
    <arg name="debug"        value="false" />
    <arg name="gui"          value="true" />
</include>
</launch>

The duck is not displayed in Gazebo, although I can see the element exists in the left-hand pannel. I have seen other people with my problem, and tried many things, but I cannot make it work.

Should the .dae and .world files be in a specific folder? Any help is appreciated! (I'm using Gazebo 4.1.3 with ROS Indigo).

UPDATE: After applying the accepted answer, this is the final state (note that file:// has changed to model://)

Launch file:

<?xml version="1.0" encoding="UTF-8"?>
<launch>
<include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name"   value="$(find my_package)/models/test_world.world" />
    <arg name="use_sim_time" value="true" />
    <arg name="debug"        value="false" />
    <arg name="gui"          value="true" />
</include>
</launch>

World file:

<?xml version="1.0" ?>
<sdf version="1.4">
<world name="test_world">
    <include>
        <uri>model://sun</uri>
    </include>
    <include>
        <uri>model://ground_plane</uri>
    </include>

<model name="duck">
    <pose>0 0 0  0 0 0</pose>
    <static>true</static>
    <link name="body">
        <visual name="visual">
            <geometry>
                <mesh><uri>model://duck.dae</uri></mesh>
            </geometry>
        </visual>
    </link>
</model>
</world>
</sdf>

And the folder structure is:

  • my_package
    • models
      • test_world.world
      • duck.dae
    • lauch
      • test_launch.launch
    • CMakeLists.txt
    • package.xml
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2015-06-25 07:36:16 -0500

updated 2015-06-25 09:59:56 -0500

I guess you need to add an export to your package.xml

  <export>
    <!-- You can specify that this package is a metapackage here: -->
    <!-- <metapackage/> -->

    <!-- Other tools can request additional information be placed here -->
    <gazebo_ros gazebo_model_path="${prefix}/models"/> 
  </export>

And:

  <run_depend>gazebo_ros</run_depend>
  <build_depend>gazebo_ros</build_depend>

And in CMakeLists:

find_package(catkin REQUIRED gazebo_ros)

so the model path "models" inside your package is found by gazebo.

If you are learning SDF now, I guess I am sure that you might also have to learn URDF because SDF is not supported by ROS tools like robot state publisher. (Just a hint) ;-)

UPDATE: I have a model myself inside the directory of my package with dae. I inserted it with gazebo and saved the world file with it.

<model name='hills'>
  <static>1</static>
  <link name='link'>
    <collision name='collision'>
      <geometry>
        <mesh>
          <uri>model://hills/mesh/hills.dae</uri>
        </mesh>
      </geometry>
      <max_contacts>10</max_contacts>
      <surface>
        <bounce/>
        <friction>
          <ode/>
        </friction>
        <contact>
          <ode/>
        </contact>
      </surface>
    </collision>
    <visual name='visual_1'>
      <pose>0 0 0 0 -0 0</pose>
      <cast_shadows>0</cast_shadows>
      <geometry>
        <mesh>
          <uri>model://hills/mesh/hills.dae</uri>
        </mesh>
      </geometry>
      <material>
        <script>
          <uri>model://hills/materials/scripts</uri>
          <uri>model://hills/materials/textures</uri>
          <name>vrc/grass</name>
        </script>
      </material>
    </visual>
    <velocity_decay>
      <linear>0</linear>
      <angular>0</angular>
    </velocity_decay>
    <self_collide>0</self_collide>
    <kinematic>0</kinematic>
    <gravity>1</gravity>
  </link>
  <pose>5 -5 0 0 -0 0</pose>
</model>

It lies in a subfolder

models

-hills
 -materials
 -scripts
 -textures
 -mesh
   -hills.dae
 model.config
 model.sdf

Regards,

Christian

edit flag offensive delete link more

Comments

I'm afraid that is not working, the same results. Cannot see the duck when I roslaunch the file.

Javier V. Gómez gravatar image Javier V. Gómez  ( 2015-06-25 08:00:20 -0500 )edit

maybe a catkin_make could also help ... to publish the path...

cyborg-x1 gravatar image cyborg-x1  ( 2015-06-25 08:20:32 -0500 )edit

@cyborg-x1 Well, by manually creating the model at ~/.gazebo I was able to do what you mention. I saved the world and now it works from the launch file. However, I depend on the file being at ~/.gazebo, which is not very satisfactory.

Javier V. Gómez gravatar image Javier V. Gómez  ( 2015-06-25 08:38:11 -0500 )edit

@cyborg-x1 I changed the <uri>model://duck/meshes/duck.dae</uri> by <uri>package://my_package/models/duck.dae</uri> but it does not work. How can I refer to a model in a package? Thank you!!

Javier V. Gómez gravatar image Javier V. Gómez  ( 2015-06-25 08:39:10 -0500 )edit

that is the export I mentioned it will add the models path in your package to the gazebo one ... and it should find your model ... it does for me ...

cyborg-x1 gravatar image cyborg-x1  ( 2015-06-25 08:49:52 -0500 )edit

Check the insert tab of gazebo if you find your path there.

cyborg-x1 gravatar image cyborg-x1  ( 2015-06-25 08:55:58 -0500 )edit

I do not know what I am doing wrong, but it does not work. In theory, the only thing missing to what I did in the original post is the line addition to the package.xml, are you sure about it?

Javier V. Gómez gravatar image Javier V. Gómez  ( 2015-06-25 09:40:22 -0500 )edit

I do not know when and where it does create that link but you could try to remove devel and build folders and execute catkin_make again... actually that should probably add the folder so you should see any models below it in the Gazebo Insert Tab or at least the path. And source devel/setup.bash

cyborg-x1 gravatar image cyborg-x1  ( 2015-06-25 09:46:15 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-25 06:26:03 -0500

Seen: 3,323 times

Last updated: Jun 25 '15