nkoenig's answer worked for me. But there wasn't any need for step 4 - Use ground plane using include tag
I also referred to another question for values of ambient, diffuse, specular ,emissive to ensure no squishing of image. Also used the fix mentioned in the answer.
Steps that worked for me:
Create a new model directory:
mkdir ~/.gazebo/models/my_ground_plane
Create the materials directories:
mdkir -p ~/.gazebo/models/my_ground_plane/materials/textures
mdkir -p ~/.gazebo/models/my_ground_plane/materials/scripts
Create your material script file
~/.gazebo/models/my_ground_plane/materials/scripts/my_ground_plane.material
with the following contents:
material MyGroundPlane/Image
{
technique
{
pass
{
ambient 1 1 1 1.000000
diffuse 1 1 1 1.000000
specular 0.03 0.03 0.03 1.000000
texture_unit
{
texture MyImage.png
}
}
}
}
4.Copy your image to
~/.gazebo/models/my_ground_plane/materials/textures/MyImage.png
5.Create a
~/.gazebo/models/my_ground_plane/model.sdf
file with the following contents
<?xml version="1.0" encoding="UTF-8"?>
<sdf version="1.4">
<model name="my_ground_plane">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
<surface>
<friction>
<ode>
<mu>100</mu>
<mu2>50</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name="visual">
<cast_shadows>false</cast_shadows>
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
<material>
<script>
<uri>model://my_ground_plane/materials/scripts</uri>
<uri>model://my_ground_plane/materials/textures/</uri>
<name>MyGroundPlane/Image</name>
</script>
</material>
</visual>
</link>
</model>
</sdf>
6.Create a
~/.gazebo/models/my_ground_plane/model.config
file with the following contents
<?xml version="1.0" encoding="UTF-8"?>
<model>
<name>My Ground Plane</name>
<version>1.0</version>
<sdf version="1.4">model.sdf</sdf>
<description>My textured ground plane.</description>
</model>
7.Files I have created till now:
~/.gazebo/models/my_ground_plane/materials/scripts/my_ground_plane.material
~/.gazebo/models/my_ground_plane/materials/textures/MyImage.png
~/.gazebo/models/my_ground_plane/model.config
~/.gazebo/models/my_ground_plane/model.sdf
8.Open Gazebo and add my_ground_plane to add the new texture you defined to the Gazebo ground plane
9.If your floor comes up blinking grey when you insert it, it's because it's z-fighting with the default ground_plane, just delete the ground plane and that should be fine.