1
当前位置:   article > 正文

gazebo通过sdf搭建仿真环境和机器人Husky_husky仿真

husky仿真

具体格式要求可参考:http://sdformat.org/spec?ver=1.6&elem=sdf

  1. <?xml version="1.0" ?>
  2. <sdf version="1.5">
  3. <world name="default">
  4. <light name='sun' type='directional'>
  5. <cast_shadows>1</cast_shadows>
  6. <pose>-11.82075 -19.38429 17.2198 0 -0 0</pose>
  7. <diffuse>0.7 0.7 0.7 1</diffuse>
  8. <specular>0.2 0.2 0.2 1</specular>
  9. <attenuation>
  10. <range>1000</range>
  11. <constant>0.9</constant>
  12. <linear>0.01</linear>
  13. <quadratic>0.001</quadratic>
  14. </attenuation>
  15. <direction>0.3698 0.4 -0.5</direction>
  16. </light>
  17. <model name="ground">
  18. <static>true</static>
  19. <link name="link">
  20. <pose>-6.2343 -8.1302 0 0 -0 0</pose>
  21. <visual name="visual">
  22. <cast_shadows>false</cast_shadows>
  23. <pose>0 0 0 0 -0 0</pose>
  24. <geometry>
  25. <mesh>
  26. <uri>model://xxx_3D_visual.dae</uri>
  27. <scale>1 1 1</scale>
  28. </mesh>
  29. </geometry>
  30. </visual>
  31. <collision name="collision">
  32. <pose>0 0 0 0 0 0</pose>
  33. <geometry>
  34. <mesh>
  35. <uri>model://xxx_3D_collision.stl</uri>
  36. <scale>1 1 1</scale>
  37. </mesh>
  38. </geometry>
  39. </collision>
  40. </link>
  41. </model>
  42. <scene>
  43. <ambient>0.4 0.4 0.4 1</ambient>
  44. <background>0.7 0.7 0.7 1</background>
  45. <shadows>1</shadows>
  46. </scene>
  47. </world>
  48. </sdf>

world文件与机器人model模型属性定义类似,可以引用3D的mesh文件比如.dae .stl等作为visual或者collision,并可以定义物理环境条件等。

Husky官方地址:http://wiki.ros.org/Robots/Husky

