解决方法: srv下的 AddTwoInts.srv 文件中的内容
改为:
int64 a
int64 b
---
int64 sum
错误出现的原因:在 wiki教程中,要求:
请确保你已经按照之前教程中的指示创建了本教程中需要的服务AddTwoInts.srv。
而创建这个文件的命令:
roscp rospy_tutorials AddTwoInts.srv srv/AddTwoInts.srv
对我是无法生效的,报错:
cp: 无法创建普通文件'srv/AddTwoInts.srv': 没有那个文件或目录
而我采用的是自己书写一个AddTwoInts.srv,参照的是之前wiki里面关于.srv文件的举例:
int64 A
int64 B
---
int64 Sum
大小写出错了!
报错信息如下:
dhw@dhw-Inspiron-5593:~/catkin_ws$ catkin_make
Base path: /home/dhw/catkin_ws
Source space: /home/dhw/catkin_ws/src
Build space: /home/dhw/catkin_ws/build
Devel space: /home/dhw/catkin_ws/devel
Install space: /home/dhw/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/dhw/catkin_ws/build"
####
####
#### Running command: "make -j8 -l8" in "/home/dhw/catkin_ws/build"
####
[ 0%] Built target std_msgs_generate_messages_cpp
[ 0%] Built target std_msgs_generate_messages_eus
[ 0%] Built target std_msgs_generate_messages_py
[ 0%] Built target std_msgs_generate_messages_lisp
[ 0%] Built target std_msgs_generate_messages_nodejs
[ 0%] Built target _beginner_tutorials_generate_messages_check_deps_Num
[ 0%] Built target _beginner_tutorials_generate_messages_check_deps_AddTwoInts
[ 4%] Generating EusLisp code from beginner_tutorials/AddTwoInts.srv
[ 14%] Generating Python code from SRV beginner_tutorials/AddTwoInts
[ 14%] Generating Lisp code from beginner_tutorials/AddTwoInts.srv
[ 19%] Generating C++ code from beginner_tutorials/AddTwoInts.srv
[ 23%] Generating Javascript code from beginner_tutorials/AddTwoInts.srv
[ 28%] Built target beginner_tutorials_generate_messages_nodejs
[ 33%] Built target beginner_tutorials_generate_messages_lisp
[ 42%] Built target beginner_tutorials_generate_messages_eus
[ 47%] Generating Python msg __init__.py for beginner_tutorials
[ 52%] Generating Python srv __init__.py for beginner_tutorials
[ 57%] Built target beginner_tutorials_generate_messages_cpp
[ 57%] Built target beginner_tutorials_gencpp
[ 66%] Built target listener
[ 76%] Built target talker
Scanning dependencies of target add_two_ints_client
Scanning dependencies of target add_two_ints_server
[ 85%] Building CXX object beginner_tutorials/CMakeFiles/add_two_ints_server.dir/src/add_two_ints_server.cpp.o
[ 85%] Building CXX object beginner_tutorials/CMakeFiles/add_two_ints_client.dir/src/add_two_ints_client.cpp.o
[ 90%] Built target beginner_tutorials_generate_messages_py
[ 90%] Built target beginner_tutorials_generate_messages
/home/dhw/catkin_ws/src/beginner_tutorials/src/add_two_ints_client.cpp: In function ‘int main(int, char**)’:
/home/dhw/catkin_ws/src/beginner_tutorials/src/add_two_ints_client.cpp:17:15: error: ‘beginner_tutorials::AddTwoInts::Request {aka struct beginner_tutorials::AddTwoIntsRequest_<std::allocator<void> >}’ has no member named ‘a’srv.request.a = atoll(argv[1]);^
/home/dhw/catkin_ws/src/beginner_tutorials/src/add_two_ints_client.cpp:18:15: error: ‘beginner_tutorials::AddTwoInts::Request {aka struct beginner_tutorials::AddTwoIntsRequest_<std::allocator<void> >}’ has no member named ‘b’srv.request.b = atoll(argv[2]);^
/home/dhw/catkin_ws/src/beginner_tutorials/src/add_two_ints_server.cpp: In function ‘bool add(beginner_tutorials::AddTwoInts::Request&, beginner_tutorials::AddTwoInts::Response&)’:
/home/dhw/catkin_ws/src/beginner_tutorials/src/add_two_ints_server.cpp:7:17: error: ‘beginner_tutorials::AddTwoInts::Request {aka struct beginner_tutorials::AddTwoIntsRequest_<std::allocator<void> >}’ has no member named ‘a’res.sum = req.a + req.b;^
/home/dhw/catkin_ws/src/beginner_tutorials/src/add_two_ints_server.cpp:7:25: error: ‘beginner_tutorials::AddTwoInts::Request {aka struct beginner_tutorials::AddTwoIntsRequest_<std::allocator<void> >}’ has no member named ‘b’res.sum = req.a + req.b;^
In file included from /opt/ros/melodic/include/ros/ros.h:40:0,from /home/dhw/catkin_ws/src/beginner_tutorials/src/add_two_ints_server.cpp:1:
/home/dhw/catkin_ws/src/beginner_tutorials/src/add_two_ints_server.cpp:8:51: error: ‘beginner_tutorials::AddTwoInts::Request {aka struct beginner_tutorials::AddTwoIntsRequest_<std::allocator<void> >}’ has no member named ‘a’ROS_INFO("request: x=%ld, y=%ld", (long int)req.a, (long int)req.b);^
/opt/ros/melodic/include/ros/console.h:348:165: note: in definition of macro ‘ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER’sole_define_location__loc.level_, __FILE__, __LINE__, __ROSCONSOLE_FUNCTION__, __VA_ARGS__)^~~~~~~~~~~
/opt/ros/melodic/include/ros/console.h:387:7: note: in expansion of macro ‘ROSCONSOLE_PRINT_AT_LOCATION’ROSCONSOLE_PRINT_AT_LOCATION(__VA_ARGS__); \^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/ros/melodic/include/ros/console.h:572:35: note: in expansion of macro ‘ROS_LOG_COND’#define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, __VA_ARGS__)^~~~~~~~~~~~
/opt/ros/melodic/include/rosconsole/macros_generated.h:110:23: note: in expansion of macro ‘ROS_LOG’#define ROS_INFO(...) ROS_LOG(::ros::console::levels::Info, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__)^~~~~~~
/home/dhw/catkin_ws/src/beginner_tutorials/src/add_two_ints_server.cpp:8:3: note: in expansion of macro ‘ROS_INFO’ROS_INFO("request: x=%ld, y=%ld", (long int)req.a, (long int)req.b);^~~~~~~~
/home/dhw/catkin_ws/src/beginner_tutorials/src/add_two_ints_server.cpp:8:68: error: ‘beginner_tutorials::AddTwoInts::Request {aka struct beginner_tutorials::AddTwoIntsRequest_<std::allocator<void> >}’ has no member named ‘b’ROS_INFO("request: x=%ld, y=%ld", (long int)req.a, (long int)req.b);^
/opt/ros/melodic/include/ros/console.h:348:165: note: in definition of macro ‘ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER’sole_define_location__loc.level_, __FILE__, __LINE__, __ROSCONSOLE_FUNCTION__, __VA_ARGS__)^~~~~~~~~~~
/opt/ros/melodic/include/ros/console.h:387:7: note: in expansion of macro ‘ROSCONSOLE_PRINT_AT_LOCATION’ROSCONSOLE_PRINT_AT_LOCATION(__VA_ARGS__); \^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/ros/melodic/include/ros/console.h:572:35: note: in expansion of macro ‘ROS_LOG_COND’#define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, __VA_ARGS__)^~~~~~~~~~~~
/opt/ros/melodic/include/rosconsole/macros_generated.h:110:23: note: in expansion of macro ‘ROS_LOG’#define ROS_INFO(...) ROS_LOG(::ros::console::levels::Info, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__)^~~~~~~
/home/dhw/catkin_ws/src/beginner_tutorials/src/add_two_ints_server.cpp:8:3: note: in expansion of macro ‘ROS_INFO’ROS_INFO("request: x=%ld, y=%ld", (long int)req.a, (long int)req.b);^~~~~~~~
beginner_tutorials/CMakeFiles/add_two_ints_client.dir/build.make:62: recipe for target 'beginner_tutorials/CMakeFiles/add_two_ints_client.dir/src/add_two_ints_client.cpp.o' failed
make[2]: *** [beginner_tutorials/CMakeFiles/add_two_ints_client.dir/src/add_two_ints_client.cpp.o] Error 1
CMakeFiles/Makefile2:1459: recipe for target 'beginner_tutorials/CMakeFiles/add_two_ints_client.dir/all' failed
make[1]: *** [beginner_tutorials/CMakeFiles/add_two_ints_client.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
beginner_tutorials/CMakeFiles/add_two_ints_server.dir/build.make:62: recipe for target 'beginner_tutorials/CMakeFiles/add_two_ints_server.dir/src/add_two_ints_server.cpp.o' failed
make[2]: *** [beginner_tutorials/CMakeFiles/add_two_ints_server.dir/src/add_two_ints_server.cpp.o] Error 1
CMakeFiles/Makefile2:1422: recipe for target 'beginner_tutorials/CMakeFiles/add_two_ints_server.dir/all' failed
make[1]: *** [beginner_tutorials/CMakeFiles/add_two_ints_server.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j8 -l8" failed