1. 사전 준비- catkin workspace 만들기


ROS는 catkin이라는 빌드 시스템을 사용합니다. 기존 c/c++ cross-platform 개발을 경험하셨다면 cmake에 익숙하실텐데, 이와 매우 비슷합니다. 😎

파일 구조 관점에서, ROS Application은 여러 Package들로 이루어집니다.

이들 Package가 소스 파일을 담고 있고, catkin이 이들을 빌드하여 실행 프로그램들을 만들죠.

$ mkdir -p ~/catkin_ws/src  # 내부 폴더까지 만듦.
$ cd ~/catkin_ws/ 
$ catkin_make
$ echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc 

source ~/… 는 해당 workspace의 환경설정 내용을 ROS 시스템에 인식시킨다고 이해하면 됩니다. bashrc에 넣어버리면 매번 sourcing할 필요 없이, 터미널을 켤 때마다 자동으로 sourcing됩니다.

catkin_make를 실행하면, build, devel, src 폴더가 만들어집니다.

The catkin_make  command is a convenience tool for working with catkin workspaces . Running it the first time in your workspace, it will create a CMakeLists.txt  link in your 'src' folder.

Untitled

2. 패키지 생성

패키지를 생성하여 C++과 Python으로 간단한 정보를 pub하고 sub하는 예제를 만들어 보겠습니다.

$ cd ~/catkin_ws/src
$ catkin_create_pkg topic_test std_msgs rospy roscpp