ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hi @praskot,
although I am going to answer your question I would like to tell you that, in the future, you may want to ask this type of questions on Gazebo answers, since this is something direcly related with Gazebo you will be able to find better information and help there.
Already said that, in order to achieve what you want you have several possibilities:
In case you want to have only an independent texture which can be used in every simple model of gazebo you will need to generate your own material script, and here is how you do that:
If you have installed properly Gazebo, in the location /usr/share/gazebo-9/media/materials/textures
you need to copy your image, lets say test.jpg
. Then in the location /usr/share/gazebo-9/media/materials/scripts
you will have to generate a new script (or you can edit the file gazebo.materials
where all Gazebo default materials are stored). Let us say that you jut modify this file, well at the end of the file (or wherever you want) just copy the following script:
material testing/material
{
receive_shadows on
technique
{
pass
{
ambient 1 1 1 1.000000
diffuse 1 1 1 1.000000
specular 0.03 0.03 0.03 1.000000
emissive 0.900000 0.900000 0.900000 1.000000
texture_unit
{
texture test.jpg
}
}
}
}
Once this is done, it as simple as including the name as a default Gazebo material in your xacro
. That is:
<gazebo reference="box">
<material>testing/material</material>
</gazebo>
An you will have your image as texture.
But there is another possibility: You can generate a 3D model with any modeling program like Blender and then add a custom texture with a UV Map and finally, export this model as a COLLADA file. Then, when you include this 3D model in a gazebo world, the texture images (That must be located in the same root folder as the model) will be automatically parsed and included as a material.
And the last possibility
: Is to have a custom Gazebo model. For this you will have to have the model files structured as follow:
my_model
|_ model.config
|_ model.sdf
|_ materials
|_ script
|_ testing.material (here you include the script)
|_ textures
|_ test.jpg
And then use it in the model.sdf
as:
<material>
<script>
<uri>model://my_model/materials/scripts</uri>
<uri>model://my_model/materials/textures</uri>
<name>testing/material</name>
</script>
</material>
Hope this helps you.
Regards.
2 | No.2 Revision |
Hi @praskot,
although I am going to answer your question I would like to tell you that, in the future, you may want to ask this type of questions on Gazebo answers, since this is something direcly related with Gazebo you will be able to find better information and help there.
Already said that, in order to achieve what you want you have several possibilities:
In case you want to have only an independent texture which can be used in every simple model of gazebo you will need to generate your own material script, and here is how you do that:
If you have installed properly Gazebo, in the location /usr/share/gazebo-9/media/materials/textures
you need to copy your image, lets say test.jpg
. Then in the location /usr/share/gazebo-9/media/materials/scripts
you will have to generate a new script (or you can edit the file gazebo.materials
where all Gazebo default materials are stored). Let us say that you jut modify this file, well at the end of the file (or wherever you want) just copy the following script:
material testing/material
{
receive_shadows on
technique
{
pass
{
ambient 1 1 1 1.000000
diffuse 1 1 1 1.000000
specular 0.03 0.03 0.03 1.000000
emissive 0.900000 0.900000 0.900000 1.000000
texture_unit
{
texture test.jpg
}
}
}
}
Once this is done, it as simple as including the name as a default Gazebo material in your xacro
. That is:
<gazebo reference="box">
<material>testing/material</material>
</gazebo>
An you will have your image as texture.
But there is another possibility: You can generate a 3D model with any modeling program like Blender and then add a custom texture with a UV Map and finally, export this model as a COLLADA file. Then, when you include this 3D model in a gazebo world, the texture images (That must be located in the same root folder as the model) will be automatically parsed and included as a material.
And the last possibility: possibility: Is to have a custom Gazebo model. For this you will have to have the model files structured as follow:
my_model
|_ model.config
|_ model.sdf
|_ materials
|_ script
|_ testing.material (here you include the script)
|_ textures
|_ test.jpg
And then use it in the model.sdf
as:
<material>
<script>
<uri>model://my_model/materials/scripts</uri>
<uri>model://my_model/materials/textures</uri>
<name>testing/material</name>
</script>
</material>
Hope this helps you.
Regards.