Gazebo提供了多平臺的安裝和使用支持,大部分主流的linux,Mac以及Windows,這裏結合ROS以Ubuntu爲例進行介紹。
首先是參考資料:http://gazebosim.org/tutorials?cat=install
官方提供的安裝.sh文件解析(gazebo7_install.sh):
#!/bin/bash
# Copyright (C) 2012-2016 Open Source Robotics Foundation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# This script installs gazebo onto an Ubuntu system.
codename=`lsb_release -sc`
# Make sure we are running a valid Ubuntu distribution
case $codename in
"trusty" | "utopic" | "vivid" | "wily")
;;
*)
echo "This script will only work on Ubuntu trusty, utopic, vivid, and wily"
exit 0
esac
# Add the OSRF repository
if [ ! -e /etc/apt/sources.list.d/gazebo-latest.list ]; then
sudo sh -c "echo \"deb http://packages.osrfoundation.org/gazebo/ubuntu ${codename} main\" > /etc/apt/sources.list.d/gazebo-latest.list"
fi
# Download the OSRF keys
has_key=`apt-key list | grep "OSRF deb-builder"`
echo "Downloading keys"
if [ -z "$has_key" ]; then
wget --quiet http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
fi
# Update apt
echo "Retrieving packages"
sudo apt-get update -qq
echo "OK"
# Install gazebo
echo "Installing Gazebo"
sudo apt-get install gazebo7 libgazebo7-dev
echo "Complete."
echo "Type gazebo to start the simulator."
首先,是檢查ubuntu的發行版本,符合"trusty" | "utopic" | "vivid" | "wily",符合的添加軟件源和密匙;
然後,使用sudo apt-get update更新,完成後顯示ok;
最後,使用sudo apt-get install gazebo7 libgazebo7-dev,完成全部安裝。
對於ROS Kinetic比較簡單直接使用:
~$ sudo apt-get install ros-kinetic-gazebo*
可以安裝相對應的功能包。
~$ sudo apt-get install gazebo7 libgazebo7
這樣就可以完成gazebo7的安裝。
完成後,在終端輸入gazebo,就可以啓動。
~$ gazebo
注意,模型加載,由於網絡問題會出現這樣錯誤和警告,請離線下載gazebo模型,放在home文件夾.gazebo/model下。
完成安裝後,就可以在界面上探索Gazebo7的基本操作。
附錄以下內容轉載自官方指南:
Welcome to the Beginner Module! This module will guide you through the mostbasic features of Gazebo. We will build a simple vehicle to demonstrate thesefeatures.
Each tutorial builds upon the last, so we recommend following the tutorials in order.
These tutorials are intended for those new to Gazebo and/or folks with no programming or Linux experience.
Gazebo is a 3D dynamic simulator with the ability to accurately andefficiently simulate populations of robots in complex indoor and outdoorenvironments. While similar to game engines, Gazebo offers physicssimulation at a much higher degree of fidelity, a suite of sensors, andinterfaces for both users and programs.
Typical uses of Gazebo include:
A few key features of Gazebo include:
Gazebo is currently best used on Ubuntu, a flavor of Linux. You will need a computer that has:
If you run into problems during the install, please see the complete install instructions.
Done
similar to below:
$ sudo apt-get update ... Hit http://ppa.launchpad.net trusty/main Translation-en Ign http://us.archive.ubuntu.com trusty/main Translation-en_US Ign http://us.archive.ubuntu.com trusty/multiverse Translation-en_US Ign http://us.archive.ubuntu.com trusty/restricted Translation-en_US Ign http://us.archive.ubuntu.com trusty/universe Translation-en_US Reading package lists... Done
Next install gazebo-7 by:
sudo apt-get install gazebo7 # For developers that work on top of Gazebo, one extra package sudo apt-get install libgazebo7-dev
If you see the error below:
$ sudo apt-get install gazebo7 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package gazebo7
It's possible the version of Gazebo you are looking for is not supported on the version of OS you are using.For example, installing gazebo7 on Ubuntu Precise (12.04) will produce the error above.Hint: Take a look at "Project Status" section at http://gazebosim.org/#status, next to each version is the supported ubuntu versions and ROS versions.gazebo
is executed requires the download of some models and it could take some time, please be patient.
gazeboGazebo ships different Ubuntu debian packages following the official packagingguidelines. This changesbrings an option about how to install gazebo:
This is an introduction to the Gazebo Graphical User Interface, or GUI. We will learn interface basics like what the buttons do and how to navigate in the scene.
By now, you should have Gazebo installed.
Start by opening Gazebo. Press Alt-F2, type Gazebo, and then press Enter.
This is what you should see:
Note that the Gazebo interface consists of multiple sections, explained below.
The Scene is the main part of the simulator. This is where the simulatedobjects are animated and you interact with the environment.
Both side panels—right and left—can be displayed, hidden or resized by draggingthe bar that separates them from the Scene.
The left panel appears by default when you launch Gazebo. There are three tabsin the panel:
The right panel is hidden by default. Click and drag the bar to open it. The right panel canbe used to interact with the mobile parts of a selected model (the joints). If there are nomodels selected in the Scene, the panel does not display any information.
The Gazebo interface has two Toolbars. One is located just above the Scene, andthe other is just below.
The main Toolbar includes some of the most-used options for interacting withthe simulator, such as buttons to: select, move, rotate, and scale objects;create simple shapes (e.g. cube, sphere, cylinder); and copy/paste. Go ahead and playaround with each button to see how it behaves.
Select mode: Navigate in the scene
Translate mode: Select models you want to move
Rotate mode: Select models you want to rotate
Scale mode: Select models you want to scale
Undo/Redo: Undo/redo actions in the scene
Simple shapes: Insert simple shapes into the scene
Lights: Add lights to the scene
Copy/paste: Copy/paste models in the scene
Align: Align models to one another
Snap: Snap one model to another
Change view: View the scene from various angles
The Bottom Toolbar displays data about the simulation, like the simulation timeand its relationship to real-life time. "Simulation time" refers to how quicklytime is passing in the simulator when a simulation is running. Simulation canbe slower or faster than real time, depending on how much computation isrequired to run the simulation.
"Real time" refers to the actual time that is passing in real life as thesimulator runs. The relationship between the simulation time and real time isknown as the "real time factor" (RTF). It's the ratio of simulation time to realtime. The RTF is a measure of how fast or slow your simulation is runningcompared to real time.
The state of the world in Gazebo is calculated once per iteration. You cansee the number of iterations on the right side of the bottom toolbar. Eachiteration advances simulation by a fixed number of seconds, called the stepsize. By default, the step size is 1 ms. You can pressthe pause button to pause the simulation and step through a few steps ata time using the step button.
Like most applications, Gazebo has an application menu up top. Some of the menuoptions are duplicated in the Toolbars or as right-click context menu optionsin the Scene. Check out the various menus to familiarize yourself.
NOTE: Some Linux desktops hide application menus. If you don't see themenus, move your cursor to the top of the application window, and the menusshould appear.
The mouse is very useful when navigating in the Scene. We highly recommendusing a mouse with a scroll wheel. Below are the basic mouse operations fornavigating in the Scene and changing the view angle.
Right-clicking on models will open a context menu with various options.Right-click on a model now to see what's available.
Now we'll construct our simple robot. We'll make a wheeled vehicle and add a sensor that allows us to make the robot follow a blob (person).
The Model Editor lets us construct simple models right in the Graphical User Interface (GUI). For more complex models, you'll need to learn how to write SDF files, and check out the tutorials on building a robot.But for now, we can do everything right in the Gazebo GUI!
To enter the Model Editor, click on Edit
in the menu bar and select Model Editor
. Or, use the hotkeys, Ctrl+M. Physics and the simulation will be paused as soon as you are in the Model Editor.
The Model Editor interface looks similar to the main Gazebo UI but with some subtle differences. The left panel and top Toolbar now contain only widgets for editing and creating parts of the model. The bottom Toolbar that displays simulation data is hidden since the simulation is now paused.
The left panel, also known as the Palette, has two tabs.
Add
button allows you to import custom meshes(currently supports COLLADA, STL, and SVG files) into the editor to forma link of the model.Like in Simulation mode, the main Toolbar in the Model Editor includes tools for interacting with the objects in the Scene (see the User Interface tutorial).
A new Joint Creation tool is available; it is used to create joints between links in the model.
The Model Editor supports most of the basic model building tasks that can be done by writing SDF. However, there are a few features that are notyet available:
This section provides step-by-step instructions on creating a simple vehicle model in the Model Editor.
Chassis
Pose
parameters and change Z
to be 0.4m. Click OK
to save the changes and closethe Inspector.
Front Wheels
Roll
to 1.5707 radians (90 degrees) and hit the Enter key on the keyboard. Do not close the Inspector just yet.
visual
text label. Scroll down to the Geometry
section and change the Radius
to 0.3m and Length
to 0.25m.
Radius
: 0.3m and Length
: 0.25m. Click on OK
to save the changes and close the Inspector.Let's now make sure that the vehicle will drive correctly by aligning the chassis along the positive X axis (the red marker in the scene). When you add the wheels in the next step,make sure they are at the end of the vehicle that is extending along the positive X axis.
Joint Types
section in the dialog) which justhappens to be the joint type we want.
Note: You may find it useful to change the view angle at this point. This can be done in the Upper Toolbar; click the cube icon with an orange side.
Joint axis
section and change the axis to be Z
(0, 0, 1). Pay attention to the RGB joint visual on the wheel. You should see that a yellow ring now appears over the blue arrow of the joint visual toindicate that it is the axis of rotation.
Align links
section in the Joint Creation dialog. First we will align in the X axis, so click on the X Align Max
option to see the result of the alignment. The cylinder should be highlighted to indicate that itspose has changed.
Y Align Max
option. However, it is not quite what we want yet. Click the Reverse
option next the Y alignment options to align the wheel's minimum (reverse of maximum) to the chassis's maximum.Note that the Reverse
option is applied to the child link since the default alignment configuration shown in the drop down list below is Child to Parent
. If Parent to Child
configuration is set, the Reverse
option will be applied to the parent link. Press Create
.
Pose
section at the bottom of the dialog to move the wheel. Given that the wheel has a radius of 0.3m, go ahead and change the Z
position to 0.3m to place on the ground, and press Ok
.Z
, and c) use the Y Align Min
option to align the right wheel as it is on the other side of the chassis.
Caster Wheel
Geometry
section and change the Radius
to 0.2m. Make sure to also do the same to the collision in theCollision tab.
Joint types
section, select the Ball
joint option. You should see the joint visual in the scene change color to indicate adifferent joint type has been set.
Y Align Center
option to center the two links in the Y
axis, and select the X Align Min
option to move the caster wheel so it is placed right at the back of the vehicle. Press the Create
button to finish the joint creation process.
Z
position to 0.2m.The sensor we will add to the car is a depth camera sensor which is going to help us detect objects in front of the car. In this tutorial, we will insert an existing sensor model from the model database.
Insert
tab to see a list of models available in the Model Database
section.
http://gazebosim.org/models/
and expand it to see models available from the online model database.
Y
axis.
Joint Types
section, select the Fixed
joint option, and click on Create
to finish creating the joint.
The vehicle we have built so far is complete with all of the physical and sensor components. However, it will not really do much but stay still and generate depth data in simulation. Plugins are a great way to enhance the model with some autonomy by allowing it to perform computations such as sensor dataprocessing, path planning, and control. For simplicity, this tutorial will use an existing plugin for our vehicle. Note that it is possible to create your own plugins but it requires writing code. See the Plugin tutorials.
Model
tab to see the parts that make up the car model you built.
Model Plugins
, you should see an Add
button. Click on it to bring up a Model Plugin Inspector that lets you add a new plugin to the model.
follower
in the Plugin Name
field. The plugin name has to be unique within this model.libFollowerPlugin.so
so enter this in the Filename
field. The filename corresponds to the actual filename of the plugin library stored on your local machine. It exists in the form of a dynamically linked shared object library, hence the naming convention and theextension .so
(on Linux). Do not worry if you are using Gazebo on other operating systems as the extension will be automatically replaced with the correct one.
follower
plugin does not require any additional parameters so you can leave the Innerxml
field empty. Note: This is a simple plugin for demonstration purposes. Plugins typically have various parameters associated, e.g. a differential drive plugin requires specifying the name of joints controlling theleft and right wheels so it can move the vehicle in the correct direction. In the case of the follower
plugin, it makes many assumptions on the type of model it is attached to and tries to find the joints and sensor automatically.OK
to add the plugin. The plugin should now appear under Model Plugins
in the left panel.
File
menu and selecting Save As
. Enter a name for the model and click Save
.
File
and selecting Exit Model Editor
. Gazebo should now switch back to normal simulation mode. Hit the Play button to run the simulation.
If you want to edit the model again later, just right-click on it and select Edit Model
in the context menu.