实验四 蓝桥ROS1三维建模与仿真 适用kinetic/melodic/noetic

举报
zhangrelay 发表于 2022/05/13 22:11:53 2022/05/13
【摘要】 需要先完成实验1+2+3,不要直接看本实验。 实验三补充: 要求: 自定义机器人3D模型,创建一个URDF文件、xacro文件、Gazebo仿真 环境: www.lanqiao.cn/courses/854 记录: 实验四补充 由于时间紧,实验复习聚焦到urdf+Gazebo。 tree: s...

需要先完成实验1+2+3,不要直接看本实验。

实验三补充:


要求:

自定义机器人3D模型,创建一个URDF文件、xacro文件、Gazebo仿真

环境:

www.lanqiao.cn/courses/854


记录:

实验四补充

由于时间紧,实验复习聚焦到urdf+Gazebo。

tree:

shiyanlou:urdf/ $ roslaunch urdf_tutorial display.launch model:=07-physics.urdf 

urdf:


  
  1. <?xml version="1.0"?>
  2. <robot name="physics">
  3. <material name="blue">
  4. <color rgba="0 0 0.8 1"/>
  5. </material>
  6. <material name="black">
  7. <color rgba="0 0 0 1"/>
  8. </material>
  9. <material name="white">
  10. <color rgba="1 1 1 1"/>
  11. </material>
  12. <link name="base_link">
  13. <visual>
  14. <geometry>
  15. <cylinder length="0.6" radius="0.2"/>
  16. </geometry>
  17. <material name="blue"/>
  18. </visual>
  19. <collision>
  20. <geometry>
  21. <cylinder length="0.6" radius="0.2"/>
  22. </geometry>
  23. </collision>
  24. <inertial>
  25. <mass value="10"/>
  26. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  27. </inertial>
  28. </link>
  29. <link name="right_leg">
  30. <visual>
  31. <geometry>
  32. <box size="0.6 0.1 0.2"/>
  33. </geometry>
  34. <origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
  35. <material name="white"/>
  36. </visual>
  37. <collision>
  38. <geometry>
  39. <box size="0.6 0.1 0.2"/>
  40. </geometry>
  41. <origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
  42. </collision>
  43. <inertial>
  44. <mass value="10"/>
  45. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  46. </inertial>
  47. </link>
  48. <joint name="base_to_right_leg" type="fixed">
  49. <parent link="base_link"/>
  50. <child link="right_leg"/>
  51. <origin xyz="0 -0.22 0.25"/>
  52. </joint>
  53. <link name="right_base">
  54. <visual>
  55. <geometry>
  56. <box size="0.4 0.1 0.1"/>
  57. </geometry>
  58. <material name="white"/>
  59. </visual>
  60. <collision>
  61. <geometry>
  62. <box size="0.4 0.1 0.1"/>
  63. </geometry>
  64. </collision>
  65. <inertial>
  66. <mass value="10"/>
  67. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  68. </inertial>
  69. </link>
  70. <joint name="right_base_joint" type="fixed">
  71. <parent link="right_leg"/>
  72. <child link="right_base"/>
  73. <origin xyz="0 0 -0.6"/>
  74. </joint>
  75. <link name="right_front_wheel">
  76. <visual>
  77. <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  78. <geometry>
  79. <cylinder length="0.1" radius="0.035"/>
  80. </geometry>
  81. <material name="black"/>
  82. </visual>
  83. <collision>
  84. <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  85. <geometry>
  86. <cylinder length="0.1" radius="0.035"/>
  87. </geometry>
  88. </collision>
  89. <inertial>
  90. <mass value="1"/>
  91. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  92. </inertial>
  93. </link>
  94. <joint name="right_front_wheel_joint" type="continuous">
  95. <axis rpy="0 0 0" xyz="0 1 0"/>
  96. <parent link="right_base"/>
  97. <child link="right_front_wheel"/>
  98. <origin rpy="0 0 0" xyz="0.133333333333 0 -0.085"/>
  99. </joint>
  100. <link name="right_back_wheel">
  101. <visual>
  102. <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  103. <geometry>
  104. <cylinder length="0.1" radius="0.035"/>
  105. </geometry>
  106. <material name="black"/>
  107. </visual>
  108. <collision>
  109. <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  110. <geometry>
  111. <cylinder length="0.1" radius="0.035"/>
  112. </geometry>
  113. </collision>
  114. <inertial>
  115. <mass value="1"/>
  116. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  117. </inertial>
  118. </link>
  119. <joint name="right_back_wheel_joint" type="continuous">
  120. <axis rpy="0 0 0" xyz="0 1 0"/>
  121. <parent link="right_base"/>
  122. <child link="right_back_wheel"/>
  123. <origin rpy="0 0 0" xyz="-0.133333333333 0 -0.085"/>
  124. </joint>
  125. <link name="left_leg">
  126. <visual>
  127. <geometry>
  128. <box size="0.6 0.1 0.2"/>
  129. </geometry>
  130. <origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
  131. <material name="white"/>
  132. </visual>
  133. <collision>
  134. <geometry>
  135. <box size="0.6 0.1 0.2"/>
  136. </geometry>
  137. <origin rpy="0 1.57075 0" xyz="0 0 -0.3"/>
  138. </collision>
  139. <inertial>
  140. <mass value="10"/>
  141. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  142. </inertial>
  143. </link>
  144. <joint name="base_to_left_leg" type="fixed">
  145. <parent link="base_link"/>
  146. <child link="left_leg"/>
  147. <origin xyz="0 0.22 0.25"/>
  148. </joint>
  149. <link name="left_base">
  150. <visual>
  151. <geometry>
  152. <box size="0.4 0.1 0.1"/>
  153. </geometry>
  154. <material name="white"/>
  155. </visual>
  156. <collision>
  157. <geometry>
  158. <box size="0.4 0.1 0.1"/>
  159. </geometry>
  160. </collision>
  161. <inertial>
  162. <mass value="10"/>
  163. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  164. </inertial>
  165. </link>
  166. <joint name="left_base_joint" type="fixed">
  167. <parent link="left_leg"/>
  168. <child link="left_base"/>
  169. <origin xyz="0 0 -0.6"/>
  170. </joint>
  171. <link name="left_front_wheel">
  172. <visual>
  173. <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  174. <geometry>
  175. <cylinder length="0.1" radius="0.035"/>
  176. </geometry>
  177. <material name="black"/>
  178. </visual>
  179. <collision>
  180. <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  181. <geometry>
  182. <cylinder length="0.1" radius="0.035"/>
  183. </geometry>
  184. </collision>
  185. <inertial>
  186. <mass value="1"/>
  187. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  188. </inertial>
  189. </link>
  190. <joint name="left_front_wheel_joint" type="continuous">
  191. <axis rpy="0 0 0" xyz="0 1 0"/>
  192. <parent link="left_base"/>
  193. <child link="left_front_wheel"/>
  194. <origin rpy="0 0 0" xyz="0.133333333333 0 -0.085"/>
  195. </joint>
  196. <link name="left_back_wheel">
  197. <visual>
  198. <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  199. <geometry>
  200. <cylinder length="0.1" radius="0.035"/>
  201. </geometry>
  202. <material name="black"/>
  203. </visual>
  204. <collision>
  205. <origin rpy="1.57075 0 0" xyz="0 0 0"/>
  206. <geometry>
  207. <cylinder length="0.1" radius="0.035"/>
  208. </geometry>
  209. </collision>
  210. <inertial>
  211. <mass value="1"/>
  212. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  213. </inertial>
  214. </link>
  215. <joint name="left_back_wheel_joint" type="continuous">
  216. <axis rpy="0 0 0" xyz="0 1 0"/>
  217. <parent link="left_base"/>
  218. <child link="left_back_wheel"/>
  219. <origin rpy="0 0 0" xyz="-0.133333333333 0 -0.085"/>
  220. </joint>
  221. <joint name="gripper_extension" type="prismatic">
  222. <parent link="base_link"/>
  223. <child link="gripper_pole"/>
  224. <limit effort="1000.0" lower="-0.38" upper="0" velocity="0.5"/>
  225. <origin rpy="0 0 0" xyz="0.19 0 0.2"/>
  226. </joint>
  227. <link name="gripper_pole">
  228. <visual>
  229. <geometry>
  230. <cylinder length="0.2" radius="0.01"/>
  231. </geometry>
  232. <origin rpy="0 1.57075 0 " xyz="0.1 0 0"/>
  233. </visual>
  234. <collision>
  235. <geometry>
  236. <cylinder length="0.2" radius="0.01"/>
  237. </geometry>
  238. <origin rpy="0 1.57075 0 " xyz="0.1 0 0"/>
  239. </collision>
  240. <inertial>
  241. <mass value="0.05"/>
  242. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  243. </inertial>
  244. </link>
  245. <joint name="left_gripper_joint" type="revolute">
  246. <axis xyz="0 0 1"/>
  247. <limit effort="1000.0" lower="0.0" upper="0.548" velocity="0.5"/>
  248. <origin rpy="0 0 0" xyz="0.2 0.01 0"/>
  249. <parent link="gripper_pole"/>
  250. <child link="left_gripper"/>
  251. </joint>
  252. <link name="left_gripper">
  253. <visual>
  254. <origin rpy="0.0 0 0" xyz="0 0 0"/>
  255. <geometry>
  256. <mesh filename="package://urdf_tutorial/meshes/l_finger.dae"/>
  257. </geometry>
  258. </visual>
  259. <collision>
  260. <geometry>
  261. <mesh filename="package://urdf_tutorial/meshes/l_finger.dae"/>
  262. </geometry>
  263. <origin rpy="0.0 0 0" xyz="0 0 0"/>
  264. </collision>
  265. <inertial>
  266. <mass value="0.05"/>
  267. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  268. </inertial>
  269. </link>
  270. <joint name="left_tip_joint" type="fixed">
  271. <parent link="left_gripper"/>
  272. <child link="left_tip"/>
  273. </joint>
  274. <link name="left_tip">
  275. <visual>
  276. <origin rpy="0.0 0 0" xyz="0.09137 0.00495 0"/>
  277. <geometry>
  278. <mesh filename="package://urdf_tutorial/meshes/l_finger_tip.dae"/>
  279. </geometry>
  280. </visual>
  281. <collision>
  282. <geometry>
  283. <mesh filename="package://urdf_tutorial/meshes/l_finger_tip.dae"/>
  284. </geometry>
  285. <origin rpy="0.0 0 0" xyz="0.09137 0.00495 0"/>
  286. </collision>
  287. <inertial>
  288. <mass value="0.05"/>
  289. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  290. </inertial>
  291. </link>
  292. <joint name="right_gripper_joint" type="revolute">
  293. <axis xyz="0 0 -1"/>
  294. <limit effort="1000.0" lower="0.0" upper="0.548" velocity="0.5"/>
  295. <origin rpy="0 0 0" xyz="0.2 -0.01 0"/>
  296. <parent link="gripper_pole"/>
  297. <child link="right_gripper"/>
  298. </joint>
  299. <link name="right_gripper">
  300. <visual>
  301. <origin rpy="-3.1415 0 0" xyz="0 0 0"/>
  302. <geometry>
  303. <mesh filename="package://urdf_tutorial/meshes/l_finger.dae"/>
  304. </geometry>
  305. </visual>
  306. <collision>
  307. <geometry>
  308. <mesh filename="package://urdf_tutorial/meshes/l_finger.dae"/>
  309. </geometry>
  310. <origin rpy="-3.1415 0 0" xyz="0 0 0"/>
  311. </collision>
  312. <inertial>
  313. <mass value="0.05"/>
  314. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  315. </inertial>
  316. </link>
  317. <joint name="right_tip_joint" type="fixed">
  318. <parent link="right_gripper"/>
  319. <child link="right_tip"/>
  320. </joint>
  321. <link name="right_tip">
  322. <visual>
  323. <origin rpy="-3.1415 0 0" xyz="0.09137 0.00495 0"/>
  324. <geometry>
  325. <mesh filename="package://urdf_tutorial/meshes/l_finger_tip.dae"/>
  326. </geometry>
  327. </visual>
  328. <collision>
  329. <geometry>
  330. <mesh filename="package://urdf_tutorial/meshes/l_finger_tip.dae"/>
  331. </geometry>
  332. <origin rpy="-3.1415 0 0" xyz="0.09137 0.00495 0"/>
  333. </collision>
  334. <inertial>
  335. <mass value="0.05"/>
  336. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  337. </inertial>
  338. </link>
  339. <link name="head">
  340. <visual>
  341. <geometry>
  342. <sphere radius="0.2"/>
  343. </geometry>
  344. <material name="white"/>
  345. </visual>
  346. <collision>
  347. <geometry>
  348. <sphere radius="0.2"/>
  349. </geometry>
  350. </collision>
  351. <inertial>
  352. <mass value="2"/>
  353. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  354. </inertial>
  355. </link>
  356. <joint name="head_swivel" type="continuous">
  357. <parent link="base_link"/>
  358. <child link="head"/>
  359. <axis xyz="0 0 1"/>
  360. <origin xyz="0 0 0.3"/>
  361. </joint>
  362. <link name="box">
  363. <visual>
  364. <geometry>
  365. <box size="0.08 0.08 0.08"/>
  366. </geometry>
  367. <material name="blue"/>
  368. <origin xyz="-0.04 0 0"/>
  369. </visual>
  370. <collision>
  371. <geometry>
  372. <box size="0.08 0.08 0.08"/>
  373. </geometry>
  374. </collision>
  375. <inertial>
  376. <mass value="1"/>
  377. <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
  378. </inertial>
  379. </link>
  380. <joint name="tobox" type="fixed">
  381. <parent link="head"/>
  382. <child link="box"/>
  383. <origin xyz="0.1814 0 0.1414"/>
  384. </joint>
  385. </robot>

launch:


  
  1. <launch>
  2. <arg name="model" default="$(find urdf_tutorial)/urdf/r2d2.xacro"/>
  3. <arg name="gui" default="true" />
  4. <arg name="rvizconfig" default="$(find urdf_tutorial)/rviz/urdf.rviz" />
  5. <param name="robot_description" command="$(find xacro)/xacro.py $(arg model)" />
  6. <param name="use_gui" value="$(arg gui)"/>
  7. <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
  8. <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
  9. <node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />
  10. </launch>

Gazebo: 

xacro

sudo apt install ros-kinetic-xacro

gazebo环境


思考:

1. 仿真一个四轮小机器人:

代码参考:gitcode.net/ZhangRelay/ros_book

效果如下

2. 仿真案例学习:

代码参考:gitcode.net/ZhangRelay/urdf_tutorial

效果如下


文章来源: zhangrelay.blog.csdn.net,作者:zhangrelay,版权归原作者所有,如需转载,请联系作者。

原文链接:zhangrelay.blog.csdn.net/article/details/124750233

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。