- 自定义服务数据
int64 a
int64 b
---
int64 sum
- 添加依赖配置
<build_depend>message_generateion</build_depend>
<exec_depend>message_runtime</exec_depend>
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)
add_service_files(
FILES
AddTwoInts.srv
)
generate_messages(
DEPENDENCIES
std_msgs
)
catkin_package(
LIBRARIES learning_communication
CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
)
- 创建节点
# include "ros/ros.h"
# include "learning_communication/AddTwoInts.h"
bool add(learning_communication::AddTwoInts::Request &req,
learning_communication