Advertisement
Guest User

Untitled

a guest
Apr 24th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. ##创建msg
  2.  
  3. ###msg是什么
  4.  
  5. msg是一个普通的文本文件,描述了一个消息的数据成员(数据结构),它将作为原型去生成各种编程语言能够使用的数据类型。
  6.  
  7. ###Creating a msg
  8.  
  9. Firstly, we need a msg folder with a filename.msg file under the package folder.
  10.  
  11. Then, write the msg file with the format <type> <name> per line.
  12.  
  13. Then, open package.xml, and make sure these two lines are in it and uncommented:
  14.  
  15. ```xml
  16. <build_depend>message_generation</build_depend>
  17. <run_depend>message_runtime</run_depend>
  18. ```
  19.  
  20. And in CMakeLists.txt, check the content below:
  21.  
  22. ```makefile
  23. # Do not just add this to your CMakeLists.txt,
  24. # modify the existing text to add message_generation before the closing parenthesis
  25. find_package(catkin REQUIRED COMPONENTS
  26. roscpp
  27. rospy
  28. std_msgs
  29. message_generation
  30. )
  31.  
  32. catkin_package(
  33. ...
  34. CATKIN_DEPENDS message_runtime ...
  35. ...)
  36.  
  37. add_message_files(
  38. FILES
  39. yours.msg
  40. )
  41. ```
  42.  
  43. ##创建srv$ rosmsg sh
  44. $ rosmsg sh
  45. ###srv是什么
  46.  
  47. 同msg一样,srv是用来描述service的纯文本和原型描述;特别地,它需要描述请求和响应两个部分。
  48.  
  49. ###Creating a srv
  50.  
  51. Create .srv file in package_path/srv/your.srv
  52.  
  53. Check the content in package.xml:
  54.  
  55. ```xml
  56. <build_depend>message_generation</build_depend>
  57. <run_depend>message_runtime</run_depend>
  58. ```
  59.  
  60. and check these content in CMakeLists.txt:
  61.  
  62. ```makefile
  63. # Do not just add this line to your CMakeLists.txt,
  64. # modify the existing line
  65. find_package(catkin REQUIRED COMPONENTS
  66. roscpp
  67. rospy
  68. std_msgs
  69. message_generation
  70. )
  71.  
  72. add_service_files(
  73. FILES
  74. your.srv
  75. )
  76.  
  77. Similar to msg, use `rossrv show <srvname>` to check it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement