使用launch文件启动gazebo加载world模型,或者说是将world模型加入gazebo仿真器中作为环境。

first,我们应该告诉gazebo 要加载的world文件放在哪里。并通过arg标签,设置此world文件加载时的参数。

  <!-- 设置launch文件的参数 --> <arg name="world_name" value="$(find mbot_gazebo)/worlds/playground.world"/><arg name="paused" default="false"/><arg name="use_sim_time" default="true"/><arg name="gui" default="true"/><arg name="headless" default="false"/><arg name="debug" default="false"/>

roslaunch Arguments(参数说明)

You can append the following arguments to the launch files to change the behavior of Gazebo:
paused
Start Gazebo in a paused state (default false)
use_sim_time
Tells ROS nodes asking for time to get the Gazebo-published simulation time, published over the ROS topic /clock (default true)
gui
Launch the user interface window of Gazebo (default true)
headless (deprecated) recording (previously called headless)
Enable gazebo state log recording
debug
Start gzserver (Gazebo Server) in debug mode using gdb (default false)
verbose
Run gzserver and gzclient with --verbose, printing errors and warnings to the terminal (default false)

除了上述几个,还有一个最重要的就是world_name参数,此参数用于加载其他的world模型。

第二步,我们应该通过include empty_world.launch文件,加载上述world文件,并将上面所设置的参数传递给empty_world文件中。

  <!-- 运行gazebo仿真环境 --><include file="$(find gazebo_ros)/launch/empty_world.launch"><arg name="world_name" value="$(arg world_name)" /><arg name="debug" value="$(arg debug)" /><arg name="gui" value="$(arg gui)" /><arg name="paused" value="$(arg paused)"/><arg name="use_sim_time" value="$(arg use_sim_time)"/><arg name="headless" value="$(arg headless)"/></include>

