在完成Gazebo7安裝後,需要熟悉Gazebo,方便之後使用。

部分源代碼可以參考:https://bitbucket.org/osrf/gazebo/src/

如果還沒有安裝請參考之前內容完成安裝,快速打開ubuntu終端的方式(CTRL+ALT+t):

  1. ~$ gazebo

Gazebo7自帶了很多構建好的環境模型,可以直接使用,這些模型位置和安裝路徑相關:

  1. relaybot@relaybot-desktop:~$ ls /usr/share/gazebo-7/worlds/
  2. actor.world pioneer2dx.world
  3. blank.world plane_demo.world
  4. camera.world plugin.world
  5. cart_demo.world polyline.world
  6. cessna_demo.world population.world
  7. contact.world pr2.world
  8. depth_camera.world presentation.world
  9. elevator.world pressure_sensor.world
  10. empty_1_0.world projector.world
  11. empty_bullet.world quad_rotor_demo_2.world
  12. empty_sky.world quad_rotor_demo.world
  13. empty.world random_velocity.world
  14. everything.world ray_cpu.world
  15. flocking.world ray_noise_plugin.world
  16. force_torque_demo.world road_textures.world
  17. friction_demo.world road.world
  18. gripper.world robocup09_spl_field.world
  19. heightmap_dem.world robocup14_spl_field.world
  20. heightmap.world robocup_3Dsim.world
  21. hydra_demo.world rubble.world
  22. imu_demo.world seesaw.world
  23. initial_velocity.world shapes_bitmask.world
  24. joint_damping_demo.world shapes_layers.world
  25. joint_friction_demo.world shapes.world
  26. joints.world sim_events.world
  27. lift_drag_demo.world simple_arm.world
  28. lights.world simple_gripper.world
  29. linear_battery_demo.world single_rotor_demo.world
  30. logical_camera.world sonar_demo.world
  31. magnetometer.world sphere_atlas_demo.world
  32. mud_bitmask.world stacks.world
  33. mud.world timer_gui.world
  34. multilink_shape.world torsional_friction_demo.world
  35. nested_model.world transporter.world
  36. openal.world trigger.world
  37. ortho.world twin_rotor_demo.world
  38. osrf_elevator.world underwater.world
  39. pioneer2dx_camera.world willowgarage.world
  40. pioneer2dx_laser_camera.world wireless_sensors.world
  41. pioneer2dx_laser.world

在ubuntu下默認的路徑爲:/usr/share/gazebo-7/worlds/。

啓動一個示例,如下:

  1. /usr/share/gazebo-7/worlds$ gazebo lift_drag_demo.world

啓動一個帶有天空的環境:

  1. /usr/share/gazebo-7/worlds$ gazebo empty_sky.world

  1. <?xml version="1.0" ?>
  2. <sdf version="1.5">
  3. <world name="default">
  4. <scene>
  5. <sky>
  6. <clouds>
  7. <speed>12</speed>
  8. </clouds>
  9. </sky>
  10. </scene>
  11. <!-- A global light source -->
  12. <include>
  13. <uri>model://sun</uri>
  14. </include>
  15. <!-- A ground plane -->
  16. <include>
  17. <uri>model://ground_plane</uri>
  18. </include>
  19. </world>
  20. </sdf>

注意這個環境中,天空中只有雲彩速度爲12,場景中還有光源和大地。

