ROS探索總結(五)——建立簡單的機器人模型smartcar

來源:互聯網
上載者:User

        前面我們使用的是已有的機器人模型進行模擬,這一節我們將建立一個簡單的智能車機器人smartcar,為後面建立複雜機器人打下基礎。

一、建立硬體描述包
roscreat-pkg  smartcar_description  urdf
二、智能車尺寸資料        因為建立的是一個非常簡單的機器人,所以我們盡量使用簡單的元素:使用長方體代替車模,使用圓柱代替車輪,具體尺寸如下:
三、建立urdf檔案        在smartcar_description檔案夾下建立urdf檔案夾,建立智能車的描述檔案smartcar.urdf,描述代碼如下:
<?xml version="1.0"?><robot name="smartcar">  <link name="base_link">    <visual>      <geometry>        <box size="0.25 .16 .05"/></geometry><origin rpy="0 0 1.57075" xyz="0 0 0"/>    <material name="blue"><color rgba="0 0 .8 1"/></material>    </visual> </link> <link name="right_front_wheel">    <visual>      <geometry>        <cylinder length=".02" radius="0.025"/>      </geometry>      <material name="black">        <color rgba="0 0 0 1"/>      </material>    </visual>  </link>  <joint name="right_front_wheel_joint" type="continuous">    <axis xyz="0 0 1"/>    <parent link="base_link"/>    <child link="right_front_wheel"/>    <origin rpy="0 1.57075 0" xyz="0.08 0.1 -0.03"/>    <limit effort="100" velocity="100"/>    <joint_properties damping="0.0" friction="0.0"/>  </joint>  <link name="right_back_wheel">    <visual>      <geometry>        <cylinder length=".02" radius="0.025"/>      </geometry>      <material name="black">        <color rgba="0 0 0 1"/>      </material>    </visual>  </link>  <joint name="right_back_wheel_joint" type="continuous">    <axis xyz="0 0 1"/>    <parent link="base_link"/>    <child link="right_back_wheel"/>    <origin rpy="0 1.57075 0" xyz="0.08 -0.1 -0.03"/>    <limit effort="100" velocity="100"/>    <joint_properties damping="0.0" friction="0.0"/> </joint> <link name="left_front_wheel">    <visual>      <geometry>        <cylinder length=".02" radius="0.025"/>      </geometry>      <material name="black">        <color rgba="0 0 0 1"/>      </material>    </visual>  </link>  <joint name="left_front_wheel_joint" type="continuous">    <axis xyz="0 0 1"/>    <parent link="base_link"/>    <child link="left_front_wheel"/>    <origin rpy="0 1.57075 0" xyz="-0.08 0.1 -0.03"/>    <limit effort="100" velocity="100"/>    <joint_properties damping="0.0" friction="0.0"/>  </joint>  <link name="left_back_wheel">    <visual>      <geometry>        <cylinder length=".02" radius="0.025"/>      </geometry>      <material name="black">        <color rgba="0 0 0 1"/>      </material>    </visual>  </link>  <joint name="left_back_wheel_joint" type="continuous">    <axis xyz="0 0 1"/>    <parent link="base_link"/>    <child link="left_back_wheel"/>    <origin rpy="0 1.57075 0" xyz="-0.08 -0.1 -0.03"/>    <limit effort="100" velocity="100"/>    <joint_properties damping="0.0" friction="0.0"/>  </joint>  <link name="head">    <visual>      <geometry>        <box size=".02 .03 .03"/>      </geometry>  <material name="white">  <color rgba="1 1 1 1"/>  </material>    </visual>  </link>  <joint name="tobox" type="fixed">    <parent link="base_link"/>    <child link="head"/>    <origin xyz="0 0.08 0.025"/>  </joint></robot>

四、建立launch命令檔案        在smartcar_description檔案夾下建立launch檔案夾,建立智能車的描述檔案 base.urdf.rviz.launch,描述代碼如下:

<launch><arg name="model" /><arg name="gui" default="False" /><param name="robot_description" textfile="$(find smartcar_description)/urdf/smartcar.urdf" /><param name="use_gui" value="$(arg gui)"/><node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node><node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" /><node name="rviz" pkg="rviz" type="rviz" args="-d $(find urdf_tutorial)/urdf.vcg" /></launch>

五、效果示範        在終端中輸入顯示命令:

roslaunch  smartcar_description  base.urdf.rviz.launch  gui:=true


        顯示效果如所示,使用gui中的控制bar可以控制四個輪子單獨旋轉。

----------------------------------------------------------------

歡迎大家轉載我的文章。

轉載請註明:轉自古-月

http://blog.csdn.net/hcx25909

歡迎繼續關注我的部落格

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.