下面就要加载机器人的模型了,官网(http://gazebosim.org/tutorials?tut=ros_roslaunch)中给出来两种方法,本文中使用ROS Service Call Spawn Method,可以参考官网教程,描述如下:

The first method keeps your robot's ROS packages more portable between computers and repository check outs. It allows you to keep your robot's location relative to a ROS package path, but also requires you to make a ROS service call using a small (python) script.
This method uses a small python script called spawn_model to make a service call request to the gazebo_ros ROS node (named simply "gazebo" in the rostopic namespace) to add a custom URDF into Gazebo. The spawn_model script is located within the gazebo_ros package. You can use this script in the following way:
rosrun gazebo_ros spawn_model -file `rospack find MYROBOT_description`/urdf/MYROBOT.urdf -urdf -x 0 -y 0 -z 1 -model MYROBOT
XACRO Example with PR2
If your URDF is not in XML format but rather in XACRO format, you can make a similar modification to your launch file. You can run this PR2 example by installing this package:
ROS Jade:
sudo apt-get install ros-jade-pr2-common
Then adding this to your launch file created previously in this tutorial:
<!-- 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" />

简单来说,就是使用官方提供出的spawn_urdf节点,此节点可以将机器人导入Gazebo中。我们要做的,只是将我们需要的机器人模型传递给这个节点即可。具体做法请看下面几步:

第三步,应该加载机器人模型

 <!-- 加载机器人模型描述参数 --><param name="robot_description" command="$(find xacro)/xacro --inorder '$(find mbot_description)/urdf/xacro/gazebo/mbot_with_camera_gazebo.xacro'" />

第四步设置

  <!-- 运行joint_state_publisher节点,发布机器人的关节状态  --><node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node> <!-- 运行robot_state_publisher节点,发布tf  --><node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"  output="screen" ><param name="publish_frequency" type="double" value="50.0" /></node>

第五步,通过节点将机器人加载到gezebo中。

 <!-- 在gazebo中加载机器人模型--><node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"args="-urdf -model mbot -param robot_description"/> 

此节点的参数有:

Commands:-[urdf|gazebo] - specify incoming xml is urdf or gazebo format-[file|param] [<file_name>|<param_name>] - source of the model xml-model <model_name> - name of the model to be spawned.-reference_frame <entity_name> - optinal: name of the model/body where initial pose is defined.If left empty or specified as "world", gazebo world frame is used.-namespace <ros_namespace> - optional: all subsequent ROS interface plugins will be inside of this namespace.-x <x in meters> - optional: initial pose, use 0 if left out-y <y in meters> - optional: initial pose, use 0 if left out-z <z in meters> - optional: initial pose, use 0 if left out-R <roll in radians> - optional: initial pose, use 0 if left out-P <pitch in radians> - optional: initial pose, use 0 if left out-Y <yaw in radians> - optional: initial pose, use 0 if left out

gazebo加载world模型相关推荐

  1. Gazebo加载模型时黑屏

    Gazebo加载模型时黑屏 1. 黑屏状态 2. 解决办法1 3. 解决办法2 1. 黑屏状态 Gazebo加载模型的时候会发现一直处于这种状态 这可能是因为model库加载不正确导致的 2. 解决办 ...

  2. Gazebo仿真--加载世界模型

    加载世界模型 例子: <launch><include file="$(find gazebo_ros)/launch/empty_world.launch"&g ...

  3. ros学习记录:Gazebo加载速度慢,长时间停在“Preparing your world”

    前言 ros学习记录笔记,一个小白的自留地,欢迎大佬批评指正~ 一.问题描述 Gazebo加载速度慢,长时间停在"Preparing your world" 二.解决办法 1.下载 ...

  4. 在C++中加载TorchScript模型

    在C++中加载TorchScript模型 本教程已更新为可与PyTorch 1.2一起使用 顾名思义,PyTorch的主要接口是Python编程语言.尽管Python是合适于许多需要动态性和易于迭代的 ...

  5. xBIM 实战01 在浏览器中加载IFC模型文件

    系列目录    [已更新最新开发文章,点击查看详细]  一.创建Web项目 打开VS,新建Web项目,选择 .NET Framework 4.5  选择一个空的项目 新建完成后,项目结构如下: 二.添 ...

  6. Python时间序列模型推理预测实战:时序推理数据预处理(特征生成、lstm输入结构组织)、模型加载、模型预测结果保存、条件判断模型循环运行

    Python时间序列模型推理预测实战:时序推理数据预处理(特征生成.lstm输入结构组织).模型加载.模型预测结果保存.条件判断模型循环运行 目录

  7. threejs加载obj模型_Vulkan编程指南(章节31-载入模型)

    章节31 载入模型 介绍 本章节我们将会渲染一个带有纹理的三维模型. 库 我们使用tinyobjloader库来从OBJ文件加载顶点数据.tinyobjloader库是一个简单易用的单文件OBJ加载器 ...

  8. PaddleOCR加载chinese_ocr_db_crnn_modile模型进行中英文混合预测(Http服务)实践

    1. 环境搭建 参考:<PaddleOCR加载chinese_ocr_db_crnn_server模型进行中英文混合预测(命令行)实践> 2. 服务端部署 hub serving star ...

  9. threejs加载3D模型例子

    加载3D模型 首先要引入ColladaLoader加载器,Collada是一个3D模型交换方案,即不同的3D模型可以通过Collada进行相互转换,言外之意,threejs可以使用Collada将3D ...

最新文章

  1. 比Hadoop快至少10倍的物联网大数据平台,我把它开源了
  2. Spring Boot AJAX 示例
  3. 牛客 - 小A的回文串(Manacher模板题)
  4. 【教程】如何给Eclipse中添加库(jar包)
  5. oracle00109,ORA-01034: 、ORA-01078: 和 LRM-00109: 的解决方法,ora-01034ora-01078
  6. contes 7.6安装后网络问题解决方案
  7. 2016年第四季度思科称霸印度网络市场
  8. 用英语推销计算机设备,销售电脑的英语对话
  9. 从微软中国下载Windows系统并安装
  10. 计算机课开机心得学生,计算机课学习心得范文体会范文(精选8篇)
  11. matlab上机作业,matlab上机作业(数字信号处理)
  12. matlab dbns实现,深度置信网DBNs的源码
  13. 【题目】pyCharm 专业版 和 社区版的区别以及如何查看其版本
  14. 华硕路由器信息发现服务器,研究人员发现华硕路由器收集用户访问记录等隐私数据...
  15. MAC OS X 问题库
  16. 重磅 | 分子生物学与遗传学经典名著——《Lewin基因XII》(中译本)
  17. `泷泽萝拉.png .exe`
  18. 【BZOJ1412】【ZJOI2009】狼和羊的故事(网络流)
  19. 在硅谷,人生的可能性不只有 996
  20. oracle如果不存在则建分区,Oracle建分区表

热门文章

  1. cdr 表格自动填充文字_让人眼前一亮的WPS Office 2019的七大特色功能之表格篇
  2. 优秀技术人,如何做到高效沟通?
  3. 嵌入式C语言方面面试、笔试经典问题/题目
  4. 用CMD命令打开事件查看器
  5. 蓝宝石超频软件测试,超频测试:风冷核心频率1.15GHz
  6. Spring注解@Primary的意思
  7. Simotion TCP 通讯数据发送方式
  8. 微博自动登录与发帖(selenium+cookie)
  9. Python小项目【画玫瑰花、画生日蛋糕、】
  10. 无聊的肥宅反编译neko atsume猫咪后院 (一)