实验设备:虚拟机+ubuntu18.04+gazebo9
实验中使用的是aruco图片,在下面网站中找到在线aruco生成.svg矢量图。GitHub - okalachev/arucogen: Online ArUco markers generatorOnline ArUco markers generator. Contribute to okalachev/arucogen development by creating an account on GitHub.https://github.com/okalachev/arucogen
通过svgtopng网站转成png图片。
待放置的图片保存到/usr/share/gazebo-9/media/materials/textures中。
在/usr/share/gazebo-9/media/materials/scripts中写入aruco.material文件。
cd /usr/share/gazebo-9/media/materials/scripts
sudo gedit ./aruco.material
aruco.material:
import * from "grid.material"
material Gazebo/aruco-36
{
receive_shadows on
technique
{
pass
{
ambient 0.5 0.5 0.5 1.000000
texture_unit
{
texture aruco-36.png
filtering anistropic
max_anisotropy 16
}
}
}
}
1、在world文件中使用:
<link name='marker'>
<collision name='marker_Collision'>
<geometry>
<box>
<size>0.2 0.005 0.2</size>
</box>
</geometry>
<pose frame=''>0 0 0.05 0 -0 0</pose>
<max_contacts>10</max_contacts>
<surface>
<contact>
<ode/>
</contact>
<bounce/>
<friction>
<torsional>
<ode/>
</torsional>
<ode/>
</friction>
</surface>
</collision>
<visual name='marker_Visual'>
<pose frame=''>0 0 0.05 0 -0 0</pose>
<geometry>
<box>
<size>0.1 0.001 0.1</size>
</box>
</geometry>
<material>
<script>
<uri>file://usr/share/gazebo-9/media/materials/scripts/aruco.material</uri>
<name>Gazebo/aruco-36</name>
</script>
<ambient>1 1 1 1</ambient>
</material>
<meta>
<layer>0</layer>
</meta>
</visual>
<pose frame=''>0 0 0 0 -0 0</pose>
<self_collide>0</self_collide>
<enable_wind>0</enable_wind>
<kinematic>0</kinematic>
</link>
实际效果:
2、在xacro文件中使用:将图片的box连接固定在机器人尖端部分上(直接将图片链接到连接体)
<link name="marker1">
<visual>
<origin xyz="0 0 0.05" rpy = "0 0 0"/>
<geometry>
<box size="0.2 0.005 0.2"/>
</geometry>
</visual>
</link>
<gazebo reference="marker1">
<material>Gazebo/aruco-36</material>
</gazebo>
<joint name="marker_joint" type="fixed">
<parent link="tool0"/>
<child link="marker1"/>
<origin xyz="0 0 0.01" rpy="${pi/2} 0 ${pi/2}"/>
</joint>
实际效果: