The steps are clearly defined here. When I followed the instructions, I didn’t encounter any problems but for completeness here I write most of the steps verbatim.
The original instructions start with checking
locele. I find that the default
locale for standard Ubuntu English installation on x86 PC is already
en_US.UTF-8 but I would make sure and check the locale.
Example settings from my machine (Although the selected language was English
during installation, my timezone is İstanbul/Turkey and I think this is the
reason behind some
Open a terminal and run the command
locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC=tr_TR.UTF-8 LC_TIME=tr_TR.UTF-8 LC_COLLATE="en_US.UTF-8" LC_MONETARY=tr_TR.UTF-8 LC_MESSAGES="en_US.UTF-8" LC_PAPER=tr_TR.UTF-8 LC_NAME=tr_TR.UTF-8 LC_ADDRESS=tr_TR.UTF-8 LC_TELEPHONE=tr_TR.UTF-8 LC_MEASUREMENT=tr_TR.UTF-8 LC_IDENTIFICATION=tr_TR.UTF-8 LC_ALL=
If you don’t see
UTF-8, check this
Let’s continue with the installation.
sudo apt install software-properties-common sudo add-apt-repository universe sudo apt update && sudo apt install curl sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg 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 sudo apt update sudo apt upgrade sudo apt install ros-humble-desktop
At the end of the above commands, the most complete ROS2 packages (desktop)
should be installed (around 1.1k new packages and 1 GB). By default, ROS Humble
is installed on path
/opt/ros/humble. To use
ros2 commands either we should
source /opt/ros/humble/setup.bash for each terminal session or we should
add it the end of the
.bashrc. If you are planning to work with ROS, adding it
to the end of the
.bashrc is more convenient (my recommendation).
🥳 Enjoying? Join our free newsletter ✉️ to get a copy of future posts! Don't forget to ✅ follow us!
Don't worry, you can always opt-out.
Finally, test our setup. Open two terminals then type
source /opt/ros/humble/setup.bash ros2 run demo_nodes_cpp talker
source /opt/ros/humble/setup.bash ros2 run demo_nodes_py listener
demo_nodes_py use C++ and Python bindings for ROS,
talker sends Hello World message with a counter and
captures messages and prints them. Both C++ and Python programs support sending
and receiving test messages thus all the given commands are valid. But testing
both C++ and Python bindings at the same time is a good idea.
# All commands are valid ros2 run demo_nodes_cpp talker ros2 run demo_nodes_cpp listener ros2 run demo_nodes_py talker ros2 run demo_nodes_py listener
💡 Hint: ROS 2 supports TAB completion. Feel free to press TAB while writing commands and parameters (separated by spaces) after
The expected output is shown below.
🤓 Reading one more post from asynx?
How to install WSL on a Windows machine not connected to the Internet