I am using ROS2/Gazebo project. In Gazebo, I have a cube, and I want to have an aruco marker on it. Two questions:
- How to only show an image (png) on one side of a cube? Currently, it shows on all six sides.
- How to make the image smaller than the side of a cube? I used the code (below), but it tiles small images, instead of showing just one, centred.
Comment to code: I used both codes in sdf model files themselves, and in a separate .material file (see below). No success in both case.
Thank you.
Code:
Material file:
material aruco_marker_42
{
technique
{
pass
{
texture_unit
{
texture aruco_marker_42.png
scale 0.5 0.5
u_repeat 1
v_repeat 1
//filter trilinear
//max_anisotropy 8
padding 0.2
repeat_u false
repeat_v false
//wrap clamp
//wrap_s clamp
//wrap_t clamp
filtering anisotropic
max_anisotropy 8
//scale 1 1
// set wrap to "clamp" to prevent tiling
wrap s_clamp t_clamp
}
}
}
}
Model file (pasted as part of world file, contains pretty much everything I tried):
<model name='charger'>
<static>true</static>
<link name='charger_link'>
<collision name='charger_collision'>
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
</collision>
<visual name='charger_visual'>
<geometry>
<box>
<size>1 1 1</size>
<!-- size>2 2 1</size -->
</box>
</geometry>
<material>
<script>
<uri>model://aruco_markers/materials/scripts</uri>
<uri>model://aruco_markers/textures/aruco_marker_42.png</uri>
<name>aruco_marker_42</name>
<!-- texture_coordinates>
<u_scale>0.1</u_scale>
<v_scale>0.1</v_scale>
<padding>0.4</padding>
<use_interpolation>false</use_interpolation>
</texture_coordinates -->
</script>
<texture>
<!-- diffuse>my_texture</diffuse -->
<!-- padding>0.5</padding>
<!-- scale>0.5 0.5</scale>
<u_scale>0.5</u_scale>
<v_scale>0.5</v_scale -->
<!-- scale>0.5 0.5</scale -->
<scale>1 1</scale>
<u_scale>0.5</u_scale>
<v_scale>0.5</v_scale>
<repeat>0 0</repeat>
<wrap_s>clamp</wrap_s>
<wrap_t>clamp</wrap_t>
<use_texture_coords>false</use_texture_coords>
<scale>0.5 0.5</scale>
<u_scale>0.5</u_scale>
<v_scale>0.5</v_scale>
</texture>
</material>
</visual>
</link>
<pose>0 7.7 0.5 0 0 0</pose>
</model>