ROS2 Humble 설치

원래는 노션에 적어놓고 매번 반복하던 내용인데, 아예 블로그에 올려 놓으면 귀찮게 로그인 안해도 볼수 있기에 옮겨 놓음.

설치 환경: Ubuntu 22.04

Ubuntu 설치 시 영문환경으로 하는 것을 강력히 추천. 한글 입력은 https://ahnbk.dev/?p=368를 참고하면 됨.

ROS2 Humble 설치에 대한 공식 문서는 https://docs.ros.org/en/humble/Installation.html 를 참고하길 바람.


Repository 추가 및 Key 등록

sudo apt install software-properties-common
sudo add-apt-repository universe
$ 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

ROS2 설치

$ sudo apt update
$ sudo apt install ros-humble-desktop-full


개발환경 셋업

$ echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
$ echo "export ROS_DOMAIN_ID=<your_domain_id>" >> ~/.bashrc
$ echo "export ROS_LOCALHOST_ONLY=0" >> ~/.bashrc
$ source ~/.bashrc

개발툴 (colcon) 설치

$ sudo apt install python3-colcon-common-extensions

워크스페이스 생성 및 빌드

$ mkdir -p ~/dev_ws/src
$ cd ~/dev_ws
$ colcon build --symlink-install

생성한 워크스페이스 등록

$ echo "source ~/dev_ws/install/setup.bash" >> ~/.bashrc

colcon_cd, colcon 매개변수 자동완성 기능 활성화

$ echo "source /usr/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc
$ echo "export _colcon_cd_root=/opt/ros/humble/" >> ~/.bashrc
$ echo "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash"

DDS 설치 (fastRTPS -> CycloneDDS)

$ sudo apt install ros-humble-rmw-cyclonedds-cpp
$ echo "export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp" >> ~/.bashrc

cyclonedds 설정 파일 생성 및 등록

$ vi ~/cyclonedds.xml
<?xml version="1.0" encoding="UTF-8" ?>
<CycloneDDS xmlns="https://cdds.io/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://cdds.io/config https://raw.githubusercontent.com/eclipse-cyclonedds/cyclonedds/master/etc/cyclonedds.xsd">
    <Domain id="any">
        <General>
            <Interfaces>
                <!-- <NetworkInterface autodetermine="false" name="enp2s0`" priority="default" multicast="default" /> -->
                <NetworkInterface autodetermine="true" priority="default" multicast="default" />
            </Interfaces>
            <AllowMulticast>default</AllowMulticast>
            <MaxMessageSize>65500B</MaxMessageSize>
        </General>
    </Domain>
</CycloneDDS>
$ echo "export CYCLONEDDS_URI=file:///home/<user-name>/cyclonedds.xml

rosdep 및 vcstool 설치

$ sudo apt install python3-rosdep
$ sudo rosdep init
$ rosdep update
$ sudo apt install python3-vcstool

이것으로 기본 설치 완료. 대략 20분 정도 소요됨.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *