赞
踩
通过Blender或SolidWorks等三维建模软件进行编辑,得到物体的.dae或.stl格式的文件。
- <?xml version="1.0"?>
- <robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="soup_can">
- <property name="M_PI" value="3.141592654" />
- <xacro:macro name="soup_can">
- <link name="soup_can_link">
- <collision>
- <origin xyz="0 0 0" rpy="0 0 0"/>
- <geometry>
- <mesh filename="package://gazebo_ur5_kinect_sim/urdf/meshes/soup_can.dae" />
- </geometry>
- </collision>
-
- <visual>
- <origin xyz="0 0 0" rpy="0 0 0"/>
- <geometry>
- <mesh filename="package://gazebo_ur5_kinect_sim/urdf/meshes/soup_can.dae" />
- </geometry>
- <material name="">
- <color rgba="0.0 0.0 0.5 1" />
- </material>
- </visual>
-
- <inertial>
- <mass value="0.0855" />
- <origin xyz="0 0 0" rpy="0 0 0"/>
- <inertia ixx="0.00007900658" ixy="0" ixz="0" iyy="0.00007900658" iyz="0" izz="0.0000491287275" />
- </inertial>
-
- </link>
-
- <gazebo reference="soup_can_link">
- <!-- <material>Gazebo/Blue</material> -->
- </gazebo>
-
- </xacro:macro>
-
- </robot>

文件名称为soup_can.urdf.xacro。
上述代码的意思是将该物体作为一个link进行编写,<geometry>中描述了物体的大小及形状,<visual>中描述了该物体的色彩等信息,<inertial>用来描述物体的惯性矩阵。
- <?xml version="1.0"?>
- <robot xmlns:xacro="http://wiki.ros.org/xacro" name="xxt_soup_can">
-
- <xacro:include filename="$(find gazebo_ur5_kinect_sim)/urdf/soup_can/soup_can.urdf.xacro" />
- <xacro:soup_can />
-
- </robot>
文件名称为 soup_can_gazebo.xacro。
- <?xml version="1.0" ?>
-
- <sdf version="1.6">
- <world name="default">
-
- <include>
- <uri>model://sun</uri>
- </include>
- <include>
- <uri>model://ground_plane</uri>
- </include>
-
- </world>
- </sdf>
文件名称为test.world。
- <?xml version="1.0"?>
- <launch>
- <include file="$(find gazebo_ros)/launch/empty_world.launch">
- <!-- <arg name="world_name" value="$(find experiment)/world/gravity_free.world"/> -->
- <!-- <arg name="world_name" default="worlds/empty.world"/> -->
- <arg name="world_name" default="$(find gazebo_ur5_kinect_sim)/world/test.world" />
-
- </include>
-
-
- <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find gazebo_ur5_kinect_sim)/urdf/soup_can/soup_can_gazebo.xacro'" />
-
- <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
- <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
-
- <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" />
-
- <!-- <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" /> -->
-
- </launch>
-

文件名称为soup_can_world.launch。
其中spawn_gazebo_model用于加载物体,并调整物体的初始位置,与是否加载模型。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。