- ROS란?

로봇 개발을 위해 사용되는 오픈 소스 운영체제. 다양한 로봇의 공통적인 기능인 인지, 판단, 구동을 보다 쉽게 구현할 수 있도록 지원한다.

로봇을 개발할 때 센서, 알고리즘, 엑츄에이터를 개별적으로 구현하는 것은 매우 복잡하다. 이를 해결하기 위해 ROS가 등장한 것이다.
- 패키지 시스템: 로봇 개발을 모듈화하여 필요한 기능을 조합 가능
- 시뮬레이션 지원: Gazebo, Ignition 등의 시뮬레이션 도구 제공
- 임베디드 지원: Micro ROS, rosserial 등 활용 가능
- 시각화 및 디버깅: Rviz, Rqt 등의 툴 제공
- 연구 및 상용화 지원: 연구자는 공통된 소스로 비교 분석 가능, 사용자는 빠른 상용화 가능
- 기본 설정 및 ROS 설치
해당 강의는 ubuntu 18.04 + ROS Melodic을 사용한다.
하지만 최신 버전의 Vscode는 이에 호환되지 않는다. 그렇다고 우분투의 버전을 올리면 ROS Melodic이 호환되지 않는다.
아래 링크로 들어가서 낮은 버전의 vscode를 받아야한다.
https://update.code.visualstudio.com/1.64.2/linux-deb-x64/stable
터미널로 가서 ROS를 설치를 해보자.
# 기본 세팅
$ sudo apt-get purge modemmanager
$ sudo adduser [사용자 계정 이름]
$ sudo usermod -aG sudo [사용자 계정 이름]
# Ubuntu ROS Melodic 설치
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
$ curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
$ sudo apt update
$ sudo apt install ros-melodic-desktop-full -y
$ echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
$ sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
$ sudo rosdep init
$ rosdep update
이후 필요한 패키지들은 다음과 같은 명령어로 설치할 수 있다.
$ sudo apt-get install ros-melodic-<package name>
roscore 명령어를 입력하면 다음과 같이 나올 것이다. 그러면 설치 완료다.
$ roscore
... logging to /home/kimsooyoung/.ros/log/5b440a74-4cda-11eb-a263-9cb6d08bf543/roslaunch-kimsooyoung-XPS-13-9370-10527.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://localhost:38251/
ros_comm version 1.14.10
SUMMARY
========
PARAMETERS
* /rosdistro: melodic
* /rosversion: 1.14.10
NODES
auto-starting new master
process[master]: started with pid [10537]
ROS_MASTER_URI=http://localhost:11311/
setting /run_id to 5b440a74-4cda-11eb-a263-9cb6d08bf543
process[rosout-1]: started with pid [10559]
started core service [/rosout]
다음과 같은 예제를 통해 설치가 잘 되었는지 확인해보자.
$ rosrun turtlesim turtlesim_node
# 새 터미널 실행
$ rosrun turtlesim turtle_teleop_key

마지막으로 자주 사용되는 명령어를 단축해놓으면 편하다. bash 파일을 수정하자.
$ gedit ~/.bashrc
# 파일 제일 아래에 다음과 같은 내용 입력
alias eb='gedit ~/.bashrc'
alias sb='source ~/.bashrc'
alias gs='git status'
alias gp='git pull'
alias cw='cd ~'
alias cs='cd ~/src'
alias cm='cd ~ && catkin_make'
alias cma='catkin_make -DCATKIN_WHITELIST_PACKAGES=""'
alias cop='catkin_make --only-pkg-with-deps'
alias sds='source devel/setup.bash'
alias axclient='rosrun actionlib axclient.py'
# 종료 후 터미널 업데이트
$ source ~/.bashrc
출처)
https://www.youtube.com/watch?v=j2kBX8G6-bY&t=2s
https://www.youtube.com/watch?v=OrvwFIgcK5c
'Robotics > ROS' 카테고리의 다른 글
| 4. rosrun, roslaunch, launch (0) | 2025.02.10 |
|---|---|
| 3. roscore, rosmaster, rosnode (0) | 2025.02.10 |
| 2. Gazebo 환경과 사용법 (0) | 2025.02.10 |