这里的Husky模型被缩小了,比原来的机器人小很多,参数不一致!大约1/3

  1. <?xml version='1.0'?>
  2. <sdf version='1.6'>
  3. <model name='xxx_husky'>
  4. <link name='base_link'>
  5. <inertial>
  6. <mass>3.3855</mass>
  7. <pose frame=''>-0.085613 -0.00084 0.1 0 -0 0</pose>
  8. <inertia>
  9. <ixx>0.22343</ixx>
  10. <ixy>0</ixy>
  11. <ixz>0.0275174</ixz>
  12. <iyy>0.342518</iyy>
  13. <iyz>0.00023962</iyz>
  14. <izz>0.21241</izz>
  15. </inertia>
  16. </inertial>
  17. <self_collide>0</self_collide>
  18. <enable_wind>0</enable_wind>
  19. <kinematic>0</kinematic>
  20. <pose frame=''>0 0 0.02 0 -0 0</pose>
  21. <gravity>1</gravity>
  22. <visual name='body'>
  23. <pose frame=''>0 0 0 0 -0 0</pose>
  24. <geometry>
  25. <mesh>
  26. <uri>model://husky/meshes/body.dae</uri>
  27. <scale>0.33 0.33 0.3</scale>
  28. </mesh>
  29. </geometry>
  30. </visual>
  31. <collision name='collision'>
  32. <laser_retro>0</laser_retro>
  33. <max_contacts>10</max_contacts>
  34. <pose frame=''>0 0 0.05 0 -0 0</pose>
  35. <geometry>
  36. <box>
  37. <size>0.33 0.16 0.06</size>
  38. </box>
  39. </geometry>
  40. </collision>
  41. </link>
  42. <link name='back_left_wheel'>
  43. <pose frame=''>-0.09 0.1 0.035 0 -0 0</pose>
  44. <inertial>
  45. <mass>0.26357</mass>
  46. <pose frame=''>0 0 0 0 -0 0</pose>
  47. <inertia>
  48. <ixx>0.00246688</ixx>
  49. <ixy>0</ixy>
  50. <ixz>0</ixz>
  51. <iyy>0.00246688</iyy>
  52. <iyz>0</iyz>
  53. <izz>0.00441058</izz>
  54. </inertia>
  55. </inertial>
  56. <self_collide>0</self_collide>
  57. <enable_wind>0</enable_wind>
  58. <kinematic>0</kinematic>
  59. <gravity>1</gravity>
  60. <visual name='back_left_wheel'>
  61. <pose frame=''>0 0 0 0 -0 0</pose>
  62. <geometry>
  63. <mesh>
  64. <uri>model://husky/meshes/wheel.dae</uri>
  65. <scale>0.3 0.3 0.3</scale>
  66. </mesh>
  67. </geometry>
  68. </visual>
  69. <collision name='back_left_wheel_collision'>
  70. <laser_retro>0</laser_retro>
  71. <max_contacts>10</max_contacts>
  72. <pose frame=''>0 0 0 -1.5707 0 0</pose>
  73. <geometry>
  74. <cylinder>
  75. <radius>0.055</radius>
  76. <length>0.03</length>
  77. </cylinder>
  78. </geometry>
  79. <surface>
  80. <friction>
  81. <ode>
  82. <mu>0.5</mu>
  83. <mu2>50</mu2>
  84. <fdir1>0 0 0</fdir1>
  85. <slip1>0.01</slip1>
  86. <slip2>0</slip2>
  87. </ode>
  88. </friction>
  89. </surface>
  90. </collision>
  91. </link>
  92. <link name='back_right_wheel'>
  93. <pose frame=''>-0.09 -0.1 0.035 0 -0 0</pose>
  94. <inertial>
  95. <mass>0.26357</mass>
  96. <pose frame=''>0 0 0 0 -0 0</pose>
  97. <inertia>
  98. <ixx>0.00246688</ixx>
  99. <ixy>0</ixy>
  100. <ixz>0</ixz>
  101. <iyy>0.00246688</iyy>
  102. <iyz>0</iyz>
  103. <izz>0.00441058</izz>
  104. </inertia>
  105. </inertial>
  106. <self_collide>0</self_collide>
  107. <enable_wind>0</enable_wind>
  108. <kinematic>0</kinematic>
  109. <gravity>1</gravity>
  110. <visual name='back_right_wheel'>
  111. <pose frame=''>0 0 0 -3.14159 0 0</pose>
  112. <geometry>
  113. <mesh>
  114. <uri>model://husky/meshes/wheel.dae</uri>
  115. <scale>0.3 0.3 0.3</scale>
  116. </mesh>
  117. </geometry>
  118. </visual>
  119. <collision name='back_right_wheel_collision'>
  120. <laser_retro>0</laser_retro>
  121. <max_contacts>10</max_contacts>
  122. <pose frame=''>0 0 0 -1.5707 0 0</pose>
  123. <geometry>
  124. <cylinder>
  125. <radius>0.055</radius>
  126. <length>0.03</length>
  127. </cylinder>
  128. </geometry>
  129. <surface>
  130. <friction>
  131. <ode>
  132. <mu>0.5</mu>
  133. <mu2>50</mu2>
  134. <fdir1>0 0 0</fdir1>
  135. <slip1>0.01</slip1>
  136. <slip2>0</slip2>
  137. </ode>
  138. </friction>
  139. </surface>
  140. </collision>
  141. </link>
  142. <link name='front_left_wheel'>
  143. <pose frame=''>0.09 0.1 0.035 0 -0 0</pose>
  144. <inertial>
  145. <mass>0.26357</mass>
  146. <pose frame=''>0 0 0 0 -0 0</pose>
  147. <inertia>
  148. <ixx>0.00246688</ixx>
  149. <ixy>0</ixy>
  150. <ixz>0</ixz>
  151. <iyy>0.00246688</iyy>
  152. <iyz>0</iyz>
  153. <izz>0.00441058</izz>
  154. </inertia>
  155. </inertial>
  156. <self_collide>0</self_collide>
  157. <enable_wind>0</enable_wind>
  158. <kinematic>0</kinematic>
  159. <gravity>1</gravity>
  160. <visual name='front_left_wheel'>
  161. <pose frame=''>0 0 0 0 -0 0</pose>
  162. <geometry>
  163. <mesh>
  164. <uri>model://husky/meshes/wheel.dae</uri>
  165. <scale>0.3 0.3 0.3</scale>
  166. </mesh>
  167. </geometry>
  168. </visual>
  169. <collision name='front_left_wheel_collision'>
  170. <laser_retro>0</laser_retro>
  171. <max_contacts>10</max_contacts>
  172. <pose frame=''>0 0 0 -1.5707 0 0</pose>
  173. <geometry>
  174. <cylinder>
  175. <radius>0.055</radius>
  176. <length>0.03</length>
  177. </cylinder>
  178. </geometry>
  179. <surface>
  180. <friction>
  181. <ode>
  182. <mu>0.5</mu>
  183. <mu2>50</mu2>
  184. <fdir1>0 0 0</fdir1>
  185. <slip1>0.01</slip1>
  186. <slip2>0</slip2>
  187. </ode>
  188. </friction>
  189. </surface>
  190. </collision>
  191. </link>
  192. <link name='front_right_wheel'>
  193. <pose frame=''>0.09 -0.1 0.035 0 -0 0</pose>
  194. <inertial>
  195. <mass>0.26357</mass>
  196. <pose frame=''>0 0 0 0 -0 0</pose>
  197. <inertia>
  198. <ixx>0.00246688</ixx>
  199. <ixy>0</ixy>
  200. <ixz>0</ixz>
  201. <iyy>0.00246688</iyy>
  202. <iyz>0</iyz>
  203. <izz>0.00441058</izz>
  204. </inertia>
  205. </inertial>
  206. <self_collide>0</self_collide>
  207. <enable_wind>0</enable_wind>
  208. <kinematic>0</kinematic>
  209. <gravity>1</gravity>
  210. <visual name='front_right_wheel'>
  211. <pose frame=''>0 0 0 -3.14159 0 0</pose>
  212. <geometry>
  213. <mesh>
  214. <uri>model://husky/meshes/wheel.dae</uri>
  215. <scale>0.3 0.3 0.3</scale>
  216. </mesh>
  217. </geometry>
  218. </visual>
  219. <collision name='front_right_wheel_collision'>
  220. <laser_retro>0</laser_retro>
  221. <max_contacts>10</max_contacts>
  222. <pose frame=''>0 0 0 -1.5707 0 0</pose>
  223. <geometry>
  224. <cylinder>
  225. <radius>0.055</radius>
  226. <length>0.03</length>
  227. </cylinder>
  228. </geometry>
  229. <surface>
  230. <friction>
  231. <ode>
  232. <mu>0.5</mu>
  233. <mu2>50</mu2>
  234. <fdir1>0 0 0</fdir1>
  235. <slip1>0.01</slip1>
  236. <slip2>0</slip2>
  237. </ode>
  238. </friction>
  239. </surface>
  240. </collision>
  241. </link>
  242. <link name='ray_sensor'>
  243. <pose frame=''>0 0 0.09 0 -0 0</pose>
  244. <sensor name='head_hokuyo_sensor' type='ray'>
  245. <visualize>0</visualize>
  246. <update_rate>10</update_rate>
  247. <ray>
  248. <scan>
  249. <horizontal>
  250. <samples>720</samples>
  251. <resolution>1</resolution>
  252. <min_angle>-3.14159</min_angle>
  253. <max_angle>3.14159</max_angle>
  254. </horizontal>
  255. <vertical>
  256. <samples>1</samples>
  257. <min_angle>0</min_angle>
  258. <max_angle>0</max_angle>
  259. </vertical>
  260. </scan>
  261. <range>
  262. <min>0.1</min>
  263. <max>16</max>
  264. <resolution>0.01</resolution>
  265. </range>
  266. <noise>
  267. <type>gaussian</type>
  268. <mean>0</mean>
  269. <stddev>0.01</stddev>
  270. </noise>
  271. </ray>
  272. <plugin name='gazebo_ros_head_hokuyo_controller' filename='libgazebo_ros_laser.so'>
  273. <topicName>laser_scan</topicName>
  274. <frameName>base_link</frameName>
  275. </plugin>
  276. </sensor>
  277. <self_collide>0</self_collide>
  278. <inertial>
  279. <pose frame=''>0 0 0 0 -0 0</pose>
  280. <inertia>
  281. <ixx>1</ixx>
  282. <ixy>0</ixy>
  283. <ixz>0</ixz>
  284. <iyy>1</iyy>
  285. <iyz>0</iyz>
  286. <izz>1</izz>
  287. </inertia>
  288. <mass>1</mass>
  289. </inertial>
  290. <enable_wind>0</enable_wind>
  291. <kinematic>0</kinematic>
  292. <gravity>1</gravity>
  293. <visual name='ray_sensor_visual'>
  294. <pose frame=''>0 0 0 1.5708 0 -1.5708</pose>
  295. <geometry>
  296. <mesh>
  297. <uri>model://husky/meshes/eye_vision_camera.dae</uri>
  298. <scale>0.2 0.2 0.2</scale>
  299. </mesh>
  300. </geometry>
  301. </visual>
  302. <collision name='ray_sensor_collision'>
  303. <laser_retro>0</laser_retro>
  304. <max_contacts>10</max_contacts>
  305. <pose frame=''>0 0 0.015 0 -0 0</pose>
  306. <geometry>
  307. <cylinder>
  308. <radius>0.01</radius>
  309. <length>0.03</length>
  310. </cylinder>
  311. </geometry>
  312. </collision>
  313. </link>
  314. <joint name='back_left_joint' type='revolute'>
  315. <parent>base_link</parent>
  316. <child>back_left_wheel</child>
  317. <pose frame=''>0 0 0 0 -0 0</pose>
  318. <axis>
  319. <xyz>0 1 0</xyz>
  320. <use_parent_model_frame>1</use_parent_model_frame>
  321. <limit>
  322. <lower>-1e+16</lower>
  323. <upper>1e+16</upper>
  324. <effort>-1</effort>
  325. <velocity>-1</velocity>
  326. </limit>
  327. <dynamics>
  328. <spring_reference>0</spring_reference>
  329. <spring_stiffness>0</spring_stiffness>
  330. <damping>0</damping>
  331. <friction>0</friction>
  332. </dynamics>
  333. </axis>
  334. <physics>
  335. <ode>
  336. <limit>
  337. <cfm>0</cfm>
  338. <erp>0.9</erp>
  339. </limit>
  340. <suspension>
  341. <cfm>0</cfm>
  342. <erp>0.2</erp>
  343. </suspension>
  344. </ode>
  345. </physics>
  346. </joint>
  347. <joint name='back_right_joint' type='revolute'>
  348. <parent>base_link</parent>
  349. <child>back_right_wheel</child>
  350. <pose frame=''>0 0 0 0 -0 0</pose>
  351. <axis>
  352. <xyz>0 1 0</xyz>
  353. <use_parent_model_frame>1</use_parent_model_frame>
  354. <limit>
  355. <lower>-1e+16</lower>
  356. <upper>1e+16</upper>
  357. <effort>-1</effort>
  358. <velocity>-1</velocity>
  359. </limit>
  360. <dynamics>
  361. <spring_reference>0</spring_reference>
  362. <spring_stiffness>0</spring_stiffness>
  363. <damping>0</damping>
  364. <friction>0</friction>
  365. </dynamics>
  366. </axis>
  367. <physics>
  368. <ode>
  369. <limit>
  370. <cfm>0</cfm>
  371. <erp>0.9</erp>
  372. </limit>
  373. <suspension>
  374. <cfm>0</cfm>
  375. <erp>0.2</erp>
  376. </suspension>
  377. </ode>
  378. </physics>
  379. </joint>
  380. <joint name='front_left_joint' type='revolute'>
  381. <parent>base_link</parent>
  382. <child>front_left_wheel</child>
  383. <pose frame=''>0 0 0 0 -0 0</pose>
  384. <axis>
  385. <xyz>0 1 0</xyz>
  386. <use_parent_model_frame>1</use_parent_model_frame>
  387. <limit>
  388. <lower>-1e+16</lower>
  389. <upper>1e+16</upper>
  390. <effort>-1</effort>
  391. <velocity>-1</velocity>
  392. </limit>
  393. <dynamics>
  394. <spring_reference>0</spring_reference>
  395. <spring_stiffness>0</spring_stiffness>
  396. <damping>0</damping>
  397. <friction>0</friction>
  398. </dynamics>
  399. </axis>
  400. <physics>
  401. <ode>
  402. <limit>
  403. <cfm>0</cfm>
  404. <erp>0.9</erp>
  405. </limit>
  406. <suspension>
  407. <cfm>0</cfm>
  408. <erp>0.2</erp>
  409. </suspension>
  410. </ode>
  411. </physics>
  412. </joint>
  413. <joint name='front_right_joint' type='revolute'>
  414. <parent>base_link</parent>
  415. <child>front_right_wheel</child>
  416. <pose frame=''>0 0 0 0 -0 0</pose>
  417. <axis>
  418. <xyz>0 1 0</xyz>
  419. <use_parent_model_frame>1</use_parent_model_frame>
  420. <limit>
  421. <lower>-1e+16</lower>
  422. <upper>1e+16</upper>
  423. <effort>-1</effort>
  424. <velocity>-1</velocity>
  425. </limit>
  426. <dynamics>
  427. <spring_reference>0</spring_reference>
  428. <spring_stiffness>0</spring_stiffness>
  429. <damping>0</damping>
  430. <friction>0</friction>
  431. </dynamics>
  432. </axis>
  433. <physics>
  434. <ode>
  435. <limit>
  436. <cfm>0</cfm>
  437. <erp>0.9</erp>
  438. </limit>
  439. <suspension>
  440. <cfm>0</cfm>
  441. <erp>0.2</erp>
  442. </suspension>
  443. </ode>
  444. </physics>
  445. </joint>
  446. <joint name='ray_sensor_joint' type='fixed'>
  447. <parent>base_link</parent>
  448. <child>ray_sensor</child>
  449. <pose frame=''>0 0 0 0 -0 0</pose>
  450. <physics>
  451. <ode>
  452. <limit>
  453. <cfm>0</cfm>
  454. <erp>0.2</erp>
  455. </limit>
  456. <suspension>
  457. <cfm>0</cfm>
  458. <erp>0.2</erp>
  459. </suspension>
  460. </ode>
  461. </physics>
  462. </joint>
  463. <static>0</static>
  464. <allow_auto_disable>1</allow_auto_disable>
  465. <plugin name='husky_diff_controller' filename='libhusky_gazebo_plugins.so'>
  466. <alwaysOn>1</alwaysOn>
  467. <updateRate>50.0</updateRate>
  468. <backLeftJoint>back_left_joint</backLeftJoint>
  469. <backRightJoint>back_right_joint</backRightJoint>
  470. <frontLeftJoint>front_left_joint</frontLeftJoint>
  471. <frontRightJoint>front_right_joint</frontRightJoint>
  472. <wheelSeparation>0.2</wheelSeparation>
  473. <wheelDiameter>0.11</wheelDiameter>
  474. <torque>5</torque>
  475. </plugin>
  476. <plugin name='p3d_base_controller' filename='libgazebo_ros_p3d.so'>
  477. <alwaysOn>1</alwaysOn>
  478. <updateRate>50.0</updateRate>
  479. <bodyName>base_link</bodyName>
  480. <topicName>base_pose_ground_truth</topicName>
  481. <gaussianNoise>0</gaussianNoise>
  482. <frameName>map</frameName>
  483. <xyzOffsets>0 0 0</xyzOffsets>
  484. <rpyOffsets>0 0 0</rpyOffsets>
  485. </plugin>
  486. </model>
  487. </sdf>

model.sdf文件一般保存到.gazebo/models/中。

可以在gazeb中使用model editor进行编辑和查看

如何启动world文件:rosrun gazebo_ros gazebo xxx.world

然后加载机器人模型!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/379151
推荐阅读
相关标签