ROS2 learning (1, ROS2 installation)

ROS2 official installation
https://docs.ros.org/en/galactic/Installation/Ubuntu-Install-Debians.html

I originally wanted to find the same installation guidance document as ros1, and I can choose according to my own system. However, I did not find a direct instruction tutorial.
However, in the installation instructions of each version of ROS2, which versions of the system are supported.
For example, I use ubuntu20.04 to install the foxy version of ROS2. This is also the most used version at present.
insert image description here
I have looked at some other versions. Currently, the lowest ubuntu version supported by ROS2 is 20.04. So if you are using a lower system version, it is recommended to upgrade the system. I haven't tried installing on a lower version myself, so I'm not sure if there are other problems.

installation steps

There are also official tutorials on the Internet that introduce the way to install through source code. Personally, I don't recommend it, because the installation process requires scientific Internet access, and the process is relatively long, and problems are prone to occur in the middle. It is still easier to install the package. It is more friendly to beginners.

1. Set the encoding format

The ubuntu system may not support UTF-8 encoding by default, so you need to confirm your own system to ensure that it supports UTF-8 encoding

locale  # check for UTF-8

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

locale  # verify settings

If the setting is successful, the display will look like this
insert image description here

2. Set the source

sudo apt install software-properties-common
sudo add-apt-repository universe

3. Add ROS 2 GPG key

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
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

4. ROS2 installation

You can choose to install the desktop version or the base version. For beginners, it is recommended to install the desktop version, which will include various samples and rviz. In the following installation command, there is a python3-argcomplete, which is an auto-completion package for python. In fact, it is for the convenience of double-clicking the tab key to automatically complete when operating the command line.

Desktop version installation

sudo apt install ros-foxy-desktop python3-argcomplete

Base version installation

sudo apt install ros-foxy-ros-base python3-argcomplete

5. Set environment variables

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

6. Test samples

If you installed the desktop version, you can run the sample directly to see the effect
Open a new terminal

ros2 run demo_nodes_cpp talker

Open another terminal

ros2 run demo_nodes_py listener

Guess you like

Origin blog.csdn.net/yangcunbiao/article/details/131692716