how-to-add-texture-to-sdf.md
Last updated
Last updated
Copyright (c) Brandeis University
by Tongkai Zhang, tongkaizhang@brandeis.edu
This is a quick guide for adding textures(.png) to your model in gazebo.
gazebo
model in sdf format
After building your own model in the sdf format, you should have a structured model cargo
directory same as the one below.
It's important that you have the directory exactly the same, since importing the texture into gazebo is based on finding parameters and texture images within that directory.
scripts: cargo.material
, formatted file, defining the name, visual property for the material.
textures: the image texture file
model.config
: meta data for the model
model.sdf
: model itself
Basic Steps:
Get the texture image ready and put them under /textures
Define texture in cargo.material
, note how texture image is included as well as how the name is set.
material Cargo/Diffuse
is the unique name for this material.
Add this material in your sdf model. It should be enclosed by the <visual>
tag. Note the uri
sexport GAZEBO_MODEL_PATH=~/catkin_ws/src/warehouse_worker/model/hould be correctly set and the name
of the material should be identical to the name defined in cargo.material
Adding model to your world
Set the model
environment variable in terminal. When gazebo launches the world, it will search the model cargo
under its default model
directory. If you want to include your models in your project folder, you should set the GAZEBO_MODEL_PATH
variable in your terminal.
export GAZEBO_MODEL_PATH=~/catkin_ws/src/warehouse_worker/model/
Now gazebo also searches model under /warehouse_worker/model/