创建ROS消息和ROS服务

1.创建完msg,

编译过程中出现如下错误:

CMake Error at beginner_tutorials/CMakeLists.txt:51 (add_message_files):
Unknown CMake command “add_message_files”.
– Configuring incomplete, errors occurred!
See also “/home/jack/my_ws/build/CMakeFiles/CMakeOutput.log”.
See also “/home/jack/my_ws/build/CMakeFiles/CMakeError.log”.
Makefile:696: recipe for target ‘cmake_check_build_system’ failed
make: *** [cmake_check_build_system] Error 1
Invoking “make cmake_check_build_system” failed
在这里插入图片描述

:

  • 经检查,在 CMakeLists.txt文件中的find_packag函数中忘了增加对message_generation的依赖,修改完后编译成功.
  • 在这里插入图片描述
  • 在这里插入图片描述
  • 2.创建完srv,

  • 编译出现以下错误
    – ==> add_subdirectory(beginner_tutorials)
    CMake Error: Error in cmake code at
    /home/jack/my_ws/src/beginner_tutorials/CMakeLists.txt:199:
    Parse error. Function missing ending “)”. End of file reached.
    – Configuring incomplete, errors occurred!
    See also “/home/jack/my_ws/build/CMakeFiles/CMakeOutput.log”.
    See also “/home/jack/my_ws/build/CMakeFiles/CMakeError.log”.
    Makefile:696: recipe for target ‘cmake_check_build_system’ failed
    make: *** [cmake_check_build_system] Error 1
    Invoking “make cmake_check_build_system” failed

    解 决 过 程 : 

    仔细观察,原来是函数少了个括号,修改后,编译成功
    在这里插入图片描述

  • 在这里插入图片描述
  • 总结细心很重要 !