啓動一個帶有機器人模型的環境:

  1. /usr/share/gazebo-7/worlds$ gazebo pioneer2dx_laser_camera.world

  1. <?xml version="1.0" ?>
  2. <sdf version="1.5">
  3. <world name="default">
  4. <!-- Ground -->
  5. <include>
  6. <uri>model://ground_plane</uri>
  7. </include>
  8. <!-- A global light source -->
  9. <include>
  10. <uri>model://sun</uri>
  11. </include>
  12.  
  13. <!-- Pioneer2dx model -->
  14. <model name="pioneer2dx">
  15. <include>
  16. <uri>model://pioneer2dx</uri>
  17. </include>
  18.  
  19. <include>
  20. <uri>model://hokuyo</uri>
  21. <pose>0.2 0 .38 0 0 0</pose>
  22. </include>
  23.  
  24. <include>
  25. <uri>model://camera</uri>
  26. <pose>0.2 0 .3 0 0 0</pose>
  27. </include>
  28.  
  29. <joint name="camera_joint" type="revolute">
  30. <parent>pioneer2dx::pioneer2dx::chassis</parent>
  31. <child>pioneer2dx::camera::link</child>
  32. <axis>
  33. <xyz>0 0 1</xyz>
  34. <limit>
  35. <lower>0</lower>
  36. <upper>0</upper>
  37. </limit>
  38. </axis>
  39. </joint>
  40.  
  41. <joint name="laser_joint" type="revolute">
  42. <parent>pioneer2dx::pioneer2dx::chassis</parent>
  43. <child>pioneer2dx::hokuyo::link</child>
  44. <axis>
  45. <xyz>0 0 1</xyz>
  46. <limit>
  47. <lower>0</lower>
  48. <upper>0</upper>
  49. </limit>
  50. </axis>
  51. </joint>
  52.  
  53. </model>
  54.  
  55. </world>
  56. </sdf>

參考上述模板,可以學習環境文件,主要由大地,光源,機器人模型,機器人模型包括本體,激光和攝像頭等具體配置。

除此之外,還有gzserver和gzclient。

gazebo命令实际上运行两个不同的可执行文件。 第一个称为gzserver,第二个称为gzclient。
gzserver可执行程序运行物理更新循环和传感器数据生成。 这是Gazebo的核心,可以独立于图形界面使用。 您可能会在论坛中看到“run headless”这个短语。 这个短语相当于只运行gzserver。 一个示例用例将涉及在不需要用户界面的云计算机上运行gzserver。
gzclient可执行文件运行基于QT的用户界面。 此应用程序提供了一个很好的可视化的模拟,并在各种模拟属性方便的控制。

當然,這兩個可以分別啓動。

gazebo使用的快捷鍵:

Action Operation Instruction
MODE
Enter Selection mode (default mode) Esc press Esc for mode to select models and right-click for context menu
Enter Rotate mode r press "r" for Rotate (model) mode
Enter Translate mode t press "t" for Translate (model) mode
Enter Scale mode s press "s" for Scale (model) mode
Enter Snap mode n press "n" for Snap (model) mode
MODELS
Delete model Delete press Delete when a model is selected to delete from scene
Copy model Ctrl + c press Ctrl + "c" when model is selected to copy
Paste model Ctrl + v press Ctrl + "v" to paste copied model
MANIPULATING MODELS
Rotate model r press "r" for Rotate mode; click model & rotate using markers
Translate model t press "t" for Translate mode; click model & translate using markers
Scale model s press "s" for Scale mode; click model & scale using markers
Constrain along axis x/y/z hold key while manipulating model to constrain movement along that axis
Snap to 45° when rotating Ctrl + drag hold Ctrl while rotating model to rotate in 45° increments
Snap to grid when translating Ctrl + drag hold Ctrl while translating model to snap to grid
Snap to 1 m when scaling Ctrl + drag hold Ctrl while scaling mode to scale in 1 m increments
Snap when inserting Ctrl + drag hold Ctrl while inserting model to enable snap to grid
Snap models together n press "n" for Snap mode; click one link, then a second to snap first link to second
GUI LAYOUT
Hide toolbars Ctrl + h hide/show top toolbar and bottom time panel
Enter fullscreen F11 enter/exit fullscreen
Action Operation Instruction
EDITORS
Open Model Editor Ctrl + m open Model Editor to construct or edit models
Open Schematic View (Model Editor) Ctrl + e open Schematic View in Model Editor
Open Building Editor Ctrl + b open Building Editor to construct buildings
Show floor plan (Building Editor) f show/hide floor plan in Building Editor 2D View
Show building features (Building Editor) g show/hide building features in Building Editor 2D View
New canvas (both Editors) Ctrl + n create new canvas
Save model (both Editors) Ctrl + s save model for later use
Save as (both Editors) Ctrl + Shift + s save model for later use & give it a name
Exit (both Editors) Ctrl + x exit Editor
WORLD
Save world Ctrl + s press Ctrl + "s" to save world for later use
Save as Ctrl + Shift + s press Ctrl + Shift + "s" to save world for later use & give it a name
Reset world Ctrl + r press Ctrl + "r" to reset world to its original state
Reset model poses Ctrl + Shift + r press Ctrl + Shift + "r" to reset models to their original poses
DATA
Visualize topics Ctrl + t open dialog with list of topics currently advertized
Log data Ctrl + d open dialog to record log files
MISCELLANEOUS
Quit Gazebo Ctrl + q press Ctrl + "q" to quit Gazebo

