我正在使用 ROS2/Gazebo 项目。在 Gazebo 中,我有一个立方体,我想在上面做一个 aruco 标记。 两个问题:
代码注释:我在 sdf 模型文件本身和单独的 .material 文件中使用了这两种代码(见下文)。两种情况都没有成功。
谢谢。
代码:
材料文件:
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 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>
我在项目中使用的解决方法是定义一个非常薄的立方体,我将 QR 码用作纹理。为了证明这个肮脏的把戏是合理的,我把它想象成一张打印出来并贴在盒子上的纸。这个解决方法实际上可以解决你的两个问题。
另一种方法是创建一个盒子的 COLLADA (.dae) 模型,只在一侧应用适当的纹理。 在这里您可以在示例中看到它是如何完成的。
不完全是一个漂亮的解决方案,但绝对有效:我们合并两个形状,一个有标记,一个更大,没有一个:
<model name='charger'>
<!-- default_parameters>
<sdf_param> tag_scaling_factor_x 0.4 </sdf_param>
</default_parameters -->
<static>true</static>
<link name='charger_body_link'>
<collision name='charger_body_collision'>
<geometry>
<box>
<size>0.5 0.5 1</size>
</box>
</geometry>
</collision>
<visual name='charger_body_visual'>
<geometry>
<box>
<size>0.5 0.5 1</size>
</box>
</geometry>
</visual>
</link>
<link name='aruco_marker_link'>
<collision name='aruco_marker_collision'>
<geometry>
<box>
<size>0.1 0.01 0.1</size>
</box>
</geometry>
</collision>
<visual name='charger_visual'>
<geometry>
<box>
<size>0.2 0.01 0.2</size>
<!-- size>${tag_scaling_factor_x} 0.01 ${tag_scaling_factor_z}</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>
</script>
</material>
<pose>0 -0.25 0.15 0 0 0</pose>
</visual>
</link>
<pose>0 7.7 0.5 0 0 0</pose>
</model>