Message (msg / srv / action interface)
消息msgCommonThe agreed-upon data format that ROS nodes use to exchange information.
Before ROS nodes can exchange data, they need to agree on what that data looks like — that agreement is a message, collectively called an interface in ROS 2. There are three kinds of interface files: .msg defines the data structure carried on a topic; .srv defines a service's request and response, separated by three dashes; and .action defines a goal, result, and intermediate feedback for an action. These files only declare field types and names; the build tools generate the corresponding C++ and Python code automatically. Commonly used standard message packages include std_msgs, geometry_msgs (e.g. the velocity command Twist, or the pose type Pose), and sensor_msgs (e.g. the image type Image, joint state JointState, or point cloud PointCloud2). Reusing a standard message instead of defining a custom one keeps a node easy to connect to existing tools.
ExampleRunning ros2 interface show geometry_msgs/msg/Twist shows it's made of a linear and an angular three-dimensional vector, which is what base velocity commands use.
- Also called
- msg, ROS message, interface type, interface
- Related
- Topic (ROS) · Service (ROS) · Action (ROS Action) · Publish-Subscribe · Robot Operating System 2 · cmd_vel Topic (geometry_msgs/Twist velocity command)
- Sources
- ROS 2 文档:About interfaces (Chinese)