ROS/ROS 1 Noetic

ROS 1 Noetic - 패키지 생성 및 설정

1. 패키지 생성

  • catkin_create_pkg <package_name> [depend1] [depend2] [depend3]
cd ~/catkin_ws/src
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp

 

2. 패키지 파일 설정  (package.xml 편집)

<?xml version="1.0"?>
<package format="2">
  <!-- 패키지 이름 -->
  <name>ros_tutorials_topic</name>
  
  <!-- 패키지 버전 -->
  <version>0.0.0</version>
  
  <!-- 패키지 설명 -->
  <description>The ros_tutorials_topic package</description>

  <!-- 최초 개발자 정보 -->
  <author email="User@todo.todo">User</author>
  
  <!-- 유지보수 개발자 정보 -->
  <maintainer email="User@todo.todo">User</maintainer>

  <!-- 라이센스 사용 정보 -->
  <license>Apache License 2.0</license>

  <!-- URL 관련 정보 -->
  <!-- website : 웹사이트 -->
  <!-- repository : 레포지토리 -->
  <!-- bugtracker : 버그 관련 -->
  <url type="website">http://wiki.ros.org/ros_tutorials_topic</url>

  <!-- 빌더 툴 -->
  <buildtool_depend>catkin</buildtool_depend>
  
  <!-- 빌드 시 의존성 -->
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>message_generation</build_depend>
  
  <!-- 실행 시 의존성 -->
  <exec_depend>roscpp</exec_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <exec_depend>message_runtime</exec_depend>
  
  <!-- 추가적인 태그 -->
  <export></export>
</package>

 

3. 빌드 파일 설정 (CMakeLists.txt 편집)

## 최소 요구 버전
cmake_minimum_required(VERSION 2.8.3)

## 패키지 이름
project(ros_tutorials_topic)

## 캐킨 빌드를 할때 요구되는 구성 요소 패키지이다.
## 의존성 패키지로 message_generation, std_msgs, roscpp이며 이 패키지들이 존재하지않으면 빌드 도중에 에러가난다.
find_package(catkin REQUIRED COMPONENTS message_generation std_msgs roscpp)

## 메시지 선언: MsgTutorial.msg
add_message_files(FILES MsgTutorial.msg)

## 의존하는 메시지를 설정하는 옵션이다.
## std_msgs가 설치되어있지 않다면 빌드 도중에 에러가 난다.
generate_messages(DEPENDENCIES std_msgs)

## 메시지 인터페이스 파일 설정
## add_message_files(FILES 파일이름.확장자)

## 서비스 인터페이스 파일 설정
## add_service_files(FILES 파일이름.확장자)

## 액션 인터페이스 파일 설정
## add_action_files(FILES 파일이름.확장자)

 
## 캐킨 패키지 옵션으로 라이브러리, 캐킨 빌드 의존성, 시스템 의존 패키지를 기술한다.
## LIBRARIES : 패키지 이름
## CATKIN_DEPENDS : Catkin 종속 패키지
## DEPENDS : 비 Catkin 종속 패키지
catkin_package(
  LIBRARIES ros_tutorials_topic
  CATKIN_DEPENDS std_msgs roscpp)

## 빌드 시 생성되는 파일들을 특정 경로로 지정할 수 있는 것
## set_target_properties()

## 인클루드 디렉터리를 설정한다.
include_directories(${catkin_INCLUDE_DIRS})

## topic_publisher 노드에 대한 빌드 옵션이다.
## 파이썬일 경우 빌드 옵션을 설정안해도 됨
## 실행파일, 타깃 링크 라이브러리, 추가 의존성 등을 설정한다.
## topic_publisher = 노드 이름
## src/topic_publisher.cpp = 노드 프로그래밍 파일
add_executable(topic_publisher src/topic_publisher.cpp)
add_dependencies(topic_publisher ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(topic_publisher ${catkin_LIBRARIES})

## topic_subscriber 노드에 대한 빌드 옵션이다.
add_executable(topic_subscriber src/topic_subscriber.cpp)
add_dependencies(topic_subscriber ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(topic_subscriber ${catkin_LIBRARIES})

 

4. 빌드하기

cd ~/catkin_ws
catkin_make

 

참고 링크 1: https://htsstory.tistory.com/entry/ROS-%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%B0%8D-python-2-%EC%84%9C%EB%B9%84%EC%8A%A4-%ED%86%B5%EC%8B%A0?category=282702 

 

ROS 프로그래밍 (python) -2- 서비스 통신

ROS python 프로그래밍 =서비스 통신= Created Date: 2018.04.01 Modified Date: 2018.04.01 revision 1 키워드:ROS,ptyhon,service,파이썬,서비스 개발 환경:ROS kinetic kame + Ubuntu 16.04 + laptop ※국내 RO..

htsstory.tistory.com

 

참고 링크 2: http://wiki.ros.org/catkin/CMakeLists.txt

 

catkin/CMakeLists.txt - ROS Wiki

Overview The file CMakeLists.txt is the input to the CMake build system for building software packages. Any CMake-compliant package contains one or more CMakeLists.txt file that describe how to build the code and where to install it to. The CMakeLists.txt

wiki.ros.org

 

참고 링크 3: http://wiki.ros.org/ROS/Tutorials/WritingServiceClient%28python%29

 

ROS/Tutorials/WritingServiceClient(python) - ROS Wiki

Writing a Service Node Here we'll create the service ("add_two_ints_server") node which will receive two ints and return the sum. Change directory into the beginner_tutorials package, you created in the earlier tutorial, creating a package: Change director

wiki.ros.org

 

참고 링크 4: http://wiki.ros.org/ROS/Tutorials/CreatingPackage

 

ROS/Tutorials/CreatingPackage - ROS Wiki

Using roscreate Before we create a package, let's see how the roscreate-pkg command-line tool works. This creates a new ROS package. All ROS packages consist of the many similar files : manifests, CMakeLists.txt, mainpage.dox, and Makefiles. roscreate-pkg

wiki.ros.org