[2023-2] Mobility Service 강좌 정리본
1. What is ROS?
- 로봇 운영 및 제어를 위한 운영 체제
- 로봇 응용 프로그램을 위한 소프트웨어 패키지
2. Overview of ROS Architecture
- DDS를 통한 하드웨어 추상화 모빌리티
3. Why ROS in Mobility Service?
- 특정 패키지를 사용할 수 있음
- 평가를 위한 전체 패키지 ROS 프로그래밍 개요
4. Basic ROS Setup
- Virtualbox 7.0.6, Ubuntu 20.04 LTS, ROS 2 (완료) : 용량은 매우 크게 해줌
- Terminal에 들어가서 차례대로 밑의 코드들을 입력해주고 세팅 완료하기
(1) 지역 설정
$ 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
(2) 소스 설정
$ 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 focal main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
- 밑의 사진처럼 복사 붙여넣기 와리가리하면 되는데 힘드니까
- (윈도우키) gedit 검색하면 텍스트 편집기 나오는데 거기에 붙여넣기 하고 다 복사해서 넣으면 된다.
- 복사, 붙여넣기할 때 쉬프트를 추가해서 눌러줘야한다!!!
3. ROS2 패키지 설치
$ sudo apt update
$ sudo apt install ros-foxy-desktop ros-foxy-rmw-fastrtps* ros-foxy-rmw-cyclonedds*
4. ROS2 패키지 설치 확인
- 두 개를 동시에 돌려야 함 : 쉬프트 + 컨트롤 + N 누르면 터미널 하나 더 뜬다!
$ source /opt/ros/foxy/setup.bash
$ ros2 run demo_nodes_cpp talker
$ source /opt/ros/foxy/setup.bash
$ ros2 run demo_nodes_py listener
- 밑의 사진처럼 Hello 어쩌고 계속 뜨면 성공
5. ROS 개발 툴 설치
$ sudo apt update && sudo apt install -y \
build-essential \
cmake \
git \
libbullet-dev \
python3-colcon-common-extensions \
python3-flake8 \
python3-pip \
python3-pytest-cov \
python3-rosdep \
python3-setuptools \
python3-vcstool \
wget
$ python3 -m pip install -U \
argcomplete \
flake8-blind-except \
flake8-builtins \
flake8-class-newline \
flake8-comprehensions \
flake8-deprecated \
flake8-docstrings \
flake8-import-order \
flake8-quotes \
pytest-repeat \
pytest-rerunfailures \
pytest
$ sudo apt install --no-install-recommends -y \
libasio-dev \
libtinyxml2-dev \
libcunit1-dev
6. ROS 2 빌드 테스트
$ source /opt/ros/foxy/setup.bash
$ mkdir -p ~/robot_ws/src
$ cd ~/robot_ws/
$ colcon build --symlink-install
7. Run commands 설정
- 저장은 컨트롤 + s 하기
$ nano ~/.bashrc
(또는 vim ~/.bashrc 또는 xed ~/.bashrc)
source /opt/ros/foxy/setup.bash
source ~/robot_ws/install/local_setup.bash
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
source /usr/share/vcstool-completion/vcs.bash
source /usr/share/colcon_cd/function/colcon_cd.sh
export _colcon_cd_root=~/robot_ws
export ROS_DOMAIN_ID=7
export ROS_NAMESPACE=robot1
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
# export RMW_IMPLEMENTATION=rmw_connext_cpp
# export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
# export RMW_IMPLEMENTATION=rmw_gurumdds_cpp
# export RCUTILS_CONSOLE_OUTPUT_FORMAT='[{severity} {time}] [{name}]: {message} ({function_name}() at {file_name}:{line_number})'
export RCUTILS_CONSOLE_OUTPUT_FORMAT='[{severity}]: {message}'
export RCUTILS_COLORIZED_OUTPUT=1
export RCUTILS_LOGGING_USE_STDOUT=0
export RCUTILS_LOGGING_BUFFERED_STREAM=1
alias cw='cd ~/robot_ws'
alias cs='cd ~/robot_ws/src'
alias ccd='colcon_cd'
alias cb='cd ~/robot_ws && colcon build --symlink-install'
alias cbs='colcon build --symlink-install'
alias cbp='colcon build --symlink-install --packages-select'
alias cbu='colcon build --symlink-install --packages-up-to'
alias ct='colcon test'
alias ctp='colcon test --packages-select'
alias ctr='colcon test-result'
alias rt='ros2 topic list'
alias re='ros2 topic echo'
alias rn='ros2 node list'
alias killgazebo='killall -9 gazebo & killall -9 gzserver & killall -9 gzclient'
alias af='ament_flake8'
alias ac='ament_cpplint'
alias testpub='ros2 run demo_nodes_cpp talker'
alias testsub='ros2 run demo_nodes_cpp listener'
alias testpubimg='ros2 run image_tools cam2image'
alias testsubimg='ros2 run image_tools showimage'
세팅 완료 ! 다음부터는 거북이를 움직여보자-!