ROS学习之⾃定义srv类型1. 创建srv⽂件
cd ~/catkin_ws/src/my_package
mkdir srv
echo "int64 a
int64 b
---
int64 sum" > srv/AddTwoInts.srv
2. 更改⽂件
更改find_package()函数:
在中添加对message_generation包的依赖:
此步骤已经在⼀节中添加过了
指定需要转换的srv⽂件
尾巴英语怎么说编译
回到catkin_ws⽬录下:
catkin_make
编译之后就会⽣成Num.h头⽂件,所在⽬录如下:
测试:
rossrv show my_package/AddTwoInts
<⽂件内容
cmake_minimum_required(VERSION 2.8.3)
project(my_package)
find_package(catkin REQUIRED COMPONENTS幼儿园大班试卷
大提琴谱roscpp
rospy
std_msgs
message_generation
)
朱德的故事#指定需要转换的msg⽂件
胎心看男女add_message_files(FILES Num.msg)
#指定需要转换的srv⽂件
add_rvice_files(FILES AddTwoInts.srv)
#只有调⽤了下⾯的函数最后才会⽣成 Num.h ⽂件距离过年还有多少天
generate_messages()
catkin_package(
INCLUDE_DIRS include
LIBRARIES my_package直接报价
CATKIN_DEPENDS roscpp rospy std_msgs message_runtime DEPENDS system_lib
)
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
# talker_Node在ros中是独⼀⽆⼆的,不能和其它节点名字重复add_executable(publisher_Node src/publisher.cpp)
target_link_libraries(publisher_Node ${catkin_LIBRARIES})
怎样安慰病人add_executable(subscriber_Node src/subscriber.cpp)
target_link_libraries(subscriber_Node ${catkin_LIBRARIES})