日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ROS探索总结(四)(五)(六)——简单的机器人仿真 创建简单的机器人模型smartcar 使用smartcar进行仿真

發布時間:2025/3/21 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ROS探索总结(四)(五)(六)——简单的机器人仿真 创建简单的机器人模型smartcar 使用smartcar进行仿真 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ROS探索總結(四)——簡單的機器人仿真



前邊我們已經介紹了ROS的基本情況,以及新手入門ROS的初級教程,現在就要真正的使用ROS進入機器人世界了。接下來我們涉及到的很多例程都是《ROS by Example》這本書的內容,我是和群里的幾個人一起從國外的亞馬遜上買到的,還是很有參考價值的,不過前提是你已經熟悉之前的新手教程了。

一、ROS by Example


? ? ? ? 這本書是關于國外關于ROS出版的第一本書,主要針對Electric和Fuerte版本,使用機器人主要是TurtleBot。書中詳細講解了關于機器人的基本仿真、導航、路徑規劃、圖像處理、語音識別等等,而且在google的svn上發布了所有代碼,可以通過以下命令下載、編譯: [plain]?view plaincopy
  • svn?checkout?http://ros-by-example.googlecode.com/svn/trunk/rbx_vol_1??
  • rosmake?rbx_vol_1??
  • rospack?profile??????????//加入ROS?package路徑??


  • 二、rviz簡單機器人模擬

    ? ? ? ?1、安裝機器人模擬器 ? ? ? ? ? ? ? ? ? ? ??

    ? ? ? ?rviz是一個顯示機器人實體的工具,本身不具有模擬的功能,需要安裝一個模擬器arbotix。 [plain]?view plaincopy
  • svn?checkout?http://vanadium-ros-pkg.googlecode.com/svn/trunk/arbotix??
  • rosmake?arbotix??

  • ? ? ? ?

    ? ? ? ?2、TurtleBot機器人的模擬

    ? ? ? ?在書中的rbx_vol_1包里已經為我們寫好了模擬的代碼,我們先進行實驗,完成后再仔細研究代碼。
    ? ? ? ?機器人模擬運行:
    [plain]?view plaincopy
  • roscore??
  • roslaunch?rbx1_bringup?fake_pi_robot.launch??

  • ? ? ? ?然后在終端中可以看到,機器人已經開始運行了,打開rviz界面,才能看到機器人實體。 [plain]?view plaincopy
  • rosrun?rviz?rviz?-d?`rospack?find?rbx1_nav`/sim_fuerte.vcg??

  • ? ? ? ?后面的參數是加載了rviz的配置文件sim_fuerte.vcg。效果如下: ??
    ? ? ? ?此時的機器人是靜止的,需要發布一個消息才能讓它動起來。 [plain]?view plaincopy
  • rostopic?pub?-r?10?/cmd_vel?geometry_msgs/Twist?'{linear:?{x:?0.2,?y:?0,?z:?0},?angular:?{x:?0,?y:?0,?z:?0.5}}'??


  • ? ? ? ? ? ? ? ?如果要讓機器人停下來,需要在中斷中按下“Ctrl+c”,然后輸入: [plain]?view plaincopy
  • rostopic?pub?-1?/cmd_vel?geometry_msgs/Twist?'{}'??

  • ? ? ? ?也可以改變發送的topic信息,使機器人走出不同的軌跡。

    三、實現分析

    ? ? ? ?按照上面的仿真過程,我們詳細分析每一步的代碼實現。 ??

    ? ? ? ?1、TurtleBot機器人運行

    ? ? ? ?機器人運行使用的是launch文件,首先打開fake_turtlebot.launch文件。? [plain]?view plaincopy
  • <launch>??
  • ??<param?name="/use_sim_time"?value="false"?/>??
  • ??
  • ??<!--?Load?the?URDF/Xacro?model?of?our?robot?-->??
  • ??<arg?name="urdf_file"?default="$(find?xacro)/xacro.py?'$(find?turtlebot_description)/urdf/turtlebot.urdf.xacro'"?/>??
  • ?????
  • ??<param?name="robot_description"?command="$(arg?urdf_file)"?/>??
  • ??????
  • ??<node?name="arbotix"?pkg="arbotix_python"?type="driver.py"?output="screen">??
  • ??????<rosparam?file="$(find?rbx1_bringup)/config/fake_turtlebot_arbotix.yaml"?command="load"?/>??
  • ??????<param?name="sim"?value="true"/>??
  • ??</node>??
  • ????
  • ??<node?name="robot_state_publisher"?pkg="robot_state_publisher"?type="state_publisher">??
  • ??????<param?name="publish_frequency"?type="double"?value="20.0"?/>??
  • ??</node>??
  • ????
  • ??<!--?We?need?a?static?transforms?for?the?wheels?-->??
  • ??<node?pkg="tf"?type="static_transform_publisher"?name="odom_left_wheel_broadcaster"?args="0?0?0?0?0?0?/base_link?/left_wheel_link?100"?/>??
  • ??<node?pkg="tf"?type="static_transform_publisher"?name="odom_right_wheel_broadcaster"?args="0?0?0?0?0?0?/base_link?/right_wheel_link?100"?/>??
  • ??
  • </launch>??

  • ? ? ? ? 文件可以大概分為四個部分:
    ? ? ? ? (1) 從指定的包中加載urdf文件
    ? ? ? ? (2) 啟動arbotix模擬器
    ? ? ? ? (3) 啟動狀態發布節點
    ? ? ? ? (4) tf坐標系配置

    2、rviz配置文件

    ? ? ? ?在打開rviz的時候需要加載一個.vcg的配置文件,主要對rviz中的插件選項進行默認的配置。這里打開的是sim_fuerte.vcg文件,由于文件比較長,這里只列舉重點的部分。 [plain]?view plaincopy
  • Background\?ColorB=0.12549??
  • Background\?ColorG=0.12549??
  • Background\?ColorR=0.12549??
  • Camera\?Config=158.108?0.814789?0.619682?-1.57034??
  • Camera\?Type=rviz::FixedOrientationOrthoViewController??
  • Fixed\?Frame=/odom??
  • Grid.Alpha=0.5??
  • Grid.Cell\?Size=0.5??
  • Grid.ColorB=0.941176??
  • Grid.ColorG=0.941176??
  • Grid.ColorR=0.941176??
  • Grid.Enabled=1??
  • Grid.Line\?Style=0??
  • Grid.Line\?Width=0.03??
  • Grid.Normal\?Cell\?Count=0??
  • Grid.OffsetX=0??
  • Grid.OffsetY=0??
  • Grid.OffsetZ=0??
  • Grid.Plane=0??



  • ? ? ? ? 上面的代碼是配置背景顏色和網格屬性的,對應rviz中的選項如下圖所示。 ? ? ? ?? ? ? ? ? 其中比較重要的一個選項是Camera的type,這個選項是控制開發者的觀察角度的,書中用的是FixedOrientationOrthoViewController的方式,就是上面圖中的俯視角度,無法看到機器人的三維全景,所以可以改為OrbitViewController方式,如下圖所示:

    3、發布topic

    ? ? ? ? 要讓機器人動起來,還需要給他一些運動需要的信息,這些信息都是通過topic的方式發布的。
    ? ? ? ? 這里的topic就是速度命令,針對這個topic,我們需要發布速度的信息,在ROS中已經為我們寫好了一些可用的數據結構,這里用的是Twist信息的數據結構。在終端中可以看到Twist的結構如下:
    ? ? ? ? ? ? ?? ? ? ? ??用下面的命令進行消息的發布,其中主要包括力的大小和方向。 [plain]?view plaincopy
  • Background\?ColorB=0.12549??
  • Background\?ColorG=0.12549??
  • Background\?ColorR=0.12549??
  • Camera\?Config=158.108?0.814789?0.619682?-1.57034??
  • Camera\?Type=rviz::FixedOrientationOrthoViewController??
  • Fixed\?Frame=/odom??
  • Grid.Alpha=0.5??
  • Grid.Cell\?Size=0.5??
  • Grid.ColorB=0.941176??
  • Grid.ColorG=0.941176??
  • Grid.ColorR=0.941176??
  • Grid.Enabled=1??
  • Grid.Line\?Style=0??
  • Grid.Line\?Width=0.03??
  • Grid.Normal\?Cell\?Count=0??
  • Grid.OffsetX=0??
  • Grid.OffsetY=0??
  • Grid.OffsetZ=0??
  • Grid.Plane=0??



  • 4、節點關系圖


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




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


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

    一、創建硬件描述包

    [plain]?view plaincopy
  • roscreat-pkg??smartcar_description??urdf??


  • 二、智能車尺寸數據

    ? ? ? ? 因為建立的是一個非常簡單的機器人,所以我們盡量使用簡單的元素:使用長方體代替車模,使用圓柱代替車輪,具體尺寸如下:

    三、建立urdf文件

    ? ? ? ? 在smartcar_description文件夾下建立urdf文件夾,創建智能車的描述文件smartcar.urdf,描述代碼如下: [plain]?view plaincopy
  • <?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,描述代碼如下: [plain]?view plaincopy
  • <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>??

  • 五、效果演示

    ? ? ? ? 在終端中輸入顯示命令: [plain]?view plaincopy
  • roslaunch??smartcar_description??base.urdf.rviz.launch??gui:=true??


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


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






    ROS探索總結(六)——使用smartcar進行仿真



    之前的博客中,我們使用rviz進行了TurtleBot的仿真,而且使用urdf文件建立了自己的機器人smartcar,本篇博客是將兩者進行結合,使用smartcar機器人在rviz中進行仿真。

    一、模型完善

    ? ? ? ? 之前我們使用的都是urdf文件格式的模型,在很多情況下,ROS對urdf文件的支持并不是很好,使用宏定義的.xacro文件兼容性更好,擴展性也更好。所以我們把之前的urdf文件重新整理編寫成.xacro文件。
    ? ? ? ? .xacro文件主要分為三部分:

    1、機器人主體

    [plain]?view plaincopy
  • <?xml?version="1.0"?>??
  • <robot?name="smartcar"?xmlns:xacro="http://ros.org/wiki/xacro">??
  • ??<property?name="M_PI"?value="3.14159"/>??
  • ??
  • ??<!--?Macro?for?SmartCar?body.?Including?Gazebo?extensions,?but?does?not?include?Kinect?-->??
  • ??<include?filename="$(find?smartcar_description)/urdf/gazebo.urdf.xacro"/>??
  • ??
  • ??<property?name="base_x"?value="0.33"?/>??
  • ??<property?name="base_y"?value="0.33"?/>??
  • ??
  • ??<xacro:macro?name="smartcar_body">??
  • ??
  • ??
  • ????<link?name="base_link">??
  • ????<inertial>??
  • ??????<origin?xyz="0?0?0.055"/>??
  • ??????<mass?value="1.0"?/>??
  • ??????<inertia?ixx="1.0"?ixy="0.0"?ixz="0.0"?iyy="1.0"?iyz="0.0"?izz="1.0"/>??
  • ????</inertial>??
  • ????<visual>??
  • ??????<geometry>??
  • ????????<box?size="0.25?.16?.05"/>??
  • ??????</geometry>??
  • ??????<origin?rpy="0?0?0"?xyz="0?0?0.055"/>??
  • ??????<material?name="blue">??
  • ??????<color?rgba="0?0?.8?1"/>??
  • ??????</material>??
  • ???</visual>??
  • ???<collision>??
  • ??????<origin?rpy="0?0?0"?xyz="0?0?0.055"/>??
  • ??????<geometry>??
  • ????????<box?size="0.25?.16?.05"?/>??
  • ??????</geometry>??
  • ????</collision>??
  • ??</link>??
  • ??
  • ??
  • ?<link?name="left_front_wheel">??
  • ????<inertial>??
  • ??????<origin??xyz="0.08?0.08?0.025"/>??
  • ??????<mass?value="0.1"?/>??
  • ???????<inertia?ixx="1.0"?ixy="0.0"?ixz="0.0"?iyy="1.0"?iyz="0.0"?izz="1.0"/>??
  • ????</inertial>??
  • ????<visual>??
  • ??????<geometry>??
  • ????????<cylinder?length=".02"?radius="0.025"/>??
  • ??????</geometry>??
  • ??????<material?name="black">??
  • ????????<color?rgba="0?0?0?1"/>??
  • ??????</material>??
  • ????</visual>??
  • ????<collision>??
  • ??????<origin?rpy="0?1.57075?1.57075"?xyz="0.08?0.08?0.025"/>??
  • ??????<geometry>??
  • ?????????<cylinder?length=".02"?radius="0.025"/>??
  • ??????</geometry>??
  • ????</collision>??
  • ??</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?1.57075"?xyz="0.08?0.08?0.025"/>??
  • ????<limit?effort="100"?velocity="100"/>??
  • ????<joint_properties?damping="0.0"?friction="0.0"/>??
  • ??</joint>??
  • ??
  • ??<link?name="right_front_wheel">??
  • ????<inertial>??
  • ??????<origin?xyz="0.08?-0.08?0.025"/>??
  • ??????<mass?value="0.1"?/>??
  • ???????<inertia?ixx="1.0"?ixy="0.0"?ixz="0.0"?iyy="1.0"?iyz="0.0"?izz="1.0"/>??
  • ????</inertial>??
  • ????<visual>??
  • ??????<geometry>??
  • ????????<cylinder?length=".02"?radius="0.025"/>??
  • ??????</geometry>??
  • ??????<material?name="black">??
  • ????????<color?rgba="0?0?0?1"/>??
  • ??????</material>??
  • ????</visual>??
  • ????<collision>??
  • ??????<origin?rpy="0?1.57075?1.57075"?xyz="0.08?-0.08?0.025"/>??
  • ??????<geometry>??
  • ?????????<cylinder?length=".02"?radius="0.025"/>??
  • ??????</geometry>??
  • ????</collision>??
  • ??</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?1.57075"?xyz="0.08?-0.08?0.025"/>??
  • ????<limit?effort="100"?velocity="100"/>??
  • ????<joint_properties?damping="0.0"?friction="0.0"/>??
  • ?</joint>??
  • ??
  • ?<link?name="left_back_wheel">??
  • ????<inertial>??
  • ??????<origin?xyz="-0.08?0.08?0.025"/>??
  • ??????<mass?value="0.1"?/>??
  • ???????<inertia?ixx="1.0"?ixy="0.0"?ixz="0.0"?iyy="1.0"?iyz="0.0"?izz="1.0"/>??
  • ????</inertial>??
  • ????<visual>??
  • ??????<geometry>??
  • ????????<cylinder?length=".02"?radius="0.025"/>??
  • ??????</geometry>??
  • ??????<material?name="black">??
  • ????????<color?rgba="0?0?0?1"/>??
  • ??????</material>??
  • ???</visual>??
  • ???<collision>??
  • ???????<origin?rpy="0?1.57075?1.57075"?xyz="-0.08?0.08?0.025"/>??
  • ??????<geometry>??
  • ?????????<cylinder?length=".02"?radius="0.025"/>??
  • ??????</geometry>??
  • ????</collision>??
  • ??</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?1.57075"?xyz="-0.08?0.08?0.025"/>??
  • ????<limit?effort="100"?velocity="100"/>??
  • ????<joint_properties?damping="0.0"?friction="0.0"/>??
  • ??</joint>??
  • ??
  • ??<link?name="right_back_wheel">??
  • ????<inertial>??
  • ???????<origin?xyz="-0.08?-0.08?0.025"/>??
  • ???????<mass?value="0.1"?/>??
  • ???????<inertia?ixx="1.0"?ixy="0.0"?ixz="0.0"?iyy="1.0"?iyz="0.0"?izz="1.0"/>??
  • ????</inertial>??
  • ????<visual>??
  • ??????<geometry>??
  • ????????<cylinder?length=".02"?radius="0.025"/>??
  • ??????</geometry>??
  • ??????<material?name="black">??
  • ????????<color?rgba="0?0?0?1"/>??
  • ??????</material>??
  • ???</visual>??
  • ???<collision>??
  • ??????<origin?rpy="0?1.57075?1.57075"?xyz="-0.08?-0.08?0.025"/>??
  • ??????<geometry>??
  • ?????????<cylinder?length=".02"?radius="0.025"/>??
  • ??????</geometry>??
  • ????</collision>??
  • ??</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?1.57075"?xyz="-0.08?-0.08?0.025"/>??
  • ????<limit?effort="100"?velocity="100"/>??
  • ????<joint_properties?damping="0.0"?friction="0.0"/>??
  • ??</joint>??
  • ??
  • ??<link?name="head">??
  • ????<inertial>??
  • ??????<origin?xyz="0.08?0?0.08"/>??
  • ??????<mass?value="0.1"?/>??
  • ??????<inertia?ixx="1.0"?ixy="0.0"?ixz="0.0"?iyy="1.0"?iyz="0.0"?izz="1.0"/>??
  • ????</inertial>??
  • ????<visual>??
  • ??????<geometry>??
  • ????????<box?size=".02?.03?.03"/>??
  • ??????</geometry>??
  • ??????<material?name="white">??
  • ????????<color?rgba="1?1?1?1"/>??
  • ??????</material>??
  • ?????</visual>??
  • ?????<collision>??
  • ??????<origin?xyz="0.08?0?0.08"/>??
  • ??????<geometry>??
  • ?????????<cylinder?length=".02"?radius="0.025"/>??
  • ??????</geometry>??
  • ????</collision>??
  • ??</link>??
  • ??
  • ??<joint?name="tobox"?type="fixed">??
  • ????<parent?link="base_link"/>??
  • ????<child?link="head"/>??
  • ????<origin?xyz="0.08?0?0.08"/>??
  • ??</joint>??
  • ??</xacro:macro>??
  • ??
  • </robot>??

  • 2、gazebo屬性部分

    [plain]?view plaincopy
  • <?xml?version="1.0"?>??
  • ??
  • <robot?xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"???
  • ????xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"???
  • ????xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"???
  • ????xmlns:xacro="http://ros.org/wiki/xacro"???
  • ????name="smartcar_gazebo">??
  • ??
  • <!--?ASUS?Xtion?PRO?camera?for?simulation?-->??
  • <!--?gazebo_ros_wge100?plugin?is?in?kt2_gazebo_plugins?package?-->??
  • <xacro:macro?name="smartcar_sim">??
  • ????<gazebo?reference="base_link">??
  • ????????<material>Gazebo/Blue</material>??
  • ????</gazebo>??
  • ??
  • ????<gazebo?reference="right_front_wheel">??
  • ????????<material>Gazebo/FlatBlack</material>??
  • ????</gazebo>??
  • ??
  • ????<gazebo?reference="right_back_wheel">??
  • ????????<material>Gazebo/FlatBlack</material>??
  • ????</gazebo>??
  • ??
  • ????<gazebo?reference="left_front_wheel">??
  • ????????<material>Gazebo/FlatBlack</material>??
  • ????</gazebo>??
  • ??
  • ????<gazebo?reference="left_back_wheel">??
  • ????????<material>Gazebo/FlatBlack</material>??
  • ????</gazebo>??
  • ??
  • ????<gazebo?reference="head">??
  • ????????<material>Gazebo/White</material>??
  • ????</gazebo>??
  • ??
  • </xacro:macro>??
  • ??
  • </robot>??

  • 3、主文件

    [cpp]?view plaincopy
  • <span?style="font-size:14px;"><?xml?version="1.0"?>??
  • ??
  • <robot?name="smartcar"????
  • ????xmlns:xi="http://www.w3.org/2001/XInclude"??
  • ????xmlns:gazebo="http://playerstage.sourceforge.net/gazebo/xmlschema/#gz"??
  • ????xmlns:model="http://playerstage.sourceforge.net/gazebo/xmlschema/#model"??
  • ????xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"??
  • ????xmlns:body="http://playerstage.sourceforge.net/gazebo/xmlschema/#body"??
  • ????xmlns:geom="http://playerstage.sourceforge.net/gazebo/xmlschema/#geom"??
  • ????xmlns:joint="http://playerstage.sourceforge.net/gazebo/xmlschema/#joint"??
  • ????xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"??
  • ????xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"??
  • ????xmlns:rendering="http://playerstage.sourceforge.net/gazebo/xmlschema/#rendering"??
  • ????xmlns:renderable="http://playerstage.sourceforge.net/gazebo/xmlschema/#renderable"??
  • ????xmlns:physics="http://playerstage.sourceforge.net/gazebo/xmlschema/#physics"??
  • ????xmlns:xacro="http://ros.org/wiki/xacro">??
  • ??
  • ??<include?filename="$(find?smartcar_description)/urdf/smartcar_body.urdf.xacro"?/>??
  • ??
  • ??<!--?Body?of?SmartCar,?with?plates,?standoffs?and?Create?(including?sim?sensors)?-->??
  • ??<smartcar_body/>??
  • ??
  • ??<smartcar_sim/>??
  • ??
  • </robot></span>??



  • 二、lanuch文件

    ? ? ? ? 在launch文件中要啟動節點和模擬器。 [plain]?view plaincopy
  • <launch>??
  • ????<param?name="/use_sim_time"?value="false"?/>??
  • ??????
  • ????<!--?Load?the?URDF/Xacro?model?of?our?robot?-->??
  • ????<arg?name="urdf_file"?default="$(find?xacro)/xacro.py?'$(find?smartcar_description)/urdf/smartcar.urdf.xacro'"?/>??
  • ????<arg?name="gui"?default="false"?/>??
  • ??
  • ????<param?name="robot_description"?command="$(arg?urdf_file)"?/>??
  • ????<param?name="use_gui"?value="$(arg?gui)"/>??
  • ??
  • ????<node?name="arbotix"?pkg="arbotix_python"?type="driver.py"?output="screen">??
  • ????????<rosparam?file="$(find?smartcar_description)/config/smartcar_arbotix.yaml"?command="load"?/>??
  • ????????<param?name="sim"?value="true"/>??
  • ????</node>??
  • ??
  • ????<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">??
  • ????????<param?name="publish_frequency"?type="double"?value="20.0"?/>??
  • ????</node>??
  • ??
  • ?????<!--?We?need?a?static?transforms?for?the?wheels?-->??
  • ????<node?pkg="tf"?type="static_transform_publisher"?name="odom_left_wheel_broadcaster"?args="0?0?0?0?0?0?/base_link?/left_front_link?100"?/>??
  • ????<node?pkg="tf"?type="static_transform_publisher"?name="odom_right_wheel_broadcaster"?args="0?0?0?0?0?0?/base_link?/right_front_link?100"?/>??
  • ??
  • ????<node?name="rviz"?pkg="rviz"?type="rviz"?args="-d?$(find?smartcar_description)/urdf.vcg"?/>??
  • </launch>??

  • 三、仿真測試

    ? ? ? ? 首先運行lanuch,既可以看到rviz中的機器人:
    [plain]?view plaincopy
  • roslaunch?smartcar_description?smartcar_display.rviz.launch??

  • 發布一條動作的消息。 [plain]?view plaincopy
  • rostopic?pub?-r?10?/cmd_vel?geometry_msgs/Twist?'{linear:?{x:?0.5,?y:?0,?z:?0},?angular:?{x:?0,?y:?0,?z:?0.5}}'??

  • 四、節點關系


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



    歡迎大家轉載我的文章。

    轉載請注明:轉自古-月

    http://blog.csdn.net/hcx25909


    總結

    以上是生活随笔為你收集整理的ROS探索总结(四)(五)(六)——简单的机器人仿真 创建简单的机器人模型smartcar 使用smartcar进行仿真的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。