新建包
mkdir -p ROSworkspace/second_ws/src
cd ROSworkspace/second_ws
catkin_make
新的srv的pkg
cd src
catkin_create_pkg service_demo roscpp rospy std_msgs
cd service_demo
mkdir srv
cd srv
gedit Greeting.srv
里面输入代码
int64 a
int64 b
---
int64 sum
然后要修改CMakeList.txt和package.xml
Package.xml里面新增
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>
CMakeList.txt修改
find_package(catkin REQUIRED COMPONENTS
roscppge
rospy
std_msgs
message_generation
)
add_service_files(
FILES
Greeting.srv
)
generate_messages(
# DEPENDENCIES
# std_msgs
)
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES service_demo
# CATKIN_DEPENDS roscpp rospy std_msgs
# DEPENDS system_lib
LIBRARIES service_demo
CATKIN_DEPENDS message_runtime
)
)
最后一行加上 include_directories(include ${catkin_INCLUDE_DIRS})
最后一步
回到second_ws的目录下
catkin_make
在devel中的include中可以看到.h文件
|