系统相关
首页 > 系统相关> > ubuntu16.04 ROS 之 URDF (一)

ubuntu16.04 ROS 之 URDF (一)

作者:互联网

1. URDF文件简介

1.1 简介

1.2 URDF描述规范

1.3 各个语句含义

2. 建模

2.1 创建简单的机器人模型–四轮小车

sudo apt-get install ros-kinetic-urdf-tutorial
mkdir myrobot/src -p
cd myrobot/src
catkin_init_workspace
cd ..
catkin_make
cd  ~/myrobot/src/
catkin_create_pkg smartcar std_msgs rospy roscpp urdf
cd smartcar
mkdir urdf&launch
cd urdf 
gedit myrobot.urdf
<robot name="test_robot">  
  <link name="base_link">  
    <visual>  
       <geometry>  
         <box size="0.2 .3 .1"/>  
       </geometry>  
       <origin rpy="0 0 0" xyz="0 0 0.05"/>  
       <material name="white">  
         <color rgba="1 1 1 1"/>  
       </material>  
    </visual>  
  </link>  
  
  <link name="wheel_1">  
    <visual>  
      <geometry>  
        <cylinder length="0.05" radius="0.05"/>  
      </geometry>  
      <origin rpy="0 1.5 0" xyz="0.1 0.1 0"/>  
      <material name="black">  
        <color rgba="0 0 0 1"/>  
      </material>  
    </visual>  
  </link>  
  
  <link name="wheel_2">  
    <visual>  
      <geometry>  
        <cylinder length="0.05" radius="0.05"/>  
      </geometry>  
      <origin rpy="0 1.5 0" xyz="-0.1 0.1 0"/>  
      <material name="black"/>  
    </visual>  
  </link>  
  
  <link name="wheel_3">  
    <visual>  
      <geometry>  
        <cylinder length="0.05" radius="0.05"/>  
      </geometry>  
      <origin rpy="0 1.5 0" xyz="0.1 -0.1 0"/>  
      <material name="black"/>  
    </visual>  
  </link>  
  
  <link name="wheel_4">  
    <visual>  
      <geometry>  
        <cylinder length="0.05" radius="0.05"/>  
      </geometry>  
      <origin rpy="0 1.5 0" xyz="-0.1 -0.1 0"/>  
      <material name="black"/>  
    </visual>  
  </link>  
  
  <joint name="joint_base_wheel1" type="fixed">  
    <parent link="base_link"/>  
    <child link="wheel_1"/>  
  </joint>  
  
  <joint name="joint_base_wheel2" type="fixed">  
    <parent link="base_link"/>  
    <child link="wheel_2"/>  
  </joint>  
  
  <joint name="joint_base_wheel3" type="fixed">  
    <parent link="base_link"/>  
    <child link="wheel_3"/>  
  </joint>  
  
  <joint name="joint_base_wheel4" type="fixed">  
    <parent link="base_link"/>  
    <child link="wheel_4"/>  
  </joint>  
</robot> 
check_urdf 01_skeleton.urdf  

3. 书写launch 文件

<!-- -->
<launch>
        <param name="robot_description"
        textfile="$(find little_car)/urdf/car01.urdf"/>   // 这一行需要更改为自己urdf文件所在位置
        
        <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>
        
		<node name="rviz" pkg="rviz" type="rviz" respawn="false" output="screen"/>
</launch>

4. 启动launch

roslaunch smartcar car01.launch

4.1 在rviz里面将Fixed Frame 改为: base_link

4.2 点击Add添加 Robotmodel 即可查看自己构建的模型

在这里插入图片描述

标签:ubuntu16.04,URDF,catkin,文件,urdf,launch,cd,ROS,myrobot
来源: https://blog.csdn.net/qq_40660130/article/details/113606444