Skip to content

Instructions for installing ROS and Gazebo!

Catharine McGhan edited this page Jul 2, 2021 · 4 revisions

Gazebo is a dynamic (3D) simulator that was developed to work with ROS. There are several quadcopter models that work in Gazebo and are controllable via ROS messaging.

See the hector_quadrotor instructions elsewhere on the wiki after installing Ubuntu bash + ROS + Gazebo, for an easy-to-get-started UAV model that works well in Gazebo.

As of late Spring 2020, Ubuntu 20.04 is out, but ROS does not really support this well yet. Please stick with Ubuntu 18.04 and ROS melodic for now!

Table of Contents

Install an Ubuntu bash shell to your computer:

If you've got Mac OSX, some pre-Win10 version of Windows, or otherwise want to make ROS work on Windows 10...

  1. Install VirtualBox
  2. Download the Ubuntu 18.04 desktop ISO
  3. Install Ubuntu 18.04 as a Virtual Machine under VirtualBox. (Instructions: link. Recommended CPU cores = 2-4, recommended memory = 4GB-8GB, recommended disk size = 20GB-40GB.)
  4. Start up the Ubuntu 18.04 VM under VirtualBox
(Note that, under Windows, the best/easiest/fastest way to get ROS+Gazebo working _well_ is to go dual-boot. See this external website link as an example of how to do that, but just be aware that you should absolutely back up all of your personal data first if you want to go this route, and that you need to be a good bit more careful as you go. You'll also need to look up a few things, such as what keystroke you need to use to get into your computer's BIOS menu upon reboot / boot up.)

If you've got a flavor of Linux on your computer already, or you're an adventurous Win/Mac user...

  1. Download the Ubuntu 18.04 desktop ISO
  2. Set up Ubuntu to run dual-boot on your computer. (See: link or link from Windows, link from Mac OSX, link from another flavor of Linux.)

Once you have an Ubuntu bash interface (of whatever type)...

If you are installing Ubuntu 16.04 LTS: 1. Install ROS kinetic and gazebo. Instructions are here

    1. (Note: if you install `ros-kinetic-desktop-full`, you get Gazebo along with it.)

1. Set up your catkin workspace. Instructions are here

If you are installing Ubuntu 18.04 LTS: 1. Install ROS melodic and gazebo. Instructions are here

    1. (Note: if you install `ros-melodic-desktop-full`, you get Gazebo along with it.)

1. Set up your catkin workspace. Instructions are here

From here, you can start playing with ROS and Gazebo and get different models flying around in the sim.



