Gazebo機器人仿真學習探索筆記(二)基本使用說明
来源:互联网 发布:淘宝司法拍卖房产网址 编辑:程序博客网 时间:2024/06/05 00:30
在完成Gazebo7安裝後,需要熟悉Gazebo,方便之後使用。
部分源代碼可以參考:https://bitbucket.org/osrf/gazebo/src/
如果還沒有安裝請參考之前內容完成安裝,快速打開ubuntu終端的方式(CTRL+ALT+t
):
~$ gazebo
Gazebo7自帶了很多構建好的環境模型,可以直接使用,這些模型位置和安裝路徑相關:
relaybot@relaybot-desktop:~$ ls /usr/share/gazebo-7/worlds/actor.world pioneer2dx.worldblank.world plane_demo.worldcamera.world plugin.worldcart_demo.world polyline.worldcessna_demo.world population.worldcontact.world pr2.worlddepth_camera.world presentation.worldelevator.world pressure_sensor.worldempty_1_0.world projector.worldempty_bullet.world quad_rotor_demo_2.worldempty_sky.world quad_rotor_demo.worldempty.world random_velocity.worldeverything.world ray_cpu.worldflocking.world ray_noise_plugin.worldforce_torque_demo.world road_textures.worldfriction_demo.world road.worldgripper.world robocup09_spl_field.worldheightmap_dem.world robocup14_spl_field.worldheightmap.world robocup_3Dsim.worldhydra_demo.world rubble.worldimu_demo.world seesaw.worldinitial_velocity.world shapes_bitmask.worldjoint_damping_demo.world shapes_layers.worldjoint_friction_demo.world shapes.worldjoints.world sim_events.worldlift_drag_demo.world simple_arm.worldlights.world simple_gripper.worldlinear_battery_demo.world single_rotor_demo.worldlogical_camera.world sonar_demo.worldmagnetometer.world sphere_atlas_demo.worldmud_bitmask.world stacks.worldmud.world timer_gui.worldmultilink_shape.world torsional_friction_demo.worldnested_model.world transporter.worldopenal.world trigger.worldortho.world twin_rotor_demo.worldosrf_elevator.world underwater.worldpioneer2dx_camera.world willowgarage.worldpioneer2dx_laser_camera.world wireless_sensors.worldpioneer2dx_laser.world在ubuntu下默認的路徑爲:/usr/share/gazebo-7/worlds/。
啓動一個示例,如下:
/usr/share/gazebo-7/worlds$ gazebo lift_drag_demo.world
啓動一個帶有天空的環境:
/usr/share/gazebo-7/worlds$ gazebo empty_sky.world
<?xml version="1.0" ?><sdf version="1.5"> <world name="default"> <scene> <sky> <clouds> <speed>12</speed> </clouds> </sky> </scene> <!-- A global light source --> <include> <uri>model://sun</uri> </include> <!-- A ground plane --> <include> <uri>model://ground_plane</uri> </include> </world></sdf>
注意這個環境中,天空中只有雲彩速度爲12,場景中還有光源和大地。
啓動一個帶有機器人模型的環境:
/usr/share/gazebo-7/worlds$ gazebo pioneer2dx_laser_camera.world
<?xml version="1.0" ?><sdf version="1.5"> <world name="default"> <!-- Ground --> <include> <uri>model://ground_plane</uri> </include> <!-- A global light source --> <include> <uri>model://sun</uri> </include> <!-- Pioneer2dx model --> <model name="pioneer2dx"> <include> <uri>model://pioneer2dx</uri> </include> <include> <uri>model://hokuyo</uri> <pose>0.2 0 .38 0 0 0</pose> </include> <include> <uri>model://camera</uri> <pose>0.2 0 .3 0 0 0</pose> </include> <joint name="camera_joint" type="revolute"> <parent>pioneer2dx::pioneer2dx::chassis</parent> <child>pioneer2dx::camera::link</child> <axis> <xyz>0 0 1</xyz> <limit> <lower>0</lower> <upper>0</upper> </limit> </axis> </joint> <joint name="laser_joint" type="revolute"> <parent>pioneer2dx::pioneer2dx::chassis</parent> <child>pioneer2dx::hokuyo::link</child> <axis> <xyz>0 0 1</xyz> <limit> <lower>0</lower> <upper>0</upper> </limit> </axis> </joint> </model> </world></sdf>
參考上述模板,可以學習環境文件,主要由大地,光源,機器人模型,機器人模型包括本體,激光和攝像頭等具體配置。
除此之外,還有gzserver和gzclient。
gazebo命令实际上运行两个不同的可执行文件。 第一个称为gzserver,第二个称为gzclient。
gzserver可执行程序运行物理更新循环和传感器数据生成。 这是Gazebo的核心,可以独立于图形界面使用。 您可能会在论坛中看到“run headless”这个短语。 这个短语相当于只运行gzserver。 一个示例用例将涉及在不需要用户界面的云计算机上运行gzserver。
gzclient可执行文件运行基于QT的用户界面。 此应用程序提供了一个很好的可视化的模拟,并在各种模拟属性方便的控制。
當然,這兩個可以分別啓動。
gazebo使用的快捷鍵:
Gazebo 鼠標控制
場景視角改變
注意這裏gazebo並不能與ROS通訊,如果需要可以使用下面命令:
rosrun gazebo_ros gazeborosrun gazebo_ros gzserverrosrun gazebo_ros gzclientrosrun gazebo_ros spawn_modelrosrun gazebo_ros perfrosrun gazebo_ros debug
啓動後可以看到:
~$ rostopic list /clock/gazebo/link_states/gazebo/model_states/gazebo/parameter_descriptions/gazebo/parameter_updates/gazebo/set_link_state/gazebo/set_model_state/rosout/rosout_agg具體在之後筆記中再補充。
附件:官網教程。
Run Gazebo
These three steps will run Gazebo with a default world.
Install Gazebo.
Open a terminal. On most Ubuntu systems you can press
CTRL+ALT+t
Start Gazebo by entering the following at the command prompt.
gazebo
Run Gazebo with a robot
Let's simulate something a bit more interesting by loading a world with a pioneer2dx.
Open a terminal and enter the following command.
gazebo worlds/pioneer2dx.world
Where are the worlds located?
You may have noticed the mysterious worlds/pioneer2dx.world
argument in the above command. This instructs gazebo to find the pioneer2dx.world
file, and load it on start.
World files are located in a versioned system directory, for example /usr/share/gazebo-7
on Ubuntu. If you have Gazebo 7.0 installed on Ubuntu, in a terminal type the following to see a complete list of worlds.
ls /usr/share/gazebo-7/worlds
For a Gazebo 7.0 installation on OS X using Homebrew, type the following to see a complete list of worlds.
ls /usr/local/share/gazebo-7/worlds
Client and server separation
The gazebo
command actually runs two different executables for you. Thefirst is called gzserver
, and the second gzclient
.
The gzserver
executable runs the physics update-loop and sensor datageneration. This is the core of Gazebo, and can be used independently of agraphical interface. You may see the phrase "run headless" thrown about inthe forums. This phrase equates to running only the gzserver
. An exampleuse case would involve running gzserver
on a cloud computer where a userinterface is not needed.
The gzclient
executable runs a QT based userinterface. This application provides a nice visualization of simulation, andconvenient controls over various simulation properties.
Try running each of these executables. Open a terminal and run the server:
gzserver
Open another terminal and run the graphical client:
gzclient
At this point you should see the Gazebo user interface. You restart thegzclient
application as often as you want, and even run multipleinterfaces.
This page describes each of the items involved in running a Gazebo simulation.
World Files
The world description file contains all the elements in a simulation, including robots, lights, sensors, and static objects. This file is formatted using SDF (Simulation Description Format), and typically has a .world
extension.
The Gazebo server (gzserver
) reads this file to generate and populate a world.
A number of example worlds are shipped with Gazebo. These worlds are located in <install_path>/share/gazebo-<version>/worlds
.
Model Files
A model file uses the same SDF format as world files, but should only contain a single <model> ... </model>
. The purpose of these files is to facilitate model reuse, and simplify world files. Once a model file is created, it can be included in a world file using the following SDF syntax:
<include> <uri>model://model_file_name</uri></include>
A number of models are provided in the online model database (in previous versions, some example models were shipped with Gazebo). Assuming that you have an Internet connection when running Gazebo, you can insert any model from the database and the necessary content will be downloaded at runtime.
Environment Variables
Gazebo uses a number of environment variables to locate files, and set up communications between the server and clients.
Starting with Gazebo 1.9.0, default values that work for most cases are compiled in. This means you don't need to set any variables.
Here are the variables:
GAZEBO_MODEL_PATH
: colon-separated set of directories where Gazebo will search for models
GAZEBO_RESOURCE_PATH
: colon-separated set of directories where Gazebo will search for other resources such as world and media files.
GAZEBO_MASTER_URI
: URI of the Gazebo master. This specifies the IP and port where the server will be started and tells the clients where to connect to.
GAZEBO_PLUGIN_PATH
: colon-separated set of directories where Gazebo will search for the plugin shared libraries at runtime.
GAZEBO_MODEL_DATABASE_URI
: URI of the online model database where Gazebo will download models from.
These defaults are also included in a shell script:
source <install_path>/share/gazebo/setup.sh
If you want to modify Gazebo's behavior, e.g., by extending the path it searches for models, you should first source the shell script listed above, then modify the variables that it sets.
Gazebo Server
The server is the workhorse of Gazebo. It parses a world description file given on the command line, and then simulates the world using a physics and sensor engine.
The server can be started using the following command. Note that the server does not include any graphics; it's meant to run headless.
gzserver <world_filename>
The <world_filename>
can be:
relative to the current directory,
an absolute path, or
relative to a path component in
GAZEBO_RESOURCE_PATH
.
Worlds that are shipped with Gazebo are located in <install_path>/share/gazebo-<version_number>/worlds
.
For example, to use the empty.world
which is shipped with Gazebo, use the following command
gzserver worlds/empty.world
Graphical Client
The graphical client connects to a running gzserver
and visualizes the elements. This is also a tool which allows you to modify the running simulation.
The graphical client is run using:
gzclient
Server + Graphical Client in one
The gazebo
command combines server and client in one executable. Instead of running gzserver worlds/empty.world
and then gzclient
, you can do this:
gazebo worlds/empty.world
Plugins
Plugins provide a simple and convenient mechanism to interface with Gazebo. Plugins can either be loaded on the command line, or specified in a world/model file (see the SDF format). Plugins specified on the command line are loaded first, then plugins specified in the world/model files are loaded. Most plugins are loaded by the server; however, plugins can also be loaded by the graphical client to facilitate custom GUI generation.
Example of loading a plugin on the command line:
gzserver -s <plugin_filename> <world_file>
The same mechanism is used by the graphical client:
gzclient -g <plugin_filename>
For more information refer to the plugins overview page.
Introduction
Gazebo uses a distributed architecturewith separate libraries for physics simulation,rendering, user interface, communication, and sensor generation.Additionally, gazebo provides two executable programs for running simulations:
a server
gzserver
for simulating the physics, rendering, and sensorsa client
gzclient
that provides a graphical interface tovisualize and interact with the simulation
The client and server communicate using the gazebo communication library.
Communication Between Processes
The communication library currently uses the open sourceGoogle Protobuf
for the message serializationand boost::ASIO
for the transport mechanism.It supports the publish/subscribe communication paradigm.For example, a simulated world publishes body pose updates,and sensor generation and GUI will consume these messages to produce output.
This mechanism allows for introspection of a running simulation,and provides a convenient mechanism to control aspectsof Gazebo.
System
Gazebo Master
This is essentially a topic name server.It provides namelookup, and topic management.A single master can handle multiple physics simulations,sensor generators, and GUIs.
Communication Library
- Dependencies: Protobuf and boost::ASIO
- External API:
- Internal API: None
- Advertised Topics: None
- Subscribed Topics: None
This library is used by almost all subsequent libraries.It acts as the communication and transport mechanism for Gazebo.It currently supports only publish/subscribe,but it is possible to useRPCwith minimal effort.
Physics Library
- Dependencies: Dynamics engine (with internal collision detection)
- External API: Provides a simple and generic interface to physics simulation
- Internal API: Defines a fundamental interface to the physics library for 3rd party dynamic engines.
The physics library provides a simple and generic interface tofundamental simulation components, including rigid bodies,collision shapes, and joints for representing articulationconstraints.This interface has been integrated with four open-sourcephysics engines:
- Open Dynamics Engine (ODE)
- Bullet
- Simbody
- Dynamic Animation and Robotics Toolkit (DART)
A model described in theSimulation Description Format (SDF)using XML can be loaded by each of these physics engines.This provides access to different algorithm implementationsand simulation features.
Rendering Library
- Dependencies: OGRE
- External API: Allows for loading, initialization, and scene creation
- Internal API: Store metadata for visualization, call the OGRE API for rendering.
The rendering library uses OGRE to provide a simple interfacefor rendering 3D scenes to both the GUI and sensor libraries.It includes lighting, textures, and sky simulation.It is possible to write plugins for the rendering engine.
Sensor Generation
- Dependencies: Rendering Library, Physics Library
- External API: Provide functionality to initialize and run a set of sensors
- Internal API: TBD
The sensor generation library implements all the various types of sensors,listens to world state updates from a physics simulator andproduces output specified by the instantiated sensors.
GUI
- Dependencies: Rendering Library, Qt
- External API: None
- Internal API: None
The GUI library uses Qt to create graphical widgets for users to interact with the simulation.The user may control the flow of time by pausing or changing time step sizevia GUI widgets.The user may also modify the scene by adding, modifying, or removing models.Additionally there are some tools for visualizing andlogging simulated sensor data.
Plugins
The physics, sensor, and rendering libraries support plugins.These plugins provide users with access to the respective librarieswithout using the communication system.
Capture screenshots
To capture a screenshot of the scene displayed in the Gazebo 3D render window, find and click on the camera icon on the toolbar above the render window.
Screenshot save location
The captured image will be saved to ~/.gazebo/pictures with a timestamped filename.
- Gazebo機器人仿真學習探索筆記(二)基本使用說明
- Gazebo機器人仿真學習探索筆記(一)安裝與使用
- Gazebo機器人仿真學習探索筆記(三)機器人模型
- Gazebo機器人仿真學習探索筆記(四)模型編輯
- Gazebo機器人仿真學習探索筆記(五)環境模型
- Gazebo機器人仿真學習探索筆記(六)工具和实用程序
- Gazebo機器人仿真學習探索筆記(七)连接ROS
- Gazebo仿真
- ROS Gazebo(五):ros_control和gazebo仿真总结
- ROS中给turtlebot加两个传感器:kinect+hokuyo,进行gazebo仿真 (二)
- ROS的初步学习(二)--使用Gazebo模拟器
- 【ROS Gazebo专题】二、Gazebo的使用上
- x265探索与研究(二):x265使用基本方法
- ROS Gazebo(二):概述
- 在ROS Kinetic中使用Gazebo 8进行机器人仿真
- Pioneer3-dx Gazebo 仿真
- 2017 FIRA SIMUROSOT仿真环境(ROS+Gazebo)
- 机器人仿真(一)——Asctec 四轴飞行器 Gazebo 仿真
- Python web 简单服务器的搭建与运行
- oracle表的导出这个问题怎么解决
- spark streaming programming guide 基础概念之输入离散流和接收方(三d)
- 在水平和垂直方向都加上scrollview
- windows 7 64位 刷J-Link固件 无法识别成串口时 安装 sam-ba at91 usb to serial converter 驱动不成功的解决办法
- Gazebo機器人仿真學習探索筆記(二)基本使用說明
- JavaScript: The Definitive Guide
- 在centos7上安装nginx
- Machine Learning and Data Mining Course/Video
- 网络流算法
- Mysql----mysql服务不能启动
- 线性表的链式存储与基本操作
- JAVA 内存泄露详解
- spark性能调优一--常规调优