ROS2 (Foxy) Installation
The main tutorial page for ROS2 Foxy can be found here: https://docs.ros.org/en/foxy/index.html
It is recommended to install a Long-Term Suppport (LTS) ROS2 distro. This tutorial describes the installation of ROS2 Foxy on Ubuntu 20. There are two ways to install ROS2: 1) from source and 2) from binary (Debian installer).
Step 1: Make sure you already install the compatible distribution of Ubuntu. For ROS2 Foxy, you need Ubuntu 20.
Step 2: Install ROS2. It is recommended to install the “Desktop Install” ROS2 installation.
To install ROS2 from Debian installer, follow the instruction here: https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html
Step 3: Create and build your overlay ROS2 workspace, let’s say it is called “ros2_ws”, in home directory.
1 2 3 |
mkdir -p ~/ros2_ws/src cd ~/ros2_ws colcon build |
Step 4: Source ROS2 from ~/.bashrc so that you don’t need to source it every time you open a new terminal. First, open your bashrc by using gedit:
1 |
gedit ~/.bashrc |
After that, add the following in your bashrc file:
1 2 3 |
source /opt/ros/foxy/setup.bash source install/local_setup.bash source install/setup.bash |
Step 5: Check your ROS2 installation by running a simple publisher and a simple listener.
Open a terminal and type the following to run a simple publisher node called “talker”:
1 |
ros2 run demo_nodes_cpp talker |
Afterwards, open another terminal and run a simple listener node called “listener”:
1 |
ros2 run demo_nodes_py listener |
Step 6: Install Gazebo 11.
Follow the following installation instruction: http://gazebosim.org/tutorials?tut=install_ubuntu
Now you can launch Gazebo by typing the following on a terminal:
1 |
gazebo |
Step 7: Install Gazebo-ROS packages. It is easy to install it from binary:
1 |
sudo apt install ros-foxy-gazebo-ros-pkgs |
Step 8: Install colcon
1 |
sudo apt install python3-colcon-common-extensions |
Step 9: Install git
1 |
sudo apt install git |
Step 10: Install the development tools:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
sudo apt update && sudo apt install -y \ build-essential \ cmake \ git \ libbullet-dev \ python3-colcon-common-extensions \ python3-flake8 \ python3-pip \ python3-pytest-cov \ python3-rosdep \ python3-setuptools \ python3-vcstool \ wget # install some pip packages needed for testing python3 -m pip install -U \ argcomplete \ flake8-blind-except \ flake8-builtins \ flake8-class-newline \ flake8-comprehensions \ flake8-deprecated \ flake8-docstrings \ flake8-import-order \ flake8-quotes \ pytest-repeat \ pytest-rerunfailures \ pytest # install Fast-RTPS dependencies sudo apt install --no-install-recommends -y \ libasio-dev \ libtinyxml2-dev # install Cyclone DDS dependencies sudo apt install --no-install-recommends -y \ libcunit1-dev |
Step 11: Install ROS2 Control packages from source (in your overlay workspace). It is recommended to install it from source to get the up-to-date capabilities as ROS2 Control is still in the development.
1 2 3 4 5 6 7 8 9 |
sudo apt-get install <code>ros-foxy-hardware-interface cd ~/ros2_ws/src git clone -b foxy-devel https://github.com/ros-controls/control_msgs git clone https://github.com/ros-controls/control_toolbox git clone https://github.com/ros-controls/ros2_control.git git clone https://github.com/ros-controls/ros2_controllers.git git clone https://github.com/ros-controls/ros2_control_demos.git cd ~/ros2_ws colcon build |
Installing ROS2 Control Demos is optional, but it is good to install it to learn from the demos.
Step 12: Install Gazebo_ROS2_Control
1 |
sudo apt-get install ros-foxy-gazebo-ros2-control |
Optional packages – The steps below are optional, i.e. you can do them if you want to install some additional packages.
Step 13 (optional): Install ROS2 Foxy demos and examples.
1 2 3 |
sudo apt install ros-foxy-ros-testing git clone -b foxy https://github.com/ros2/demos git clone -b foxy https://github.com/ros2/examples |