Note for Windows 10 machines (*only if you don't care about ROS working!*)...

Probably the easiest way to get Ubuntu on your system is to install the Ubuntu app. However, there are some issues with this...

  1. You need to have at least the Fall Creators Update (later than 2017) to get Bash on Ubuntu on Windows functionality / the Windows Subsystem for Linux (or WSL for short) and then be able to run the Ubuntu app properly.
  2. There are two versions of the Windows Subsystem for Linux as of 2020-2021 or so. WSL1 should still be selected by default, but ROS1 messaging won't work under it properly at all. WSL2 seems to sort-of (potentially) support ROS1 messaging. *****HOWEVER!***** If you use WSL2 instead of WSL1, then you won't be able to run VirtualBox VMs or other VMs under Win10! *****Use WSL2 at your own risk!*****

Ubuntu 20.04 installation and setup instructions for trying ROS1 (still broken for WSL1, works for WSL2!)

  1. Update Windows to the newest major update (for the most-recent Ubuntu app), at least 1903 or 1909 for WSL2
    1. To check your version and build number, select Windows logo key + R, type winver, select OK. (If the "OS Build" is 18362.1049+ or 18363.1049+, with the minor build # over .1049, then you're good for WSL2!)
  2. Install the Ubuntu app -- follow these instructions (and/or see also: link)
    1. If Win10 is 1903 or 1909 or newer, install WSL2 instead of WSL1 at this step
      1. You may want to make sure you're updated to using the newest version of WSL2 by downloading this .msi installer file and then running it, too
    2. I recommend that you install the specific Ubuntu 20.04 app at this step -- see link
  3. Install VcXsrv
Make sure you restart your computer before proceeding if you had to enable the "Windows Subsystem for Linux" as part of the above process!

Then:

  • Run VcXsrv XLaunch program
    • Select Multiple Windows, Display number 0
    • Select Start no client
    • Select/checkboxes for Clipboard and Primary Selection and Native opengl and Disable access control
    • It's recommended that you Save configuration to the desktop at the end so you can just double-click the file the next time
  • Run the Ubuntu 20.04 app
  • Run at the Ubuntu 20.04 app commandline:
 sudo apt update
 sudo apt upgrade
 sudo apt install net-tools gedit gnome-terminal
 vi ~/.bashrc
  • Inside .bashrc, use the arrow keys to scroll down to the very bottom of the file, and the end of the last line.
Hit the 'a' key, then the 'Enter' key, then type:
 export DISPLAY="`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"

Hit the 'Esc' key, type ':w' (colon w) and hit enter, type ":q" (colon q) and hit enter.

  • Then run at the Ubuntu 20.04 app commandline:
 source ~/.bashrc
  • And then try opening gnome-terminal (which should pop up as a new terminal in a new GUI window):
 gnome-terminal &
  • Then try installing ROS1:
 sudo apt install git
 sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
 sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
 sudo apt update
 sudo apt install ros-noetic-desktop-full
 echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
 source ~/.bashrc
 sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
 sudo rosdep init
 rosdep update
 mkdir -p ~/catkin_ws/src
 cd ~/catkin_ws/
 catkin_make
 source devel/setup.bash
 roscore

roscore should run.

  • You may need to:
 export LIBGL_ALWAYS_INDIRECT=0

in order for gazebo to run properly.

Note that ROS still does NOT currently work under the "Bash on Ubuntu on Windows" Windows Subsystem for Linux on the newer Windows 10 major updates if you are using WSL1 instead of WSL2! To install a working version of ROS for the older Linux subsystem, you will need to install VirtualBox (see above) or use WSL2.

**UNTESTED!!!** Instructions for swapping between WSL1 and WSL2 for your Ubuntu app

The following has not been tested as of yet -- use at your own caution!

Generally discussed under "Step 3 Enable Virtual Machine Feature" here and "Set your distribution version to WSL 1 or WSL 2" here as well as here

Other refs:

Change the version of WSL used by an Ubuntu app

  • Note that the wsl --set-distribution command may take a few minutes...
  1. Get the list first
 wsl --list --verbose
  1. Set the WSL version for the distribution
 wsl --set-version <distribution name> <versionNumber>

Replace <distribution name> with the actual name of your distribution (from wsl -l -v) and <versionNumber> with the number '1' or '2' (1 for WSL1 and 2 for WSL2).

Note that if any distribution is using WSL2, that you may not be able to disable the WSL2 feature.

Enable WSL2:

 dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart 

Disable WSL2 and enable WSL1:

 dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /all /norestart
 dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Disable WSL1:

Not sure why you'd want to disable WSL1, but for completeness:

 dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

If you've enabled or disabled either or both of the WSL1 or WSL2 Win10 features, you're going to want to restart again before trying to use any Ubuntu app or Virtual Machine program again.



Old Win10 WSL1 instructions below, kept for reference re: prior versions of Win10 updates

Ubuntu 18.04 installation and setup instructions for trying ROS1 (still broken)

1. Update Windows to the newest major update (for the most-recent Ubuntu app) 1. Install the Ubuntu app 1. Install XMing

Make sure you restart your computer before proceeding if you had to enable the "Windows Subsystem for Linux" as part of the above process!

Then:

  1. Run XMing
  2. Run the Ubuntu app (/ Bash on Ubuntu on Windows)
  3. Run at the Ubuntu app (/ Bash on Ubuntu on Windows) commandline:
 echo "export DISPLAY=:0" >> ~/.bashrc
 source ~/.bashrc
 sudo apt update & sudo apt install gedit gnome-terminal

Note that if you're using the vagrant-rss scripts to install ROS, then aptdcon and dbus need to be installed for the ROS stuff to install / work at all due to the methods being used in the scripts for installation. Install these via the following:

 sudo apt install dbus dbus-x11
 sudo service dbus start
 sudo systemd-machine-id-setup

(Ref.s: link, which discusses installing dbus and creating a machine-id)

And then try installing ROS using the vagrant-rss scripts:

 sudo apt install git
 mkdir git_pulls
 cd git_pulls
 git clone https://github.com/AS4SR/vagrant-rss.git
 cd vagrant-rss/single_installers
 sudo su
 ./quick_install_ros_gazebo_and_catkin_ws.sh kinetic @USER@

replacing @USER@ with your username.

This will have roscore working -- but -very- laggy -- under Windows 10 Fall Creators Update (or newer). Try this out in a new `gnome-terminal` window:

 # tab 1:
 source ~/catkin_ws/devel/setup.bash
 roscore
 # tab 2:
 source ~/catkin_ws/devel/setup.bash
 rostopic echo /testint
 # tab 3:
 source ~/catkin_ws/devel/setup.bash
 rostopic pub /testint std_msgs/Int32 "data: 5"

Note that ROS still does NOT currently work under the "Bash on Ubuntu on Windows" Windows Subsystem for Linux on the newer Windows 10 major updates if you are using WSL1 instead of WSL2! To install a working version of ROS for the older Linux subsystem, you will need to install VirtualBox (see above) or use WSL2 (see above).

Ubuntu 16.04 installation and setup instructions for trying ROS1 (hugely broken)

Probably the easiest way to get Ubuntu 16.04 on your system is to:

  1. Update Windows to the Fall Creators Update (for the most-recent Ubuntu app)
    1. Otherwise, update Windows to the Creators Update (for Bash on Ubuntu on Windows)
  2. Install the Ubuntu app if you have the Fall Creators Update (Oct-Nov 2017)
    1. Install Bash on Ubuntu on Windows if you have the Creators Update (early-2017)
  3. Install XMing
Make sure you restart your computer before proceeding if you had to enable the "Windows Subsystem for Linux" as part of the above process!

Then:

  1. Run XMing
  2. Run the Ubuntu app (/ Bash on Ubuntu on Windows)
  3. Run at the Ubuntu app (/ Bash on Ubuntu on Windows) commandline:
 echo "export DISPLAY=:0" >> ~/.bashrc
 source ~/.bashrc
 sudo apt update & sudo apt install gedit gnome-terminal

Note that if you're using the vagrant-rss scripts to install ROS, then aptdcon and dbus need to be installed for the ROS stuff to install / work at all due to the methods being used in the scripts for installation. Install these via the following:

 sudo apt install aptdcon dbus
 sudo service dbus start

(Ref.s: link, link, and you may need to create the machine-id manually via link, but -don't- do link because we want it using Unix sockets not Windows protocols)

And then try installing ROS using the vagrant-rss scripts:

 sudo apt install git
 mkdir git_pulls
 cd git_pulls
 git clone https://github.com/AS4SR/vagrant-rss.git
 cd vagrant-rss/single_installers
 sudo su
 ./quick_install_ros_gazebo_and_catkin_ws.sh kinetic @USER@

replacing @USER@ with your username.

This will have roscore working -- but -very- laggy -- under Windows 10 Fall Creators Update (or newer). Try this out in a new gnome-terminal window:

 # tab 1:
 source ~/catkin_ws/devel/setup.bash
 roscore
 # tab 2:
 source ~/catkin_ws/devel/setup.bash
 rostopic echo /testint
 # tab 3:
 source ~/catkin_ws/devel/setup.bash
 rostopic pub /testint std_msgs/Int32 "data: 5"

Note that ROS does NOT currently work under the "Bash on Ubuntu on Windows" Windows Subsystem for Linux on the Windows 10 Creators Update! To install a working version of ROS for the older Linux subsystem, you will need to install VirtualBox (see above).

  • This is due to issues with ros_comm! (See link and link for more information.)
  • As of 2017-05-17 and the Windows Creators Update version of the Windows Subsystem for Linux (WSL), you may be able to install and compile under bash on Win10, but if you try running roscore and then rostopic echo /rosout, you'll get a TCP/IP warning/error after awhile, saying that you can't connect.
  • If you try running roslaunch hector_quadrotor_demo indoor_slam_gazebo.launch, because of the ros_comm TCP/IP stack issues, the controller_manager will 'warn' that it isn't able to load the controllers, and none of the services necessary to control the UAV are loaded -- rosservice list does now show /enable_motors or any of the /controller_manager/* services, an example of what you should see is here: link).
=== Partial fix of ros_comm issue under Windows 10 Creators Update (general pub-sub topics seem to work, hector_quadrotor still not working):
cd ~/Downloads && mkdir -p ros_comm_fix/src
cd ros_comm_fix/src
git clone -b transport_tcp_kinetic https://github.com/andyli/ros_comm.git
catkin_init_workspace
cd ..
catkin_make
catkin_make install
Clone this wiki locally