-
ROS2 환경 구성드론/시뮬레이터 2022. 5. 19. 23:41
가상머신에 우분투 18.04버전을 설치했는데
강의에서 사용하는 ROS 2 Foxy는 우분투 20.04를 권장한다고 한다....
그래서 이참에 리눅스 사용이 점점 늘어날 것 같아서
가상환경이 아닌 듀얼부팅으로 우분트 20.04를 설치하려고 한다.
환경 구성은 강의 공식 블로그를 참조했다.
ROS 2 Foxy 설치 - Linux20.04
동영상 강의와 다르게, apt-get 키워드가 모두 apt로 변경되었습니다. 이 둘의 차이는 다음 레퍼런스를 참고하시길 바랍니다.
puzzling-cashew-c4c.notion.site
준비물
준비물을 준비하자
1. BalenaEtcher
balena - The complete IoT fleet management platform
Infrastructure and tools to develop, deploy, and manage connected devices at scale. Your first ten devices are always free.
www.balena.io
2. 우분투 20.04
Ubuntu 20.04.4 LTS (Focal Fossa)
Select an image Ubuntu is distributed on three types of images described below. Desktop image The desktop image allows you to try Ubuntu without changing your computer at all, and at your option to install it permanently later. This type of image is what m
releases.ubuntu.com
3. 4Gb 이상 USB
디스크 분할
여분 디스크가 없는 경우 디스크를 분할해서 우분투를 설치해야 한다.
디스크를 분할하는 방법이다.
시작에서 하드 디스크를 검색하면 아래 사진처럼 파티션 만들기가 뜨는데 클릭한다.
클릭시 화면 메인 공간에 오른쪽 클릭 후 불륨 축소를 한다. 축소할 공간 크기를 입력한다. 축소된 공간이 생긴 모습
BalenaEtcher를 이용해 부팅디스크 만들기
BalenaEtcher를 설치한다.
설치된 화면 우분투 ISO파일를 선택한다. USB 선택 부팅 USB 만드는 화면 완성된 모습
우분투 설치
ㅜ우분투 설치 화면 우분투 설치는 아래 블로그를 참조했다.
https://jimnong.tistory.com/676
우분투 리눅스 듀얼부팅 설치방법 정리(윈도우10/윈도우11 기준)
우분투 리눅스 다운로드 방법(Desktop 버전) 우분투 리눅스 설치용 USB 만드는 법(윈도우에서) 우분투 리눅스 설치용 USB 만드는 법(Ubuntu 16.04 에서) 에 이어... 우분투 듀얼부팅 설치방법을 설명하고
jimnong.tistory.com
그리고 우분투를 설치하니까 GPU 드라이버가 설치가 안돼서 다음 명령어를 입력했다.
# 장착된 장치 확인 $ ubuntu-drivers devices # 해당 장치에 맞는 드라이버 자동 설치 $ sudo ubuntu-drivers autoinstall
편의성 프로그램 설치 및 추가 설정
강의에서 알려준 프로그램을 설치했다.
1. Terminator (다중 분할 터미널을 위한 인터페이스)
$ sudo apt update # terminator 설치 $ sudo apt install terminator -y
2. VScode
Download Visual Studio Code - Mac, Linux, Windows
Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications.
code.visualstudio.com
추천하는 Extensions
- Visual Studio IntelliCode
- Project Manager
- ROS
- URDF
- C/C++
- Python
- CMake Tools
- Material Theme
- Code runner
3. 센서인식을 방해하는 프로그램 제거 설정
$ sudo apt purge modemmanager $ sudo adduser [사용자 계정 이름] $ sudo usermod -aG sudo [사용자 계정 이름]
ROS2 Foxy 설치
아래 공식 사이트 내용대로 설치했다.
Ubuntu (Debian) — ROS 2 Documentation: Foxy documentation
Make sure you have a locale which supports UTF-8. If you are in a minimal environment (such as a docker container), the locale may be something minimal like POSIX. We test with the following settings. However, it should be fine if you’re using a differen
docs.ros.org
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 sudo apt update && sudo apt install curl gnupg2 lsb-release 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 $(source /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-foxy-desktop
Gazebo 설치
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - sudo apt update sudo apt install gazebo11 libgazebo11-dev -y # Gazebo ROS 패키지들도 설치해줍니다. sudo apt install ros-foxy-gazebo-ros-pkgs -y # 설치 이후 실행을 통해 확인 gazebo
설치된 화면 Update
sudo apt install ros-foxy-rqt* sudo apt install ros-foxy-image-view sudo apt install ros-foxy-navigation2 ros-foxy-nav2-bringup sudo apt install ros-foxy-joint-state-publisher-gui sudo apt install ros-foxy-xacro
이후 재부팅해야 한다.!!
개발 환경 세팅
Colcon Build system 설치
sudo apt update sudo apt install python3-colcon-common-extensions
workspace 생성 및 빌드
source /opt/ros/foxy/setup.bash mkdir -p ~/gcamp_ros2_ws/src cd ~/gcamp_ros2_ws/src git clone https://github.com/ros/ros_tutorials.git -b foxy-devel cd ../ rosdep install -i --from-path src --rosdistro foxy -y colcon build --symlink-install
빌드가 완료된 모습
명령어 단축하기
gedit ~/.bashrc에는 많은 명령어가 있다고 한다.
자주 쓰는 긴 명령어를 간단하게 단어로 명령어를 쓸 수 있는 방법이 있다고 한다.
gedit ~/.bashrc
여기에 아래 코드 추가하고 저장한다.
alias eb='gedit ~/.bashrc' alias sb='source ~/.bashrc' alias cba='colcon build --symlink-install' alias cbp='colcon build --symlink-install --packages-select' alias killg='killall -9 gzserver && killall -9 gzclient && killall -9 rosmaster' alias rosfoxy='source /opt/ros/foxy/setup.bash && source ~/gcamp_ros2_ws/install/local_setup.bash' source /usr/share/colcon_cd/function/colcon_cd.sh export _colcon_cd_root=~/gcamp_ros2_ws
저장하고 터미널을 재시작한다.
예시로 아래 명령어를 입력해보자.
cd gcamp_ros2_ws cba
정상적으로 작동되면 다음과 같이 뜬다.
ROS 테스트
ROS의 Hellow World 같은 것을 실행해 보자
rosfoxy ros2 run turtlesim turtlesim_node # new terminal rosfoxy ros2 run turtlesim turtle_teleop_key
방향키로 거북이를 조정할 수 있다. 이로써 ROS 세팅이 완료되었다.
'드론 > 시뮬레이터' 카테고리의 다른 글
[ROS2] Launch 파일 작성 (0) 2022.06.06 Gazebo Simulation 실행 및 동작 테스트 (0) 2022.05.29 ROS2 강의 (0) 2022.05.19 PX4 Gazebo설치 및 동작 (0) 2022.05.12 PX4 설치하고 설치 오류 해결 후 동작 확인 (0) 2022.05.07