Installation#
ROS2 installation#
This script does the main installation of ROS2 Foxy Fitzroy. For more details, see the official installation doc.
# set up sources
sudo apt update && sudo apt install curl gnupg2 lsb-release
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'
# install ros package
sudo apt update
sudo apt install ros-foxy-desktop
sudo apt install ros-foxy-ros-base
# source the environment
source /opt/ros/foxy/setup.zsh
echo "source /opt/ros/foxy/setup.zsh" >> ~/.zshrc
# autocompletion tool
sudo apt install -y python3-pip
pip3 install -U argcomplete
# install rosdep
sudo apt install -y python3-rosdep
sudo rosdep init
rosdep update
# install colcon
sudo apt install python3-colcon-common-extensions
# tests : run in two consoles
ros2 run demo_nodes_cpp talker
ros2 run demo_nodes_cpp listener
ROS2 workspace#
This section describes how to create the workspace where your code will be. For more details, see the official doc.
source ROS2 environment (if not already done when the terminal is launched).
create the workspace and source folders :
mkdir -p ~/ros_workspace/src cd ~/ros_workspace/src
clone a tutorial repo :
git clone https://github.com/ros/ros_tutorials.git -b foxy-devel
make sure all dependencies are fine (make sure to run it from the workspace folder) :
cd ~/ros_workspace rosdep install -i --from-path src --rosdistro foxy -y
build the repo (make sure to run it from the workspace folder)
colcon run