创建使用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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值