Gazebo | Ignition | Community
Ask Your Question
0

Can't import mesh in Gazebo world

asked 2021-08-29 12:13:29 -0600

Anirban Sinha gravatar image

updated 2021-08-29 14:40:48 -0600

Hi,

I am working on a custom rospackage to spawn custom meshed models in Gazebo. The package name is person_sim. The file structure of the package is as following,

person_sim
  |->launch->environment.launch
  |->materials->...
  |->meshes-> my_mesh.world, standing.dae
  |->CMakeLists.txt
  |->package.xml

I have a custom world file which includes a mesh as model in the my_mesh.world file. The my_mesh.world file is as following,

<?xml version="1.0"?>
<sdf version="1.4">
  <world name="default">
    <include>
      <uri>model://ground_plane</uri>
    </include>
    <include>
      <uri>model://sun</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>file://standing.dae</uri></mesh>
          </geometry>
        </visual>
      </link>
    </model>
  </world>
</sdf>

I order to check whether the mesh is working properly, I ran the following command which clearly shows the mesh in the gazebo environment.

$ roscd person_sim/meshes
$ gazebo my_mesh.world

The figure below shows what I see after running the above commands.

image description

But when I am trying to launch this my_mesh.world through roslaunch file, I do not the see the model corresponding to the mesh standing.dae at all. The roslaunch file named environment.launch that I am using is given below

<?xml version="1.0"?>
<launch>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find person_sim)/meshes/my_mesh.world"/>
  </include>
</launch>

The figure below shows that no mesh model is in the gazebo world however the model named my_mesh is listed under Gazebo's UI panel on the left. Any help in resolving the issue will be appreciated.

image description

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-30 04:53:39 -0600

Veerachart gravatar image

I think with <uri>file://standing.dae</uri>, gazebo will try to look for the file standing.dae at your current directory, and the $GAZEBO_RESOURCE_PATH. So, when you run your world file, you are in the same directory as the mesh file, and therefore it can be loaded. However when you run the ROS launch file, I think you are in the different directory, and Gazebo can't find the standing.dae file. (You can confirm this by adding verbose option when running the ROS script. If it says the file can't be found then that's the point.)

A quick fix would be adding the path to your mesh file to the $GAZEBO_RESOURCE_PATH by running

export GAZEBO_RESOURCE_PATH=$GAZEBO_RESOURCE_PATH:/path/to/person_sim/meshes

and the launch file should load the mesh. However it's probably not the best way.

You can create a model, put your mesh file into the meshes folder of that model, and add an SDF file to load the mesh using <uri>model://meshes/standing.dae</uri>, like other models you can find on Gazebo model server.

edit flag offensive delete link more

Comments

Adding the mesh directory to the GAZEBO_RESOURCE_PATH solves the problem. Thank you.

Anirban Sinha gravatar imageAnirban Sinha ( 2021-08-31 08:09:32 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2021-08-29 12:13:29 -0600

Seen: 1,220 times

Last updated: Aug 30 '21