当前位置:   article > 正文

如何在Gazebo环境中显示自己编写的urdf文件_编辑好的urdf文件为啥不能在gazebo中显gazebo已经打开了

编辑好的urdf文件为啥不能在gazebo中显gazebo已经打开了

1.获取要显示物体的三维数据

通过Blender或SolidWorks等三维建模软件进行编辑,得到物体的.dae或.stl格式的文件。

2.编写urdf文件

  1. <?xml version="1.0"?>
  2. <robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="soup_can">
  3. <property name="M_PI" value="3.141592654" />
  4. <xacro:macro name="soup_can">
  5. <link name="soup_can_link">
  6. <collision>
  7. <origin xyz="0 0 0" rpy="0 0 0"/>
  8. <geometry>
  9. <mesh filename="package://gazebo_ur5_kinect_sim/urdf/meshes/soup_can.dae" />
  10. </geometry>
  11. </collision>
  12. <visual>
  13. <origin xyz="0 0 0" rpy="0 0 0"/>
  14. <geometry>
  15. <mesh filename="package://gazebo_ur5_kinect_sim/urdf/meshes/soup_can.dae" />
  16. </geometry>
  17. <material name="">
  18. <color rgba="0.0 0.0 0.5 1" />
  19. </material>
  20. </visual>
  21. <inertial>
  22. <mass value="0.0855" />
  23. <origin xyz="0 0 0" rpy="0 0 0"/>
  24. <inertia ixx="0.00007900658" ixy="0" ixz="0" iyy="0.00007900658" iyz="0" izz="0.0000491287275" />
  25. </inertial>
  26. </link>
  27. <gazebo reference="soup_can_link">
  28. <!-- <material>Gazebo/Blue</material> -->
  29. </gazebo>
  30. </xacro:macro>
  31. </robot>

文件名称为soup_can.urdf.xacro。

上述代码的意思是将该物体作为一个link进行编写,<geometry>中描述了物体的大小及形状,<visual>中描述了该物体的色彩等信息,<inertial>用来描述物体的惯性矩阵。

3.编写Gazebo环境下物体的urdf文件

  1. <?xml version="1.0"?>
  2. <robot xmlns:xacro="http://wiki.ros.org/xacro" name="xxt_soup_can">
  3. <xacro:include filename="$(find gazebo_ur5_kinect_sim)/urdf/soup_can/soup_can.urdf.xacro" />
  4. <xacro:soup_can />
  5. </robot>

文件名称为 soup_can_gazebo.xacro。

4.创建一个Gazebo中需要的的world

  1. <?xml version="1.0" ?>
  2. <sdf version="1.6">
  3. <world name="default">
  4. <include>
  5. <uri>model://sun</uri>
  6. </include>
  7. <include>
  8. <uri>model://ground_plane</uri>
  9. </include>
  10. </world>
  11. </sdf>

文件名称为test.world。 

5.编写launch文件,在Gazebo中显示出来

  1. <?xml version="1.0"?>
  2. <launch>
  3. <include file="$(find gazebo_ros)/launch/empty_world.launch">
  4. <!-- <arg name="world_name" value="$(find experiment)/world/gravity_free.world"/> -->
  5. <!-- <arg name="world_name" default="worlds/empty.world"/> -->
  6. <arg name="world_name" default="$(find gazebo_ur5_kinect_sim)/world/test.world" />
  7. </include>
  8. <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find gazebo_ur5_kinect_sim)/urdf/soup_can/soup_can_gazebo.xacro'" />
  9. <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
  10. <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
  11. <node name="spawn_gazebo_model" pkg="gazebo_ros" type="spawn_model" args="-y 0.0 -z 0.5 -urdf -param robot_description -model robot " respawn="false" output="screen" />
  12. <!-- <node name="spawn_sdf" pkg="gazebo_ros" type="spawn_model" args="-file $(find robot_sim)/camera_calibration/urdf/small_checkerboard.sdf -sdf -model small_checkerboard -x -0.03 -y -0.03 -z 0.2" /> -->
  13. </launch>

文件名称为soup_can_world.launch。

其中spawn_gazebo_model用于加载物体,并调整物体的初始位置,与是否加载模型。

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/979084
推荐阅读
相关标签
  

闽ICP备14008679号