- Step1:先卸载 ros-indigo-desktop-full
如果之前安装ROS时,是使用如下命令安装,则需要先卸载。
sudo apt-get install ros-indigo-desktop-full
因为,ros-indigo-desktop-full不仅包含了ros-indigo-ros-base、ros-indigo-desktop这些基本包,还集成了很多的功能包,其中包括gazebo2 以及gazebo与ROS连接的相关的包。gazebo的版本太低,如果不先卸载,会导致gazebo2 与更新版本gazebo的冲突。
使用如下命令进行卸载:
sudo apt-get remove ros-indigo-desktop-full
或者
sudo apt-get autoremove ros-indigo-desktop-full
或者
sudo apt-get remove ros-*
- Step2:添加源
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
查看是否添加成功
cat /etc/apt/sources.list.d/gazebo-stable.list
如果输出如下,则说明添加源成功。
deb http://packages.osrfoundation.org/gazebo/ubuntu-stable trusty main
- Step3:下载并添加秘钥
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
- Step4:更新源
sudo apt-get update
- Step5:选择版本下载
输入如下命令,并用tab键查看所有可供下载的版本
sudo apt-get install gazebo
输出如下结果
gazebo2 gazebo6-common
gazebo2-dbg gazebo6-dbg
gazebo3 gazebo6-doc
gazebo3-common gazebo6-plugin-base
gazebo3-dbg gazebo6-robocup3ds
gazebo3-doc gazebo6-robocup3ds-common
gazebo3-plugin-base gazebo7
gazebo4 gazebo7-common
gazebo4-common gazebo7-dbg
gazebo4-dbg gazebo7-doc
gazebo4-doc gazebo7-haptix
gazebo4-plugin-base gazebo7-haptix-common
gazebo5 gazebo7-haptix-dbg
gazebo5-common gazebo7-haptix-doc
gazebo5-dbg gazebo7-haptix-plugin-base
gazebo5-doc gazebo7-plugin-base
gazebo5-plugin-base gazebo7-robocup3ds
gazebo6 gazebo7-robocup3ds-common
或者,输入如下命令,并用tab键查看所有可供下载的版本
sudo apt-get install libgazebo
输出如下结果
libgazebo3 libgazebo5-dev libgazebo7-dev
libgazebo4 libgazebo6 libgazebo7-haptix
libgazebo4-dev libgazebo6-dev libgazebo7-haptix-dev
libgazebo5 libgazebo6-robocup3ds libgazebo7-robocup3ds
libgazebo5-dbg libgazebo7 libgazebo-dev
如果需要开发gazebo,则需安装libgazebo*-dev;如果只是使用gazebo,则只安装gazebo*即可
sudo apt-get install gazebo7
但是,可能会报错!!! 没报错跳过这一步
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
gazebo7 : Depends: libgazebo7 (= 7.12.0-1~trusty) but it is not going to be installed
Depends: libsdformat4 but it is not going to be installed
Depends: gazebo7-common (= 7.12.0-1~trusty) but it is not going to be installed
Recommends: gazebo7-plugin-base
E: Unable to correct problems, you have held broken packages.
那么应该改用如下命令进行安装
sudo aptitude install gazebo7
安装完成后,验证
gazebo --version
输出如下,说明安装成功
Gazebo multi-robot simulator, version 7.12.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org
- Step6:重新安装ROS
sudo apt-get install ros-indigo-desktop
- Step7: 安装ros与gazebo接口库
sudo apt-get install ros-indigo-gazebo7-*
大功告成!
- 注意
安装完之后,运行gazebo
可能会报错:VMware: vmw_ioctl_command error Invalid argument.
此错误是由于VMWare开了显示器的3D图形加速功能,具体解决方法:
先关闭虚拟机,然后通过右击VMWare虚拟机选择“设置”--“显示器”选项,关机“3D图形加速”功能;
重启虚拟机,重新运行gazebo即可。
See more:Gazebo官网http://gazebosim.org/tutorials?tut=ros_installing&cat=connect_ros