ROS(URDF机器人建模)

新建功能包mbot_description

在功能包下新建文件config,launch,meshes,urdf。

在launch文件夹下新建文件display_mbot_base_urdf.launch

 1 <launch>
 2     <param name = "robot_description" textfile = "$(find mbot_description)/urdf/mbot_base.urdf"/>
 3 
 4     <!-- 设置GUI参数,显示关节控制插件 -->
 5     <param name="use_gui" value="true"/>
 6 
 7     <!-- 运行joint_state_publisher节点,发布机器人的关节状态 -->
 8     <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
 9 
10     <!-- 运行robot_state_publisher节点,发布tf -->
11     <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
12 
13     <!-- 运行rviz可视化界面 -->
14     <node name="rviz" pkg="rviz" type="rviz" args="-d $(find mbot_description)/config/mbot_urdf.rviz" required="true" />
15 </launch>

在urdf文件夹中新建文件mbot_base.urdf

  1 <?xml version="1.0" ?>
  2 <robot name="mbot">
  3 
  4     <link name="base_link">
  5         <visual>
  6             <origin xyz=" 0 0 0" rpy="0 0 0" />
  7             <geometry>
  8                 <cylinder length="0.16" radius="0.20"/>
  9             </geometry>
 10             <material name="yellow">
 11                 <color rgba="1 0.4 0 1"/>
 12             </material>
 13         </visual>
 14     </link>
 15 
 16     <joint name="left_wheel_joint" type="continuous">
 17         <origin xyz="0 0.19 -0.05" rpy="0 0 0"/>
 18         <parent link="base_link"/>
 19         <child link="left_wheel_link"/>
 20         <axis xyz="0 1 0"/>
 21     </joint>
 22 
 23     <link name="left_wheel_link">
 24         <visual>
 25             <origin xyz="0 0 0" rpy="1.5707 0 0" />
 26             <geometry>
 27                 <cylinder radius="0.06" length = "0.025"/>
 28             </geometry>
 29             <material name="white">
 30                 <color rgba="1 1 1 0.9"/>
 31             </material>
 32         </visual>
 33     </link>
 34 
 35     <joint name="right_wheel_joint" type="continuous">
 36         <origin xyz="0 -0.19 -0.05" rpy="0 0 0"/>
 37         <parent link="base_link"/>
 38         <child link="right_wheel_link"/>
 39         <axis xyz="0 1 0"/>
 40     </joint>
 41 
 42     <link name="right_wheel_link">
 43         <visual>
 44             <origin xyz="0 0 0" rpy="1.5707 0 0" />
 45             <geometry>
 46                 <cylinder radius="0.06" length = "0.025"/>
 47             </geometry>
 48             <material name="white">
 49                 <color rgba="1 1 1 0.9"/>
 50             </material>
 51         </visual>
 52     </link>
 53 
 54     <joint name="front_caster_joint" type="continuous">
 55         <origin xyz="0.18 0 -0.095" rpy="0 0 0"/>
 56         <parent link="base_link"/>
 57         <child link="front_caster_link"/>
 58         <axis xyz="0 1 0"/>
 59     </joint>
 60 
 61     <link name="front_caster_link">
 62         <visual>
 63             <origin xyz="0 0 0" rpy="0 0 0"/>
 64             <geometry>
 65                 <sphere radius="0.015" />
 66             </geometry>
 67             <material name="black">
 68                 <color rgba="0 0 0 0.95"/>
 69             </material>
 70         </visual>
 71     </link>
 72 
 73     <joint name="back_caster_joint" type="continuous">
 74         <origin xyz="-0.18 0 -0.095" rpy="0 0 0"/>
 75         <parent link="base_link"/>
 76         <child link="back_caster_link"/>
 77         <axis xyz="0 1 0"/>
 78     </joint>
 79 
 80     <link name="back_caster_link">
 81         <visual>
 82             <origin xyz="0 0 0" rpy="0 0 0"/>
 83             <geometry>
 84                 <sphere radius="0.015" />
 85             </geometry>
 86             <material name="black">
 87                 <color rgba="0 0 0 0.95"/>
 88             </material>
 89         </visual>
 90     </link>
 91 
 92     <link name="kinect_link">
 93         <visual>
 94             <origin xyz="0 0 0" rpy="0 0 1.5708"/>
 95             <geometry>
 96                 <mesh filename="package://mbot_description/meshes/kinect.dae" />
 97             </geometry>
 98         </visual>
 99     </link>
100 
101     <joint name="laser_joint" type="fixed">
102         <origin xyz="0.15 0 0.11" rpy="0 0 0"/>
103         <parent link="base_link"/>
104         <child link="kinect_link"/>
105     </joint>
106 
107 </robot>

在meshes文件夹下有文件

通过urdf_to_graphiz命令查看URDF模型结构:

生成PDF

原文地址:https://www.cnblogs.com/112358nizhipeng/p/9469196.html