Tutorials/1.2/build robot/attach meshes


 * 1) Tutorial: Attach Meshes#


 * Prerequisites:** Make a mobile robot

Meshes can add realism to a model both visually and for sensors. This tutorial demonstrates how the user can use custom meshes to define how their model will appear in simulation.


 * 1) Attach a Mesh as Visual##

The most common use case for a mesh is to create a realistic looking visual.

1. Navigate to the `my_robot` directory

cd ~/.gazebo/models/my_robot

1. Open the `model.sdf` file using your favorite editor

gedit ~/.gazebo/models/my_robot/model.sdf

1. We'll add a mesh to the chassis visual. Find the visual with `name=visual`, which looks like:  .4 .2 .1

1. A mesh can come a file on disk, or from another model. In this example we'll use a mesh from the pioneer2dx model. Change the visual element to the following (but keep the the rest of the file intact):

 model://pioneer2dx/meshes/chassis.dae

1. Look in your locally cached model database to see if you have the `pioneer2dx` model referenced by above ` ` block:

ls -l ~/.gazebo/models/pioneer2dx/meshes/chassis.dae

If the mesh file does not exist, pull the model from the Gazebo Model Database by letting Gazebo know where to find the model using the environment variable:

export GAZEBO_MODEL_DATABASE_URI=http://gazebosim.org/models

and spawn the `Pioneer 2DX` model at least once in gazebo. Or manually download the model files to local cache:

cd ~/.gazebo/models wget -R *index.html*,*.tar.gz --cut-dirs=1 --no-parent -r -x -nH http://gazebosim.org/models/pioneer2dx/

before proceeding.

1. In Gazebo, drag the `My Robot` model in the world. The visual for the chassis will look like a pioneer2dx.



1. The chassis is obviously too big for our robot, so we need to scale the visual.

1. Modify the visual to have a scaling factor.  model://pioneer2dx/meshes/chassis.dae 0.9 0.5 0.5



1. The visual is also a little too low (along the z-axis). Let's raise it up a little by specifying a pose for the visual:

 0 0 0.05 0 0 0          model://pioneer2dx/meshes/chassis.dae 0.9 0.5 0.5



Note that at this point we have simply modified the ` ` elements of the robot, so the robot will look like a scaled down version of the Pioneer 2DX model through the GUI and to GPU based sensors such as camera, depth camera and GPU Lasers. Since we did not modify the ` ` elements in this model, the box geometry will still be used by the physics engine for collision dynamics and by CPU based ray sensors.


 * 1) Further Reading##

When creating a new robot, you'll likely want to use your own mesh file. The import a mesh tutorial describes how to go about importing a mesh into a format suitable for Gazebo.


 * 1) Try for yourself ##

1. Find and download a new mesh on [3D Warehouse](http://sketchup.google.com/3dwarehouse/). Make sure the mesh is in the Collada (.dae) format. 1. Put the mesh in the `~/.gazebo/models/my_robot/meshes`, creating the `meshes` subdirectory if necessary 1. Use your new mesh on the robot, either as a replacement for the chassis, or as an additional ` `.

Note: Materials (texture files such with extension like .png or .jpg), should be placed in `~/.gazebo/models/my_robot/materials/textures`.


 * 1) Next##

Next: Add a Sensor to a Robot