创建简单的机器人模型smartcar
生活随笔
收集整理的這篇文章主要介紹了
创建简单的机器人模型smartcar
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前面我們使用的是已有的機器人模型進行仿真,這一節我們將建立一個簡單的智能車機器人 smartcar,為后面建立復雜機器人打下基礎。
一、創建硬件描述包.
cd ~/catkin_ws/src
roscreat-pkg smartcar_description urdf
因為建立的是一個非常簡單的機器人,所以我們盡量使用簡單的元素:使用長方體代替車模,使用圓柱代替車輪,具體尺寸如下:
三 、 建 立 urdf 文 件
在 smartcar_description 文件夾下建立 urdf 文件夾,創建智能車的描述文件smartcar.urdf
cd smartcar_description
mkdir urdf
cd urdf
touch 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
cd ../smartcar_description mkdir launch cd launch touch 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.rviz"/>
</launch>
五、效果演示
在終端中輸入顯示命令:
roslaunch smartcar_description base.urdf.rviz.launch gui:=true
顯示效果如下圖所示,使用 gui 中的控制 bar 可以控制四個輪子單獨旋轉。
總結
以上是生活随笔為你收集整理的创建简单的机器人模型smartcar的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: yo angualr-fullstatc
- 下一篇: 什么是vue?