ROS2 Installation

1 Version Information

Release version release date Discontinuation date
Humble May 23, 2022 May 2027
Galactic May 23, 2021 November 2022
Foxy June 5, 2020 May 2023

2 Version selection

The version selection of ROS2 is : Foxy
The version selection for Linux is : Ubuntu Focal Fossa 20.04 64-bit

3 Source code installation

(Choose this installation method, it will take a long time)

3.1 Check the code

3.1.1 Command line input:

local

3.1.2 Check whether the returned result is UTF-8encoded

  • Yes
    • No processing required
  • No, enter the following command at the command line:
    • sudo apt update && sudo apt install locales
    • sudo locale-gen en_US en_US.UTF-8
    • sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
    • export LANG=en_US.UTF-8

3.2 Add the ROS2 apt repository

3.2.1 Update and installation

  sudo apt update && sudo apt install curl gnupg2 lsb-release

3.2.2 Authorizing GPG Keys

  sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

3.2.3 Add repository

  echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

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

3.4 Get ROS2 source code

3.4.1 Create a workspace

mkdir -p ~/ros2_foxy/src

3.4.2 Switching workspaces

cd ~/ros2_foxy

3.4.3 Download the source code

wget https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos
The following operations take a long time to wait:
vcs import src < ros2.repos

3.5 Install dependencies using rosdep

sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-5.3.1 urdfdom_headers"

3.6 Generate code in the workspace

cd ~/ros2_foxy
colcon build --symlink-install

3.7 Set environment variables

echo "source ~/ros2_foxy/install/setup.bash" >> ~/.bashrc

4 Installation package installation

4.1 Update and installation

sudo apt update && sudo apt install curl gnupg2 lsb-release

4.2 Authorize the GPG key

sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

4.3 Add repository

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

4.4 Download the installation package

Download :https://github.com/ros2/ros2/releases
Install address:~/Downloads/

4.5 Unzip the installation package

4.5.1 Create the installation path

mkdir -p ~/ros2_foxy

4.5.2 Switch to the installation directory

cd ~/ros2_foxy

4.5.3 Unzip the file

tar xf ~/Downloads/ros2-package-linux-x86_64.tar.bz2

4.6 Install and initialize rosdep

4.6.1 Update

sudo apt update

4.6.2 Install rosdep

sudo apt install -y python3-rosdep

4.6.3 Initialize rosdep

sudo rosdep init
rosdep update

rosdep install --from-paths ~/ros2_foxy/ros2-linux/share --ignore-src -y --skip-keys "cyclonedds fastcdr fastrtps rti-connext-dds-5.3.1 urdfdom_headers"

4.8 Install the python3 library

sudo apt install -y libpython3-dev python3-pip
pip3 install -U argcomplete

4.9 Set environment variables

echo "source ~/ros2_foxy/install/setup.bash" >> ~/.bashrc

5 Source Installation

( recommended for this installation)

5.1 Check the code

5.1.1 Command line input:

local

5.1.2 Check whether the returned result is UTF-8encoded

  • Yes
    • No processing required
  • · No, enter the following command at the command line:
    • sudo apt update && sudo apt install locales
    • sudo locale-gen en_US en_US.UTF-8
    • sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
    • export LANG=en_US.UTF-8

5.2 Add the ROS2 apt repository

5.2.1 Update and installation

  sudo apt update && sudo apt install curl gnupg2 lsb-release

5.2.2 Authorizing GPG Keys

  sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

5.2.3 Add repository

  echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

5.3 Install the ROS2 package

5.3.1 Update

sudo apt update

5.3.2Installation

sudo apt install ros-foxy-desktop

5.4 Set environment variables

  • ros2 environment variable settings

echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc

  • Environment variable settings after compiling the project

echo "~/'working directory'/src/install/setup.bash" >> ~/.bashrc

moveit2 Installation

1 Refresh environment variables

source /opt/ros/foxy/setup.bash

2 Install rosdep to install system dependencies

sudo apt install python3-rosdep

3 Update

sudo rosdep init
rosdep update
sudo apt update
sudo apt dist-upgrade

4 Install and use mixins

sudo apt install python3-colcon-common-extensions
sudo apt install python3-colcon-mixin

colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml

colcon mixin update default

5 Install vcstool

sudo apt install python3-vcstool

6 Create a workspace and download the source code

mkdir -p ~/ws_moveit2/src
cd ~/ws_moveit2/src
git clone https://github.com/ros-planning/moveit2_tutorials.git -b foxy
vcs import < moveit2_tutorials/moveit2_tutorials.repos

7 Download the packages required for the build

rosdep install -r --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y

8 Building the Workspace

cd ~/ws_moveit2
colcon build --mixin release

results matching ""

    No results matching ""