【ROS】msg&srv

  • rospack = ros+pack(age) : provides information related to ROS packages
  • roscd = ros+cd : changes directory to a ROS package or stack
  • rosls = ros+ls : lists files in a ROS package
  • roscp = ros+cp : copies files from/to a ROS package
  • rosmsg = ros+msg : provides information related to ROS message definitions
  • rossrv = ros+srv : provides information related to ROS service definitions
  • catkin_make : makes (compiles) a ROS package
    • rosmake = ros+make : makes (compiles) a ROS package (if you’re not using a catkin workspace)
  • catkin build: makes (compiles) a ROS package in an isolated manner while maintaining efficiency due to parallelisation
    • catkin_make + catkin_make_isolated
  • 概览

    • msg: 简单的文本文件, 描述了ROS消息字段, 用于生成不同语言的消息源码
      • 位于包的msg目录
      Header header
      string child_frame_id
      geometry_msgs/PoseWithCovariance pose
      geometry_msgs/TwistWithCovariance twist
      
    • srv: 描述一个服务, 包括请求和回复
      • 位于包的srv目录
      • 类似msg文件, 含2部分: 请求和回复, —分隔
      int64 A
      int64 B
      ---
      int64 Sum
      

    msg

    • 创建msg
    roscd beginner_tutorials
    $ mkdir msg
    $ echo "int64 num" > msg/Num.msg
    

    补充
    package.xml

      <build_depend>message_generation</build_depend>
      <exec_depend>message_runtime</exec_depend>
    

    CMakeList.txt

    find_package(catkin REQUIRED COMPONENTS
       roscpp
       rospy
       std_msgs
       message_generation
    )
    catkin_package(
      ...
      CATKIN_DEPENDS message_runtime ...
      ...)
    add_message_files(
      FILES
      Num.msg
    )
    generate_messages(
      DEPENDENCIES
      std_msgs
    )
    

    rosmsg

    • rosmsg show [message type]
      • rosmsg show beginner_tutorials/Num
      • rosmsg show Num
      • list : List all messages
      • md5 : Display message md5num
      • package : List messages in a package
      • packages : List messages that contain messages

    srv

    • roscp [package_name] [file_to_copy_path] [copy_path] : 复制
    roscd beginner_tutorials
    mkdir srv
    roscp rospy_tutorials AddTwoInts.srv srv/AddTwoInts.srv
    

    补充
    package.xml

      <build_depend>message_generation</build_depend>
      <exec_depend>message_runtime</exec_depend>
    

    CMakeList.txt

    find_package(catkin REQUIRED COMPONENTS
       roscpp
       rospy
       std_msgs
       message_generation
    )
    add_service_files(
      FILES
      AddTwoInts.srv
    )
    

    rossrv

    • rossrv show [service type]
      • rossrv show beginner_tutorials/AddTwoInts
    catkin_make
    

猜你喜欢

转载自blog.csdn.net/weixin_46143152/article/details/126831197
今日推荐