您的位置:首页 > 运维架构

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

2014-05-29 18:34 363 查看
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
)
[code]catkin_package(
  ...
  CATKIN_DEPENDS message_runtime ...
  ...)

and uncomment :

add_message_files(
  FILES
  Num.msg    ### msg which you create
)
[code]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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: