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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

ROS Gazebo(三):启动gazebo/URDF

發布時間:2025/6/17 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ROS Gazebo(三):启动gazebo/URDF 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

打開Gazebo的方式主要有兩種:rosrun 和 roslaunch。

1、啟動ROS節點

啟動ROS節點、bring up 機器人的標準工具是roslaunch。打開一個空的Gazebo世界命令如下:

roslaunch gazebo_ros empty_world.launch

參數:

  • paused
    在暫停狀態打開Gazebo (default false)
  • use_sim_time
    節點啟動模擬時間,啟動主題topic /clock (default true)
  • gui
    啟動Gazebo用戶接口 (default true)
  • headless
    禁止仿真器調用任何渲染組件。不能在gui:=true (default false)是使用
  • debug
    用gdb (default false)調試模式啟動 gzserver (Gazebo Server)

例如:

roslaunch gazebo_ros empty_world.launch paused:=true use_sim_time:=false gui:=true throttled:=false headless:=false debug:=true

2、demo 環境

還有一些demo可以直接使用,它們在包含在gazebo_ros功能包中,包括:

roslaunch gazebo_ros willowgarage_world.launch roslaunch gazebo_ros mud_world.launch roslaunch gazebo_ros shapes_world.launch roslaunch gazebo_ros rubble_world.launch

注意在mud_world.launch中,加入了一個機械關節,文件如下:

<!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched --><include file="$(find gazebo_ros)/launch/empty_world.launch"><arg name="world_name" value="worlds/mud.world"/> <!-- Note: the world_name is with respect to GAZEBO_RESOURCE_PATH environmental variable --><arg name="paused" value="false"/><arg name="use_sim_time" value="true"/><arg name="gui" value="true"/><arg name="headless" value="false"/><arg name="debug" value="false"/></include> </launch>

所有的文件都繼承了empty.world,只改變了一個參數:world_name。

3、創建Gazebo ROS Package

1、建立工作空間

/home/user/catkin_ws/src

2、編寫sdf文件

文件夾目錄如下:

../catkin_ws/src/MYROBOT_descriptionpackage.xmlCMakeLists.txt/urdfMYROBOT.urdf/meshesmesh1.daemesh2.dae.../materials/cad/MYROBOT_gazebo/launchMYROBOT.launch/worldsMYROBOT.world/modelsworld_object1.daeworld_object2.stlworld_object3.urdf/materials/plugins

3、創建通用的 World 文件

  • 創建ROS功能包

  • 創建launch文件夾

  • 創建 YOUROBOT.launch 文件

<launch><!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched --><include file="$(find gazebo_ros)/launch/empty_world.launch"><arg name="world_name" value="$(find MYROBOT_gazebo)/worlds/MYROBOT.world"/><!-- more default parameters can be changed here --></include> </launch>
  • 創建MYROBOT.world 文件
<?xml version="1.0" ?> <sdf version="1.4"><world name="default"><include><uri>model://ground_plane</uri></include><include><uri>model://sun</uri></include><include><uri>model://gas_station</uri><name>gas_station</name><pose>-2.0 7.0 0 0 0 0</pose></include></world> </sdf>
  • 運行文件
. ~/catkin_ws/devel/setup.bash roslaunch MYROBOT_gazebo MYROBOT.launch

4、加載 URDF 模型

如何把自己建立的URDF模型添加到gazebo環境中?

利用 roslaunch,有兩種方法:

  • ROS Service Call Spawn Method

這種方法保持ROS軟件包在不同電腦間輕松移植。只要軟件包在一個ROS包路徑中即可。不過要求編寫一個ROS service call腳本。

  • Model Database Method

只要放置在默認的數據庫路徑中,或者自己建立一個數據庫,并把它包含在環境變量中


1、ROS Service Call

利用 pawn_model腳本向 gazebo_ros 節點(在主題中,空間名為”gazebo” )發出服務請求,進而添加 URDF 到 Gazebo 中。

rosrun gazebo_ros spawn_model -file `rospack find MYROBOT_description`/urdf/MYROBOT.urdf -urdf -x 0 -y 0 -z 1 -model MYROBOT

如果是.xacro,可以轉化為 urdf 文件:

rosrun xacro xacro.py `rospack find pr2_description`/robots/pr2.urdf.xacro -o /tmp/pr2.urdf

查看其關節圖:

check_urdf pr2.urdf urdf_to_graphiz pr2.urdfcd ~ rosrun tf view_frames evince frames.pdf

查看 pawn_model的所有參數,可以運行:

rosrun gazebo_ros spawn_model -h

在 launch文件中,可以編寫為形如:

<!-- Spawn a robot into Gazebo --> <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-file $(find baxter_description)/urdf/baxter.urdf -urdf -z 1 -model baxter" />

例子:

<!-- Convert an xacro and put on parameter server --> <param name="robot_description" command="$(find xacro)/xacro.py $(find pr2_description)/robots/pr2.urdf.xacro" /><!-- Spawn a robot into Gazebo --> <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -model pr2" />

2、Model Database

此種方法需要編輯 sdf 文件,官方的模型都是采用的這種方法。

參考

https://bitbucket.org/osrf/gazebo_models/downloads/
http://gazebosim.org
http://wiki.ros.org/urdf

總結

以上是生活随笔為你收集整理的ROS Gazebo(三):启动gazebo/URDF的全部內容,希望文章能夠幫你解決所遇到的問題。

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