打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Gazebo : Tutorial : From source (Ubuntu and Mac)

要编译最新版本的 Gazebo,您需要 14.04.2 (Trusty) 或更高版本的 Ubuntu 发行版。

在从源安装之前,请确保您已删除 Ubuntu 预编译的二进制文件:

sudo apt-get remove '.*gazebo.*' '.*sdformat.*' '.*ignition-math.*'

如果您以前从源安装过,请确保安装到相同的路径位置,或者已手动从源版本中删除以前的安装。

作为旁注,默认安装位置:

  1. 预编译的 Ubuntu 二进制文件:/usr/bin/gazebo

  2. 默认源安装:/usr/local/bin/gazebo

ROS用户

构建 Gazebo 时,我们建议您不要获取/opt/ros/*/setup.sh 文件,因为它已被视为将错误的库添加到 Gazebo 构建中。

安装所需的依赖项

安装先决条件。一个干净的 Ubuntu 系统需要:

wget https://raw.githubusercontent.com/ignition-tooling/release-tools/master/jenkins-scripts/lib/dependencies_archive.sh -O /tmp/dependencies.sh
ROS_DISTRO=dummy . /tmp/dependencies.sh
sudo apt-get install $(sed 's:\\ ::g' <<< $GAZEBO_BASE_DEPENDENCIES) $(sed 's:\\ ::g' <<< $BASE_DEPENDENCIES)

可选的物理引擎

发行说明:为了使用 DART,需要从源代码完整编译 Gazebo(如本文档中详述)。.deb 包包含 ODE、Bullet 和 Simbody 物理引擎。

DART 支持

Support for DART version 5.0 is integrated into the default branch. In an Ubuntu system, several Personal Package Archives (PPA's) can be used to install the proper package and dependencies. Note that adding these PPA's may cause conflicts with ROS.

    # Only needed on Trusty. Ubuntu packages since Utopic.
    sudo apt-add-repository ppa:libccd-debs
    sudo apt-add-repository ppa:fcl-debs

    # Main repository
    sudo apt-add-repository ppa:dartsim
    sudo apt-get update
    sudo apt-get install libdart-core5-dev

Optional Dependencies

GUI test Support

To correctly parse the results of GUI regression tests, the xsltproc package is needed.

sudo apt-get install xsltproc

Man Page Support

To generate man-pages for the Gazebo executables, the ruby-ronn package is needed.

sudo apt-get install ruby-ronn

Player Support

sudo apt-get install robot-player-dev*

Build And Install ignition math

SDFormat and Gazebo depend on the ignition math library.

  1. Clone the repository into a directory and go into it:

    git clone https://github.com/ignitionrobotics/ign-math /tmp/ign-math
    cd /tmp/ign-math

    Note: the master branch is the development branch where you'll find the bleeding edge code, your cloned repository should be on this branch by default but we recommend you switch to the ign-math2 branch if you desire more stability (with the git checkout ign-math2 command).

  2. Create a build directory and go there:

    mkdir build
    cd build
  3. Build and install:

    cmake .. -DCMAKE_INSTALL_PREFIX=/usr
    make -j4
    sudo make install

Build And Install SDFormat

Gazebo depends on the SDFormat package. Let's build it, then build Gazebo off of that:

  1. Clone the repository into a directory and go into it:

    git clone https://github.com/osrf/sdformat /tmp/sdformat
    cd /tmp/sdformat

    Note: the master branch is the development branch where you'll find the bleeding edge code, your cloned repository should be on this branch by default but we recommend you switch to branch sdf3 if you desire more stability

  2. Create a build directory and go there:

    mkdir build
    cd build
  3. Build and install:

    cmake .. -DCMAKE_INSTALL_PREFIX=/usr
    make -j4
    sudo make install

Build And Install Gazebo

  1. Clone the repository into a directory and go into it:

    git clone https://github.com/osrf/gazebo /tmp/gazebo
    cd /tmp/gazebo

    Note: the master branch is the development branch where you'll find the bleeding edge code, your cloned repository should be on this branch by default but we recommend you switch to the gazebo6 branch if you desire more stability

  2. Create a build directory and go there:

    mkdir build
    cd build
  3. Configure Gazebo (choose either method a or b below):

    A。发布模式:这将生成优化的代码,但不会有调试符号。如果不需要使用GDB,请使用此模式。

       cmake ../

    注意:您可以使用自定义安装路径,以便更轻松地在源安装和 debian 安装之间切换:

       cmake -DCMAKE_INSTALL_PREFIX=/home/$USER/local ../

    b. 调试模式:这将生成带有调试符号的代码。Gazebo 运行速度会较慢,但您将能够使用 GDB。

       cmake -DCMAKE_BUILD_TYPE=Debug ../

    注意:编译的很大一部分是测试套件。如果在开发过程中暂时禁用它有用,您可以使用:

       cmake ../ -DENABLE_TESTS_COMPILATION:BOOL=False
  4. 的输出cmake ../可能会生成许多有关丢失包的错误和警告。您必须安装缺少的软件包ve errors and re-run cmake ../. Make sure all the build errors are resolved before continuing (they should be there from the earlier step in which you installed prerequisites). Warnings alert of optional packages that are missing.

  5. Make note of your install path, which is output from cmake and should look something like:

      -- Install path: /home/$USER/local
  6. Build Gazebo:

    make -j4
  7. Install Gazebo:

    sudo make install
  8. Setup environment variables

Local Install

If you decide to install gazebo in a local directory you'll need to modify some of your PATHs:

echo "export LD_LIBRARY_PATH=<install_path>/local/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
echo "export PATH=<install_path>/local/bin:$PATH" >> ~/.bashrc
echo "export PKG_CONFIG_PATH=<install_path>/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> ~/.bashrc
source ~/.bashrc

Now try running gazebo:

gazebo

If Gazebo runs successfully, you're done!.

If Gazebo was installed to /usr/local/ and running gazebo throws an error similar to:

gazebo: error while loading shared libraries: libgazebo_common.so.1: cannot open shared object file: No such file or directory

, then /usr/local/lib is not in load path (default behavior for Ubuntu). Run the following commands and then try running gazebo again:

echo '/usr/local/lib' | sudo tee /etc/ld.so.conf.d/gazebo.conf
sudo ldconfig
  1. If you are interested in using Gazebo with ROS, see Installing gazebo_ros_pkgs.

Install in a catkin workspace

Another method for installing to a local directory is to use a catkin workspace, which supports plain cmake packages as well as catkin packages. This allows multiple versions of gazebo to be installed side-by-side. Environment variables do not need to be added to the ~/.bashrc; rather they are set by sourcing the appropriate setup script. Using catkin requires the some extra python packages to be installed. If you are using Ubuntu and have configured your system to use the ROS package repository (see here for instructions), then you can use the following apt-get commands:

sudo apt-get install python-catkin-pkg python-catkin-tools

For other platforms, you can use pip (you can also use pip with Ubuntu, but apt-get is recommended):

sudo pip install catkin-pkg catkin-tools

Here is an example for building gazebo against custom versions of sdformat, bullet, and DART.

First, create a workspace folder. Since it is easy to use multiple catkin workspaces, it is convenient to place them in a single folder, such as ~/ws. For this tutorial, the bash variable WS will be used to refer to the absolute path of the workspace folder. In this case, we will name the folder gazebo_dart:

export WS=$HOME/ws/gazebo_dart
mkdir -p ${WS}/src

Clone catkin and the packages you want to build into this folder:

cd ${WS}/src
git clone https://github.com/ros/catkin.git
git clone https://github.com/bulletphysics/bullet3.git
git clone https://github.com/dartsim/dart.git
git clone https://github.com/osrf/sdformat
git clone https://github.com/osrf/gazebo

Checkout the appropriate branch for each repository. For example, gazebo5 doesn't support dart5.

cd ${WS}/src/gazebo
git checkout master
cd ${WS}/src/dart
git checkout release-5.0

Add package.xml files for the plain cmake packages:

curl https://bitbucket.org/scpeters/unix-stuff/raw/master/package_xml/package_bullet.xml    > ${WS}/src/bullet3/package.xml
curl https://bitbucket.org/scpeters/unix-stuff/raw/master/package_xml/package_dart-core.xml > ${WS}/src/dart/package.xml
curl https://bitbucket.org/scpeters/unix-stuff/raw/master/package_xml/package_gazebo.xml    > ${WS}/src/gazebo/package.xml
curl https://bitbucket.org/scpeters/unix-stuff/raw/master/package_xml/package_sdformat.xml  > ${WS}/src/sdformat/package.xml

Initialize the catkin workspace:

cd ${WS}
catkin init

Then build the workspace using catkin build. Note that bullet and DART have several important cmake options. Using bullet with gazebo requires BUILD_SHARED_LIBS=ON and has better accuracy if USE_DOUBLE_PRECISION=ON. Using DART with Gazebo is compatible with BUILD_CORE_ONLY=ON, which requires many fewer dependencies to be installed. For now, these options do not overlap, so they can be sent to all the packages:

cd ${WS}
catkin build -vi --cmake-args   -DBUILD_CORE_ONLY=ON   -DBUILD_SHARED_LIBS=ON   -DUSE_DOUBLE_PRECISION=ON

This will build all the packages in order with verbose output. Omit the -vi option to see less console output.

Once the build has completed, source the setup file located in ${WS}/devel/setup.bash to run gazebo:

. ${WS}/devel/setup.bash
gazebo -e bullet
gazebo -e dart

Other packages can be added to the catkin workspace as long as they have a package.xml that lists their dependencies.

Uninstalling Source-based Install

If you need to uninstall Gazebo or switch back to a debian-based install of Gazebo when you currently have installed Gazebo from source, navigate to your source code directory's build folders and run make uninstall:

cd ~/gazebo/build
sudo make uninstall
cd ~/sdformat/build
sudo make uninstall

Compiling From Source (Mac OS X)

Gazebo and several of its dependencies can be compiled on OS X with Homebrew using the osrf/simulation tap. Here are the instructions:

  1. Install homebrew: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. Install XQuartz, which provides X11 support and is required by Gazebo and OGRE

  3. For 10.8 and earlier, install Xcode command-line tools by downloading them from Apple. For 10.9 and later, they should prompt you to install them when you install Homebrew in step 1.

  4. Run the following commands:

    brew tap osrf/simulation
    brew install default
    gazebo

可选依赖项

Gazebo 公式有两个可选的依赖项:BulletSimbody物理引擎。要安装这些物理引擎:

    brew install default --with-bullet --with-simbody
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
rbx2 install
深度相机Astra Pro测试教程
(1)关于ROS 你需要知道的
ros常用命令
在Ubuntu14.04上安装和配置ROS Indigo
你以为只有马云会灌鸡汤?Linux 命令行也会!
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服