本文叙述如何直接使用Gazebo创建简单室内环境模型,并能够使用launch文件打开
一、利用Gazebo建立好环境模型
1. 打开Gazabo的编辑界面
运行如下命令后按Ctrl+B,进入到编辑界面
gazebo
2.建立简单环境模型(墙壁、门窗)
保存模型至home/用户名/.gazebo/models路径下,关闭界面
3.在场景中添加具体物体
在insert下打开保存好的模型,如下图所示
右键单击模型,选择“编辑模型”,在insert中为模型添加具体物体,如下图所示:
3.保存模型(分别存为models下的模型和.world文件)
(1)添加物体结束后保存模型至home/用户名/.gazebo/models路径下,关闭界面
(2)再次打开保存好的模型,并保存为.world文件至任意目录下
二、能够使用launch文件打开模型
(1)创建工作空间 catkin_ws_room,在工作空间中创建src文件夹,在src文件夹下创建robot_room包
catkin_create_pkg robot_room std_msgs rospy roscpp gazebo_ros gazebo_plugins
(2)在robot_room包中建立一个"worlds"的目录,用于存放需要仿真的世界文件。并在该目录下创建一个"my_study_room0a.world"(robot.world即为曾经保存好的.world文件)
(3) 编写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 robot_room)/worlds/my_study_room0a.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>
(4) 编译刷新环境,启动场景模型
$ cd ~/catkin_ws_room
$ catkin_make
$ source devel/setup.bash
$ roslaunch robot_room room.launch
即可打开场景模型
注:每次打开之前都要source一下环境:source devel/setup.bash
参考资料
gazebo入门教程(一) 安装,UI介绍
ROS进阶教程(一)Gazebo仿真平台模型搭建与修改
ROS学习【12】-----基于ubuntu16.04运用Gazebo仿真软件搭建室内环境
Gazebo仿真平台模型搭建与修改
http://wiki.ros.org/turtlebot_description通过ROS开启Gazebo的世界