在完成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.world
blank.world plane_demo.world
camera.world plugin.world
cart_demo.world polyline.world
cessna_demo.world population.world
contact.world pr2.world
depth_camera.world presentation.world
elevator.world pressure_sensor.world
empty_1_0.world projector.world
empty_bullet.world quad_rotor_demo_2.world
empty_sky.world quad_rotor_demo.world
empty.world random_velocity.world
everything.world ray_cpu.world
flocking.world ray_noise_plugin.world
force_torque_demo.world road_textures.world
friction_demo.world road.world
gripper.world robocup09_spl_field.world
heightmap_dem.world robocup14_spl_field.world
heightmap.world robocup_3Dsim.world
hydra_demo.world rubble.world
imu_demo.world seesaw.world
initial_velocity.world shapes_bitmask.world
joint_damping_demo.world shapes_layers.world
joint_friction_demo.world shapes.world
joints.world sim_events.world
lift_drag_demo.world simple_arm.world
lights.world simple_gripper.world
linear_battery_demo.world single_rotor_demo.world
logical_camera.world sonar_demo.world
magnetometer.world sphere_atlas_demo.world
mud_bitmask.world stacks.world
mud.world timer_gui.world
multilink_shape.world torsional_friction_demo.world
nested_model.world transporter.world
openal.world trigger.world
ortho.world twin_rotor_demo.world
osrf_elevator.world underwater.world
pioneer2dx_camera.world willowgarage.world
pioneer2dx_laser_camera.world wireless_sensors.world
pioneer2dx_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使用的快捷鍵:
| 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 |
更多文章请关注《万象专栏》
转载请注明出处:https://www.wanxiangsucai.com/read/cv11642