Installing ROS 2 Foxy
We will walk through the installation process step-by-step, ensuring that you understand each command.
Step 1: Set Up Your Ubuntu Machine
Ensure you are using Ubuntu 20.04 LTS, the recommended version for ROS Foxy.
Update your system’s package index before installation:
sudo apt update sudo apt upgradesudo: Run the command with administrative privileges.apt update: Fetches the latest updates for the package index.apt upgrade: Installs the latest versions of installed packages.
Step 2: Set Up the ROS 2 Package Sources
Add the ROS 2 repository to your system:
sudo apt install software-properties-common sudo add-apt-repository universe sudo apt updateThis ensures that the system can download packages from the ROS repository.
Step 3: Add the ROS 2 Keys
You need to add the GPG keys to authenticate ROS packages:
sudo apt update && sudo apt install curl -y sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -Add the repository to your sources list.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
Step 4: Install ROS 2 Foxy
Install the desktop version of ROS Foxy, which includes commonly used ROS 2 tools:
sudo apt install ros-foxy-desktopThis installs the core ROS 2 packages, RViz (a visualization tool), and Gazebo (a simulation tool).
Step 5: Set Up Your Environment
Source your ROS 2 installation so that ROS commands work correctly:
source /opt/ros/foxy/setup.bashTo avoid running this every time, add the command to your
.bashrcfile:echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc source ~/.bashrc
Last updated