SDF
BACK: Table of contents
Given a Solidworks file, there is a plugin that exists where you can convert the file into an urdf file. After that, it’s much easier to use .sdf format (and Gazebo converts it under the hood anyway), so do the following:
- Place model package into catkin_ws and compile it. Models should come as ROS packages, with a package.xml and CMakeLists.txt.
- Load Gazebo
$ roslaunch gazebo_ros empty_world.launch
- Load URDF model into the GUI.
$ rosrun gazebo_ros spawn_model -file (path to file).urdf -urdf -model my_object
- Right click the model in the GUI to open the Model Editor (Edit model).
- Ctrl-X will close the Model Editor and prompt and ask if you want to save.
- Save the model, which will be an SDF file.
I placed the sdf file in /models, and other meshes in /rotors_description. As long as you correctly identify the path to where bits and pieces of the model are in your sdf file, you should be okay.
For example, the rotors point to a .dae file inside of models/rotors_description/meshes, which is specified in line 124, <uri>model://rotors_description/meshes/iris_prop_ccw.dae</uri>
of iris.sdf.
model:// is defined by the line that we export earlier in the setup.
$ export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/catkin_ws/src/hiperlab_gazebo/models
In the SDF file, you will also specify the physics properties of the model (inertia, mass, etc.) You can also specify which plugins to use there.