diff --git a/articles/115_idl.md b/articles/115_idl.md index b93d73a8..b4ebe42f 100644 --- a/articles/115_idl.md +++ b/articles/115_idl.md @@ -264,7 +264,49 @@ If a cell is blank then the default mapping is used. #### 8.3.2.1 @key Annotation -While the key annotation doesn't affect the generated ROS data types directly it is being passed through to the (DDS) vendor specific code generators. +[ROS 2 nodes](ros_on_dds.html) exchange information of a certain real world object by means of topics. +Every message in a topic is known as *data sample* and represents an update to the status of the object. + +Topic instances are a way of multiplexing the transmission of updates of several objects of the same logical kind over the same resource, i.e. the topic. +In a *keyed topic*, every message is associated with a topic instance and each topic instance is identified by a unique key. +In this sense, keys can be thought as the *primary key* of a database. +This key allows nodes to update different states of the same kind. +In consequence, all data samples sharing the same key value refer to the same object. + +The `@key` annotation allows indicating that a data member is part of the key, which can have zero or more key fields and can be applied to structure fields of various types. +The following example shows how to define a keyed message using the IDL format: + +``` +# KeyedMsgName.idl +module package_name { + module msg { + struct KeyedMsgName { + @key long member1; + string member2; + }; + }; +}; +``` + +