博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用Gazebo导入world环境与机器人
阅读量:4083 次
发布时间:2019-05-25

本文共 3578 字,大约阅读时间需要 11 分钟。

转载自:

使用Gazebo导入world环境与机器人

AI Robotic

1.首先应该通过gazebo建立一个世界模型,然后导出成一个以.world为后缀的文件。

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

这一步是重点!

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

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文件中。

 

下面就要加载机器人的模型了,官网()中给出来两种方法,本文中使用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 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中。我们要做的,只是将我们需要的机器人模型传递给这个节点即可。具体做法请看下面几步:

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

第四步设置

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

此节点的参数有:

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

 

发布于 2019-11-06

你可能感兴趣的文章
Linux下用math.h头文件
查看>>
Linux中用st_mode判断文件类型
查看>>
Ubuntu修改host遇到unable to resolve host
查看>>
路由选择算法
查看>>
Objective-C 基础入门(一)
查看>>
Objective-C 基础入门(三) 读写文件与回调
查看>>
C++ STL标准库与泛型编程(一)概述
查看>>
C++ STL标准库与泛型编程(四)Deque、Queue、Stack 深度探索
查看>>
C++ STL标准库 算法
查看>>
JVM内存模型_Minor GC笔记
查看>>
SpringCloud学习之PassCloud——(一)PassCloud源代码下载
查看>>
Linux下安装Python环境并部署NLP项目
查看>>
Nginx篇-springCloud配置Gateway+Nginx进行反向代理和负载均衡
查看>>
Nginx篇-Nginx配置动静分离
查看>>
缓存篇-Redis缓存失效以及解决方案
查看>>
缓存篇-使用Redis进行分布式锁应用
查看>>
缓存篇-Redisson的使用
查看>>
phpquery抓取网站内容简单介绍
查看>>
找工作准备的方向(4月22日写的)
查看>>
关于fwrite写入文件后打开查看是乱码的问题
查看>>