Gazebo 鼠標控制
場景視角改變

注意這裏gazebo並不能與ROS通訊,如果需要可以使用下面命令:

  1. rosrun gazebo_ros gazebo
  2. rosrun gazebo_ros gzserver
  3. rosrun gazebo_ros gzclient
  4. rosrun gazebo_ros spawn_model
  5. rosrun gazebo_ros perf
  6. rosrun gazebo_ros debug

啓動後可以看到:

  1. ~$ rostopic list
  2. /clock
  3. /gazebo/link_states
  4. /gazebo/model_states
  5. /gazebo/parameter_descriptions
  6. /gazebo/parameter_updates
  7. /gazebo/set_link_state
  8. /gazebo/set_model_state
  9. /rosout
  10. /rosout_agg

具體在之後筆記中再補充。

附件:官網教程。

Run Gazebo

These three steps will run Gazebo with a default world.

  1. Install Gazebo.

  2. Open a terminal. On most Ubuntu systems you can press CTRL+ALT+t

  3. Start Gazebo by entering the following at the command prompt.

    1. gazebo

Run Gazebo with a robot

Let's simulate something a bit more interesting by loading a world with a pioneer2dx.

  1. Open a terminal and enter the following command.

    1. 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.

  1. 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.

  1. 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:

  1. gzserver

Open another terminal and run the graphical client:

  1. 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:

  1. <include>
  2. <uri>model://model_file_name</uri>
  3. </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:

  1. 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.

  1. gzserver <world_filename>

The <world_filename> can be:

  1. relative to the current directory,

  2. an absolute path, or

  3. 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

  1. 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:

  1. 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:

  1. 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:

  1. gzserver -s <plugin_filename> <world_file>

