참고 링크 : oroca 027강
$ cd ~/robot_ws/src
$ ros2 pkg create --build-type ament_cmake msg_srv_action_interface_example
$ cd msg_srv_action_interface_example
$ mkdir msg srv action
# Messages
builtin_interfaces/Time stamp
float32 argument_a
float32 argument_b
# Constants
int8 PLUS = 1
int8 MINUS = 2
int8 MULTIPLY = 3
int8 DIVISION = 4
# Request
int8 arithmetic_operator
---
# Response
float32 arithmetic_result
# Goal
float32 goal_sum
---
# Result
string[] all_formula
float32 total_sum
---
# Feedback
string[] formula
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>msg_srv_action_interface_example</name>
<version>0.2.0</version>
<description>
ROS 2 example for message, service and action interface
</description>
<maintainer email="mine1372@korea.ac.kr">Pyo</maintainer>
<license>Apache 2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>rosidl_default_generators</buildtool_depend>
<exec_depend>builtin_interfaces</exec_depend>
<exec_depend>rosidl_default_runtime</exec_depend>
<member_of_group>rosidl_interface_packages</member_of_group>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
인터페이스 전용 패키지를 만들 때에 필수적인 의존성 패키지
################################################################################
# Set minimum required version of cmake, project name and compile options
################################################################################
cmake_minimum_required(VERSION 3.5)
project(msg_srv_action_interface_example)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
endif()
################################################################################
# Find and load build settings from external packages
################################################################################
find_package(ament_cmake REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(rosidl_default_generators REQUIRED)
################################################################################
# Declare ROS messages, services and actions
################################################################################
set(msg_files
"msg/ArithmeticArgument.msg"
)
set(srv_files
"srv/ArithmeticOperator.srv"
)
set(action_files
"action/ArithmeticChecker.action"
)
rosidl_generate_interfaces(${PROJECT_NAME}
${msg_files}
${srv_files}
${action_files}
DEPENDENCIES builtin_interfaces
)
################################################################################
# Macro for ament package
################################################################################
ament_export_dependencies(rosidl_default_runtime)
ament_package()
$ cw
$ cbp msg_srv_action_interface_example
cd ~/robot_ws
colcon build --symlink-install --packages-select