ROS Gazebo(三):启动gazebo/URDF
来源:互联网 发布:武汉市广电网络分公司 编辑:程序博客网 时间:2024/04/30 08:21
打开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.launchroslaunch gazebo_ros mud_world.launchroslaunch gazebo_ros shapes_world.launchroslaunch 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_description package.xml CMakeLists.txt /urdf MYROBOT.urdf /meshes mesh1.dae mesh2.dae ... /materials /cad /MYROBOT_gazebo /launch MYROBOT.launch /worlds MYROBOT.world /models world_object1.dae world_object2.stl world_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.bashroslaunch 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.urdfurdf_to_graphiz pr2.urdfcd ~rosrun tf view_framesevince 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
- 学习ROS笔记之Using A URDF In Gazebo
- 【ROS Gazebo专题】三、Gazebo的使用下
- ROS Gazebo(二):概述
- ROS Gazebo(五):ros_control和gazebo仿真总结
- ROS Gazebo(四):ROS Control
- Using a URDF in Gazebo
- GAZEBO
- Gazebo
- gazebo
- gazebo
- gazebo
- ROS学习--(十九)使用Gazebo模拟器
- 安装ros、gazebo、moveit(rviz)
- ROS Gazebo(一):安装与使用
- ROS-NAOqi(rviz moveit gazebo等)
- ROS-NAOqi(rviz moveit gazebo等)
- interface Gazebo and ROS.
- Java集合类详解
- 获取当前年月日 时分秒
- Python基础数据结构之数据转换(Dict,Set,Tuple,List)
- 解读彩色工业相机中的拜耳(Bayer)变换
- Java的getCanonicalName和getName
- ROS Gazebo(三):启动gazebo/URDF
- 15. 3Sum
- sqoop常用指令
- C# 计算角度
- 品牌形象设计:企业品牌定名要领
- 机器学习之性能度量
- python变量
- C++进阶
- [NOIP2013] 花匠&积木大赛 贪心水题