The same mechanism is used by the graphical client:

  1. 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 sensors

  • a 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:

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機器人仿真學習探索筆記(二)基本使用說明的更多相关文章

  1. Gazebo機器人仿真學習探索筆記(三)機器人模型

    gazebo_models:https://bitbucket.org/osrf/gazebo_models 模型庫下載,可以參考如下命令: ~/Rob_Soft/Gazebo7$ hg clone ...

  2. Gazebo機器人仿真學習探索筆記(四)模型編輯

    模型編輯主要是自定義編輯物體模型構建環境,也可以將多種模型組合爲新模型等,支持外部模型導入, 需要注意的導入模型格式有相應要求,否在無法導入成功, COLLADA (dae), STereoLitho ...

  3. Gazebo機器人仿真學習探索筆記(一)安裝與使用

    Gazebo提供了多平臺的安裝和使用支持,大部分主流的linux,Mac以及Windows,這裏結合ROS以Ubuntu爲例進行介紹. 首先是參考資料:http://gazebosim.org/tut ...

  4. Gazebo機器人仿真學習探索筆記(七)连接ROS

    中文稍后补充,先上官方原版教程.ROS Kinetic 搭配 Gazebo 7 附件----官方教程 Tutorial: ROS integration overview As of Gazebo 1 ...

  5. Gazebo機器人仿真學習探索筆記(六)工具和实用程序

    Gazebo附带了许多工具和实用程序. 这些教程说明了这些可用的工具,以及如何使用它们. 主要有: 1 记录和播放 2 日志过滤 3 应用力/扭矩 4 HDF5数据集 官网介绍通俗具体,非常容易,请参 ...

  6. Gazebo機器人仿真學習探索筆記(五)環境模型

    環境模型構建可以通過向其中添加模型實現,待之後補充,比較有趣的是建築物模型, 可以編輯多層樓層和房間,加入樓梯,窗戶和牆壁等,具體可以參考附錄,等有空再補充. 起伏地形環境構建可以參考之前內容:在Ga ...

  7. ROS_Kinetic_x 基於ROS和Gazebo的RoboCup中型組仿真系統(多機器人協作)

    國防科學技術大學發布了RoboCup中型組仿真平臺,基於ROS和Gazebo設計. 該平臺可以用於多機器人協作研究.參考資料如下: ROS新聞:1    http://www.ros.org/news ...

  8. ROS常用三維機器人仿真工具Gazebo教程匯總

    參考網址: 1. http://gazebosim.org/tutorials 2. http://gazebosim.org/tutorials/browse Gazebo Tutorials Ga ...

  9. ROS_Kinetic_x 目前已更新的常用機器人資料 rosbridge agvs pioneer_teleop nao TurtleBot

    Running Rosbridge Description: This tutorial shows you how to launch a rosbridge server and talk to ...

随机推荐

  1. 出错信息:Incorrect string value: '\xE4\xBD\xA0\xE5\xA5\xBD' for column 'username'

    出错信息: java.sql.SQLException: Incorrect string value: '\xE4\xBD\xA0\xE5\xA5\xBD' for column 'username ...

  2. Redis常用命令--SortedSet

    SortedSet是一个类似于Set的集合数据类型,里面的每个字符串元素都关联到一个score(整数或浮点数),并且总是通过score来进行排序着. 并且可以取得一定范围内的元素. 在Redis中大概 ...

  3. [Codeforces 606C]Sorting Railway Cars

    Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the n ...

  4. 计蒜客NOIP模拟赛D2T3 数三角形

    刚刚上高中的洁洁在学习组合数学的过程中遇到一道麻烦的题目,她希望你能帮助她解决.给定一张无向完全图 G,其中大部分边被染成蓝色,但也有一些边被染成红色或者绿色.现在,洁洁需要给这张图的多样性进行打分. ...

  5. 【网络流】【BZOJ1001】狼抓兔子

    继续网络流的学习.... 题意简析:就是给你张图,叫你求最小割. 解题思路:最小割=最大流,按题意见图跑一次就好了. 附代码: #include<cstdio> #include<i ...

  6. [JLOI2015]城池攻占 左偏树

    题目描述 小铭铭最近获得了一副新的桌游,游戏中需要用 m 个骑士攻占 n 个城池.这 n 个城池用 1 到 n 的整数表示.除 1 号城池外,城池 i 会受到另一座城池 fi 的管辖,其中 fi &l ...

  7. ●BZOJ 2329 [HNOI2011]括号修复.cpp

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=2329 题解: Splay 类似 BZOJ 2329 [HNOI2011]括号修复 只是多了一 ...

  8. 【Aho-Corasick automation 大米饼模板】

    自动机要打熟.自动机要打好.自动机要打得美妙. [例子:HDU2222] #include<stdio.h> #include<queue> #include<cstri ...

  9. bzoj1043[HAOI2008]下落的圆盘 计算几何

    1043: [HAOI2008]下落的圆盘 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1598  Solved: 676[Submit][Stat ...

  10. A Problem-Solving FlowChart || 如何解决编程问题

    This is from book Cracking the coding interview, Gayle Laakmann Mcdowell. The flowchart can be used ...