创建使用msg,srv和topic注意事项

creat .msg后,

(1)必须在package.xml中添加依赖项:

<build_depend>message_generation</build_depend>
<run_depend>message_runtime</run_depend>
(2) 在CMakeLists.txt中添加 message_generation:

find_package(catkin REQUIRED COMPONENTS
   roscpp
   rospy
   std_msgs
   message_generation
)
catkin_package(
  ...
  CATKIN_DEPENDS message_runtime ...
  ...)
     and uncomment :

add_message_files(
  FILES
  Num.msg    ### msg which you create
)
generate_messages(   
  DEPENDENCIES  
  std_msgs  
)  

If you have a previously compiled workspace and you add a new package inside it, you can tell catkin to add this new package to the already-compiled binaries by adding this parameter:

$ catkin_make --force-cmake
$ source 

NOTES:

a,  ***.h文件不是自己写的,

#include "beginner_tutorials/AddTwoInts.h"   ##  it is a header file generated from the srv file that we created earlier.
b,  新建**.c , **.py文件后,必须修改对应的 CMakeLists.txt。

c ,  rosbag info <your bagfile>  查看bag信息。

d,   rosdep install turtlesim 下载turtlesim包的依赖项。


WORKFLOW:

<pre name="code" class="cpp">$ cd ~/catkin_ws/src/beginner_tutorials/src
# Add/Edit source files
$ cd ~/catkin_ws/src/beginner_tutorials
# Update CMakeFiles.txt to reflect any changes to your sources
$ cd ~/catkin_ws
$ catkin_make -DCMAKE_BUILD_TYPE=Release 
 
 




参考:  http://wiki.ros.org/ROS/Tutorials/CreatingMsgAndSrv

你可能感兴趣的:(ROS)