해당 실습 자료는 표윤석, 임태훈 “ROS2로 시작하는 로봇 프로그래밍” 루비페이퍼 (2022)를 참고하여 제작하였습니다.

ROS 패키지


프로그래밍 언어를 배울 때 처음에 등장하는 Hello World는 화면에 Hello World라는 문구를 출력하는 것으로 시작합니다. 이번장에서는 ROS 2의 가장 기본적인 구성인 패키지를 생성하는 방법에 대해 다뤄보도록 하겠습니다.

패키지 생성



$ mkdir ros2_ws
$ cd ros2_ws
$ mkdir src
$ cd src

# ros2 pkg create [패키지이름] --build-type [빌드 타입] --dependencies [의존하는패키지1] [의존하는패키지n]

$ ros2 pkg create topic_helloworld --build-type ament_python --dependencies rclpy std_msgs
.
├── topci_helloworld
│   └── __init__.py
├── resource
│   └── topci_helloworld
├── test
│   ├── test_copyright.py
│   ├── test_flake8.py
│   └── test_pep257.py
├── package.xml
├── setup.cfg
└── setup.py

3 directories, 8 files

패키지 설정


Creating your first ROS 2 package - ROS 2 Documentation: Foxy documentation