ROS

[ROS2] 2. ROS2 Humble 설치

Magin 2024. 2. 1. 23:08
728x90

ROS2 Humble

ROS2를 시작하면서 Humble을 선택한 이유는 버전의 사용기한이 길어서(End of Life) 미리 준비하고자 하는 생각이다.

 

이전 포스트에서도 언급한대로 우분투 22.04 버전을 설치 후 ROS2를 섪치하는 과정을 담으려고 한다.

 

1. 설치 전 세팅

*아래는 ROS2 Humble버전 공식 사이트이다.

 

Ubuntu (Debian packages) — ROS 2 Documentation: Humble documentation

You're reading the documentation for an older, but still supported, version of ROS 2. For information on the latest version, please have a look at Iron. Ubuntu (Debian packages) Debian packages for ROS 2 Humble Hawksbill are currently available for Ubuntu

docs.ros.org

 

공식문서에서도 언급한 것이 ROS2 설치 전에 UTF-8로 설정을 맞춰주는 과정이다.(아래 명령어를 순서대로 입력!!)

locale  # check for UTF-8
#위에 locale 명령어로 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

 

그 다음으로는 Ubuntu Universe repository 설정에 필요한 패키지 설치

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

 

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

 

아래 명령어는 소스리스트를 repositor에 저장(저장소의 위치를 알려주는 역할)

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

 

 

2. ROS2 Humble 설치

먼저 설치에 앞서 해줘야할 Update&Upgrade !!! 매우중요!!!

sudo apt update
sudo apt upgrade

 

대망의 ROS설치!!(시간이 좀 걸릴 수도 있다.)

sudo apt install ros-humble-desktop

#부가적으로 설치해주면 좋다!!
sudo apt install ros-dev-tools

 

ROS설치를 확인하기 위해 빌드해서 확인해보자

source /opt/ros/humble/setup.bash

 

터미널을 두개를 켜서 다음 명령어를 각각 입력해보자

source /opt/ros/humble/setup.bash
ros2 run demo_nodes_cpp talker #뭔가 익숙한 튜토리얼
source /opt/ros/humble/setup.bash
ros2 run demo_nodes_py listener

 

talker와 listener가 출력이 잘된다면 일단 설치는 완료

 

# 추가적으로 ROS2를 매번 불러오기 귀찮다면

#1.gedit 명령어
gedit ~/.bashrc

#2.vscode 명령어
code ~/.bashrc

#1번과 2번 둘중에 하나를 통해서 아래 명령어 추가
source /opt/ros/humble/setup.bash

#저장 후 소싱
source ~/.bashrc

 

 

#ROS1과 ROS2 차이점

 먼저 ROS1에서는 모든 통신은 ROS master를 거쳐서 수행되기 때문에 보안에 있어서도 취약점이 드러났다.

하지만 ROS2에서는 ROS master 없이 DDS(Data Distribution Service) 사용

 

 

728x90