• 【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
        
        • 1
        • 2
        • 3
        • 4
      • srv: 描述一个服务, 包括请求和回复
        • 位于包的srv目录
        • 类似msg文件, 含2部分: 请求和回复, —分隔
        int64 A
        int64 B
        ---
        int64 Sum
        
        • 1
        • 2
        • 3
        • 4

      msg

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

      补充
      package.xml

        <build_depend>message_generationbuild_depend>
        <exec_depend>message_runtimeexec_depend>
      
      • 1
      • 2

      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
      )
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18

      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
      
      • 1
      • 2
      • 3

      补充
      package.xml

        <build_depend>message_generationbuild_depend>
        <exec_depend>message_runtimeexec_depend>
      
      • 1
      • 2

      CMakeList.txt

      find_package(catkin REQUIRED COMPONENTS
         roscpp
         rospy
         std_msgs
         message_generation
      )
      add_service_files(
        FILES
        AddTwoInts.srv
      )
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10

      rossrv

      • rossrv show [service type]
        • rossrv show beginner_tutorials/AddTwoInts
      catkin_make
      
      • 1
  • 相关阅读:
    PHP 底层的运行机制和工作原理
    Docker Compose常用命令
    FFmpeg转码参数说明及视频转码示例
    数据结构笔记(王道考研) 第六章:图
    Golang内存对齐
    Java 算法篇-深入理解递归(递归实现:青蛙爬楼梯)
    Ubuntu 优化 与 问题记录
    深度学习实战90-基于多尺度混合注意力卷积神经网络的关系抽取模型
    分卷压缩与解压分卷
    升级macOS Ventura 16 之后出现系统卡住鼠标圈圈问题
  • 原文地址:https://blog.csdn.net/weixin_46143152/article/details/126831197