0
$\begingroup$

This question and the docs pointed me to $GAZEBO_MODEL_PATH as being the environment variable to change to include models in a gazebo world. However, I am getting an error.

This is my current tree structure:

.
├── CMakeLists.txt
├── model
│   └── robot
│       ├── model.config
│       └── model.sdf
├── script
│   └── hello.cpp
└── worlds
    ├── empty.world
    └── myworld

My GAZEBO_MODEL_PATH is:

$ $ echo $GAZEBO_MODEL_PATH
:/home/self/workspace/build_my_world/model/robot:

But when I run gazebo I get an error.

$ gazebo worlds/myworld 
Error [parser.cc:652] Could not find model.config or manifest.xml for the model
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

This is what I have in myworld file:

   1 <sdf version='1.6'>
   2   <world name='default'>
   3     
   4     <include>
   5       <pose frame=''>0 0 30 0 0 0</pose>
   6       <uri>model://model</uri>
   7     </include>
   8     

The final problem is that even if I remove the model in the world file, entering gazebo doesn't launch the application. There's NO output either.

$\endgroup$

2 Answers 2

1
$\begingroup$

First, you should add to $GAZEBO_MODEL_PATH the base directory of your model collection, /home/self/workspace/build_my_world/model.

Second, you should refer to your model by the name of its subdirectory, robot in this case.

Third, you should close the <world> and <sdf> tags at the end of the file.

It's also advisable to add the sun and ground_plane models to your world.

So in summary, what you should have is the following:

$ echo $GAZEBO_MODEL_PATH
:/home/self/workspace/build_my_world/model
<?xml version="1.0" encoding="utf-8"?>
<sdf version='1.6'>
  <world name='default'>
    <include>
      <uri>model://sun</uri>
    </include>
    <include>
      <uri>model://ground_plane</uri>
    </include>
    <include>
      <pose frame=''>0 0 0 0 0 0</pose>
      <uri>model://robot</uri>
    </include>
  </world>
</sdf>
$\endgroup$
10
  • $\begingroup$ Forgot to mention that I truncated the world file. It is over 3000 lines long. $\endgroup$ Apr 25, 2020 at 14:58
  • $\begingroup$ Is the colon : still part of the $GAZEBO_MODEL_PATH? Running gazebo still doesn't do anything. $\endgroup$ Apr 25, 2020 at 15:03
  • $\begingroup$ It is, but more importantly, you must make sure that Gazebo is reading the variable. Are you launching it from the same session where you exported it? $\endgroup$
    – xperroni
    Apr 25, 2020 at 15:13
  • $\begingroup$ I thought so but I can't check now since I restarted the virtual machine. I also realized that there was a bash variable that wasn't set to anything so the path had two // where a directory needed to have been included. $\endgroup$ Apr 25, 2020 at 15:21
  • $\begingroup$ I thought so but I can't check now since I restarted the virtual machine. I also realized that by doing the export in the .bashrc that there was a bash variable that wasn't set to anything so the path had two // where I expected /build_my_world/. I sourced .bashrc and I didn't see the missing directory when I echoed. $\endgroup$ Apr 25, 2020 at 15:28
1
$\begingroup$

If you don't want to mess things up editing .bashrc variables, I suggest you to use gazebo_ros, and you can edit package.xml file to tell gazebo to where to look for models. A simple example would be;

<depend>gazebo_ros</depend>

<export>
      <gazebo_ros gazebo_model_path="${prefix}/models"/>
      <gazebo_ros gazebo_media_path="${prefix}/worlds"/>
</export>```
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.