Home | Tutorials | Wiki | Issues
Ask Your Question
0

Unable to import own mesh into gazebo

asked 2017-08-01 08:20:37 -0500

federico.nardi gravatar image

updated 2017-08-02 04:48:56 -0500

Hi all,

I'm trying to use gazebo from ROS and my problem is the following: I have a mesh saved in .dae format that I want to load from a world file.

So, this is what I've done:

Then, I wrote the following world file:

<?xml version="1.0"?>
<sdf version="1.4">
  <world name="default">
    <include>
      <uri>model://sun</uri>
    </include>
    <include>
      <uri>model://ground_plane</uri>
    </include>   
    <model name="my_mesh">
      <pose>0 0 0  0 0 0</pose>
      <static>true</static>
      <link name="body">
        <visual name="visual">
          <geometry>
            <mesh><uri>model://my_mesh</uri></mesh>
          </geometry>
        </visual>
      </link>
    </model>
  </world>
</sdf>

and the corresponding launch file:

<launch>

  <!-- these are the arguments you can pass this launch file, for example paused:=true -->
  <arg name="paused" default="false"/>
  <arg name="use_sim_time" default="true"/>
  <arg name="extra_gazebo_args" default=""/>
  <arg name="gui" default="true"/>
  <arg name="headless" default="false"/>
  <arg name="debug" default="false"/>
  <arg name="physics" default="ode"/>
  <arg name="verbose" default="false"/>
  <arg name="world_name" default="$(find mapping_environments)/worlds/my_mesh.world"/> 

  <!-- set use_sim_time flag -->
  <group if="$(arg use_sim_time)">
    <param name="/use_sim_time" value="true" />
  </group>

  <!-- set command arguments -->
  <arg unless="$(arg paused)" name="command_arg1" value=""/>
  <arg     if="$(arg paused)" name="command_arg1" value="-u"/>
  <arg unless="$(arg headless)" name="command_arg2" value=""/>
  <arg     if="$(arg headless)" name="command_arg2" value="-r"/>
  <arg unless="$(arg verbose)" name="command_arg3" value=""/>
  <arg     if="$(arg verbose)" name="command_arg3" value="--verbose"/>
  <arg unless="$(arg debug)" name="script_type" value="gzserver"/>
  <arg     if="$(arg debug)" name="script_type" value="debug"/>

  <!-- start gazebo server-->
  <node name="gazebo" pkg="gazebo_ros" type="$(arg script_type)" respawn="false" output="screen"
    args="$(arg command_arg1) $(arg command_arg2) $(arg command_arg3) -e $(arg physics) $(arg extra_gazebo_args) $(arg world_name)" />

  <!-- start gazebo client -->
  <group if="$(arg gui)">
    <node name="gazebo_gui" pkg="gazebo_ros" type="gzclient" respawn="false" output="screen"/>
  </group>

</launch>

but when I roslaunch the file, gazebo starts with an empty world. Is there someone that can, please, explain me how to solve this problem?

Thanks!


EDIT:

@hamzamerzic according to http://wiki.ros.org/roslaunch/XML/env, the env tag is deprecated and, in fact, it has no effect. There, it is suggested to use env-loader. But, if I'm not wrong, this is meant to be used in distributed machines settings. Do you have any clue on how I can solve this problem?

edit retag flag offensive close merge delete

Comments

What I find useful is setting the GAZEBO_MODEL_PATH env variable to point to the location of your custom models. You can add within your launch file the following command: <env name="GAZEBO_MODEL_PATH" value="$(find mapping_environments)/models"/>.

hamzamerzic gravatar imagehamzamerzic ( 2017-08-02 04:21:22 -0500 )edit

Yep, that works for sure. I'm going to follow your suggestion. Thanks

federico.nardi gravatar imagefederico.nardi ( 2017-08-02 04:25:04 -0500 )edit
<@federico.nardi">p>@federico.nardi This is strange, because I use that extensively and it works like a charm. You can find examples [here](http://answers.ros.org/question/261068/roslaunch-xml-env-tag/) and [here](http://answers.gazebosim.org/question/1684/when-importing-a-urdf-model-how-are-package-uris-parsed/). You can also set the environment variable in your .bashrc by adding export GAZEBO_MODEL_PATH="$(rospack find mapping_environments)/models", but I prefer to have everything in the launch file.

hamzamerzic gravatar imagehamzamerzic ( 2017-08-02 05:04:44 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-08-01 19:48:36 -0500

The URI should be pointing to the mesh file, for example model://my_model/meshes/mesh.dae.

See an example here.

I also recommend you use the verbose argument so you can see error messages which should help identify the issue.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-08-01 08:20:37 -0500

Seen: 86 times

Last updated: Aug 02