0
$\begingroup$

Gazebo Answers logo

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


Originally posted by Anirban Sinha on Gazebo Answers with karma: 3 on 2021-08-29

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

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.


Originally posted by Veerachart with karma: 226 on 2021-08-30

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Anirban Sinha on 2021-08-31:
Adding the mesh directory to the GAZEBO_RESOURCE_PATH solves the problem. Thank you.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.