From 2cbbd2148ded7fee6bb8ade9daf56de4b9bc8b68 Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Thu, 23 Feb 2023 16:27:03 -0800 Subject: [PATCH 1/9] Add GetTypeDescription.srv Signed-off-by: Emerson Knapp --- type_description_interfaces/CMakeLists.txt | 1 + type_description_interfaces/package.xml | 1 + .../srv/GetTypeDescription.srv | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 type_description_interfaces/srv/GetTypeDescription.srv diff --git a/type_description_interfaces/CMakeLists.txt b/type_description_interfaces/CMakeLists.txt index e860c778..b7101d60 100644 --- a/type_description_interfaces/CMakeLists.txt +++ b/type_description_interfaces/CMakeLists.txt @@ -20,6 +20,7 @@ rosidl_generate_interfaces(${PROJECT_NAME} "msg/FieldType.msg" "msg/IndividualTypeDescription.msg" "msg/TypeDescription.msg" + "srv/GetTypeDescription.srv" ADD_LINTER_TESTS ) diff --git a/type_description_interfaces/package.xml b/type_description_interfaces/package.xml index dd3fe970..731c3350 100644 --- a/type_description_interfaces/package.xml +++ b/type_description_interfaces/package.xml @@ -12,6 +12,7 @@ ament_cmake rosidl_core_generators + service_msgs rosidl_core_runtime diff --git a/type_description_interfaces/srv/GetTypeDescription.srv b/type_description_interfaces/srv/GetTypeDescription.srv new file mode 100644 index 00000000..6568852a --- /dev/null +++ b/type_description_interfaces/srv/GetTypeDescription.srv @@ -0,0 +1,19 @@ +string type_name +string type_version_hash +--- +# True if the type description information is available and populated in the response +bool successful +# Empty if 'successful' was true, otherwise contains details on why it failed +string failure_reason + +# The idl or msg file name +string type_description_raw_file_name +# The idl or msg file, with comments and whitespace +# The file extension and/or the contents can be used to determine the format +string type_description_raw +# The parsed type description which can be used programmatically +TypeDescription type_description + +# Key-value pairs of extra information. +string[] extra_information_keys +string[] extra_information_values From fb7a19c674d36ac1e5d8e14774ac5d084234afa9 Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Thu, 9 Mar 2023 17:00:53 -0800 Subject: [PATCH 2/9] Add format clarification comments and fix formatting Signed-off-by: Emerson Knapp --- type_description_interfaces/package.xml | 1 + type_description_interfaces/srv/GetTypeDescription.srv | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/type_description_interfaces/package.xml b/type_description_interfaces/package.xml index 731c3350..f3fd1e14 100644 --- a/type_description_interfaces/package.xml +++ b/type_description_interfaces/package.xml @@ -12,6 +12,7 @@ ament_cmake rosidl_core_generators + service_msgs rosidl_core_runtime diff --git a/type_description_interfaces/srv/GetTypeDescription.srv b/type_description_interfaces/srv/GetTypeDescription.srv index 6568852a..18a55079 100644 --- a/type_description_interfaces/srv/GetTypeDescription.srv +++ b/type_description_interfaces/srv/GetTypeDescription.srv @@ -1,4 +1,7 @@ +# ROS interface type name, in PACKAGE/NAMESPACE/TYPENAME format string type_name + +# REP-2011 RIHS hash string, which looks like RIHSxx_hashvalue string type_version_hash --- # True if the type description information is available and populated in the response @@ -8,9 +11,14 @@ string failure_reason # The idl or msg file name string type_description_raw_file_name + # The idl or msg file, with comments and whitespace # The file extension and/or the contents can be used to determine the format +# This contains all recursive raw files, each separated by a line of 80 '=' characters +# The order will be the same as the TypeDescription - +# which is top level interface then referenced type descriptions in alphabetical order by type_name string type_description_raw + # The parsed type description which can be used programmatically TypeDescription type_description From 6f8d28686317b7897e98e56468a220d7ff02ad1e Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Tue, 14 Mar 2023 17:20:58 -0700 Subject: [PATCH 3/9] Update service from design discussion Signed-off-by: Emerson Knapp --- type_description_interfaces/CMakeLists.txt | 1 + type_description_interfaces/msg/KeyValue.msg | 2 ++ .../srv/GetTypeDescription.srv | 25 +++++++++++++++---- 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 type_description_interfaces/msg/KeyValue.msg diff --git a/type_description_interfaces/CMakeLists.txt b/type_description_interfaces/CMakeLists.txt index b7101d60..99292bd1 100644 --- a/type_description_interfaces/CMakeLists.txt +++ b/type_description_interfaces/CMakeLists.txt @@ -19,6 +19,7 @@ rosidl_generate_interfaces(${PROJECT_NAME} "msg/Field.msg" "msg/FieldType.msg" "msg/IndividualTypeDescription.msg" + "msg/KeyValue.msg" "msg/TypeDescription.msg" "srv/GetTypeDescription.srv" ADD_LINTER_TESTS diff --git a/type_description_interfaces/msg/KeyValue.msg b/type_description_interfaces/msg/KeyValue.msg new file mode 100644 index 00000000..6f825d5f --- /dev/null +++ b/type_description_interfaces/msg/KeyValue.msg @@ -0,0 +1,2 @@ +string key +string value diff --git a/type_description_interfaces/srv/GetTypeDescription.srv b/type_description_interfaces/srv/GetTypeDescription.srv index 18a55079..6920fdb2 100644 --- a/type_description_interfaces/srv/GetTypeDescription.srv +++ b/type_description_interfaces/srv/GetTypeDescription.srv @@ -3,25 +3,40 @@ string type_name # REP-2011 RIHS hash string, which looks like RIHSxx_hashvalue string type_version_hash + +# Whether to return the raw idl or msg file(s) in the response, if available +bool include_raw_description true --- +# include_raw_description requested, and provided successfully +uint8 RAW_DESCRIPTION_REQUESTED_PROVIDED = 0 +# include_raw_description disabled, so type_description_raw was left empty +uint8 RAW_DESCRIPTION_NOT_REQUESTED_NOT_PROVIDED = 1 +# include_raw_description requested, but no raw version available (perhaps for ) +uint8 RAW_DESCRIPTION_REQUESTED_NOT_AVAILABLE = 2 + # True if the type description information is available and populated in the response bool successful -# Empty if 'successful' was true, otherwise contains details on why it failed -string failure_reason +# If `successful` is false, contains a reason for failure. +# On success, may contain a reason for missing type_description_raw. +string reason + +# Contains a value from RAW_DESCRIPTION_ constants, +# explaining the value of `type_description_raw_file_name` and `type_description_raw` +uint8 type_description_raw_result # The idl or msg file name +# Empty if not available, which will be noted in `reason` string type_description_raw_file_name # The idl or msg file, with comments and whitespace # The file extension and/or the contents can be used to determine the format # This contains all recursive raw files, each separated by a line of 80 '=' characters # The order will be the same as the TypeDescription - -# which is top level interface then referenced type descriptions in alphabetical order by type_name +# which is top level interface, then referenced type descriptions in alphabetical order by type_name string type_description_raw # The parsed type description which can be used programmatically TypeDescription type_description # Key-value pairs of extra information. -string[] extra_information_keys -string[] extra_information_values +KeyValue[] extra_information From 71c97ae6edcf22ef39ff4333f7235a33eb5301bb Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Wed, 15 Mar 2023 18:19:33 -0700 Subject: [PATCH 4/9] Fix unfinished thought and clarify comments from review Signed-off-by: Emerson Knapp --- type_description_interfaces/srv/GetTypeDescription.srv | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/type_description_interfaces/srv/GetTypeDescription.srv b/type_description_interfaces/srv/GetTypeDescription.srv index 6920fdb2..4db8b4cd 100644 --- a/type_description_interfaces/srv/GetTypeDescription.srv +++ b/type_description_interfaces/srv/GetTypeDescription.srv @@ -11,17 +11,18 @@ bool include_raw_description true uint8 RAW_DESCRIPTION_REQUESTED_PROVIDED = 0 # include_raw_description disabled, so type_description_raw was left empty uint8 RAW_DESCRIPTION_NOT_REQUESTED_NOT_PROVIDED = 1 -# include_raw_description requested, but no raw version available (perhaps for ) +# include_raw_description requested, but no raw version available (perhaps for dynamically created types) uint8 RAW_DESCRIPTION_REQUESTED_NOT_AVAILABLE = 2 # True if the type description information is available and populated in the response +# If false, all other fields except `reason` are considered undefined bool successful # If `successful` is false, contains a reason for failure. # On success, may contain a reason for missing type_description_raw. string reason -# Contains a value from RAW_DESCRIPTION_ constants, -# explaining the value of `type_description_raw_file_name` and `type_description_raw` +# Contains a value from RAW_DESCRIPTION_ constants, explaining whether the +# `type_description_raw_file_name` and `type_description_raw` fields contain valid data. uint8 type_description_raw_result # The idl or msg file name From 6756fdb9ef1c453147cf1f12106346eb3d31b848 Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Tue, 21 Mar 2023 19:55:02 -0700 Subject: [PATCH 5/9] Type raw sources in a list of submessages Signed-off-by: Emerson Knapp --- type_description_interfaces/CMakeLists.txt | 1 + type_description_interfaces/msg/KeyValue.msg | 2 + .../msg/TypeSource.msg | 16 ++++++++ .../srv/GetTypeDescription.srv | 37 ++++++++----------- 4 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 type_description_interfaces/msg/TypeSource.msg diff --git a/type_description_interfaces/CMakeLists.txt b/type_description_interfaces/CMakeLists.txt index 99292bd1..9d170371 100644 --- a/type_description_interfaces/CMakeLists.txt +++ b/type_description_interfaces/CMakeLists.txt @@ -21,6 +21,7 @@ rosidl_generate_interfaces(${PROJECT_NAME} "msg/IndividualTypeDescription.msg" "msg/KeyValue.msg" "msg/TypeDescription.msg" + "msg/TypeSource.msg" "srv/GetTypeDescription.srv" ADD_LINTER_TESTS ) diff --git a/type_description_interfaces/msg/KeyValue.msg b/type_description_interfaces/msg/KeyValue.msg index 6f825d5f..b06a1617 100644 --- a/type_description_interfaces/msg/KeyValue.msg +++ b/type_description_interfaces/msg/KeyValue.msg @@ -1,2 +1,4 @@ +# Represents an arbitrary key-value pair for application-specific information. + string key string value diff --git a/type_description_interfaces/msg/TypeSource.msg b/type_description_interfaces/msg/TypeSource.msg new file mode 100644 index 00000000..8024728c --- /dev/null +++ b/type_description_interfaces/msg/TypeSource.msg @@ -0,0 +1,16 @@ +# Represents the original source of a ROS 2 interface definition. + +uint8 ENCODING_NOT_SET = 0 +uint8 ENCODING_MSG = 1 +uint8 ENCODING_SRV = 2 +uint8 ENCODING_ACTION = 3 +uint8 ENCODING_IDL = 4 + +# ROS interface type name, in PACKAGE/NAMESPACE/TYPENAME format +string type_name + +# The type of the original source file, from the above constants +uint8 encoding + +# Dumped contents of the interface definition source file +string raw_file_contents diff --git a/type_description_interfaces/srv/GetTypeDescription.srv b/type_description_interfaces/srv/GetTypeDescription.srv index 4db8b4cd..90e8c2ee 100644 --- a/type_description_interfaces/srv/GetTypeDescription.srv +++ b/type_description_interfaces/srv/GetTypeDescription.srv @@ -4,37 +4,30 @@ string type_name # REP-2011 RIHS hash string, which looks like RIHSxx_hashvalue string type_version_hash -# Whether to return the raw idl or msg file(s) in the response, if available -bool include_raw_description true +# Whether to return the original idl or msg file(s) in the response, if available +bool include_type_sources true --- -# include_raw_description requested, and provided successfully -uint8 RAW_DESCRIPTION_REQUESTED_PROVIDED = 0 -# include_raw_description disabled, so type_description_raw was left empty -uint8 RAW_DESCRIPTION_NOT_REQUESTED_NOT_PROVIDED = 1 -# include_raw_description requested, but no raw version available (perhaps for dynamically created types) -uint8 RAW_DESCRIPTION_REQUESTED_NOT_AVAILABLE = 2 +# sources requested, and provided successfully +uint8 SOURCES_REQUESTED_PROVIDED = 0 +# sources disabled, so type_sources was left empty +uint8 SOURCES_NOT_REQUESTED_NOT_PROVIDED = 1 +# sources requested, but no source available (perhaps for dynamically created types) +uint8 SOURCES_REQUESTED_NOT_AVAILABLE = 2 # True if the type description information is available and populated in the response # If false, all other fields except `reason` are considered undefined bool successful # If `successful` is false, contains a reason for failure. -# On success, may contain a reason for missing type_description_raw. +# On success, may contain a reason for missing sources. string reason -# Contains a value from RAW_DESCRIPTION_ constants, explaining whether the -# `type_description_raw_file_name` and `type_description_raw` fields contain valid data. -uint8 type_description_raw_result +# Contains a value from above constants, explaining whether the +# `type_sources` fields contain valid data. +uint8 type_sources_result -# The idl or msg file name -# Empty if not available, which will be noted in `reason` -string type_description_raw_file_name - -# The idl or msg file, with comments and whitespace -# The file extension and/or the contents can be used to determine the format -# This contains all recursive raw files, each separated by a line of 80 '=' characters -# The order will be the same as the TypeDescription - -# which is top level interface, then referenced type descriptions in alphabetical order by type_name -string type_description_raw +# List of idl or msg/srv/action source files, including all comments and whitespace. +# Sources can be matched with IndividualTypeDescriptions by their type_name +TypeSource[] type_sources # The parsed type description which can be used programmatically TypeDescription type_description From c5998a79525896dff5505fd1d820876f5d090a6f Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Tue, 21 Mar 2023 21:08:02 -0700 Subject: [PATCH 6/9] Use type_hash instead of type_version_hash Signed-off-by: Emerson Knapp --- type_description_interfaces/srv/GetTypeDescription.srv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/type_description_interfaces/srv/GetTypeDescription.srv b/type_description_interfaces/srv/GetTypeDescription.srv index 90e8c2ee..6b9aa91c 100644 --- a/type_description_interfaces/srv/GetTypeDescription.srv +++ b/type_description_interfaces/srv/GetTypeDescription.srv @@ -2,7 +2,7 @@ string type_name # REP-2011 RIHS hash string, which looks like RIHSxx_hashvalue -string type_version_hash +string type_hash # Whether to return the original idl or msg file(s) in the response, if available bool include_type_sources true From 2ec42ec19cfbee48a2ed8b5b8963ef4367dae556 Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Tue, 21 Mar 2023 21:52:45 -0700 Subject: [PATCH 7/9] Update to cpp17 while we are here, like the rest of the pkgs in the repo Signed-off-by: Emerson Knapp --- type_description_interfaces/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/type_description_interfaces/CMakeLists.txt b/type_description_interfaces/CMakeLists.txt index 9d170371..c3ac72bf 100644 --- a/type_description_interfaces/CMakeLists.txt +++ b/type_description_interfaces/CMakeLists.txt @@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 3.5) project(type_description_interfaces) -# Default to C++14 +# Default to C++17 if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD 17) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) From 1db947856ece4ba136671fc5136f2af2ef7f1132 Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Wed, 22 Mar 2023 16:39:16 -0700 Subject: [PATCH 8/9] Update encoding information and resulting logical updates Signed-off-by: Emerson Knapp --- .../msg/TypeSource.msg | 16 ++++----- .../srv/GetTypeDescription.srv | 34 +++++++------------ 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/type_description_interfaces/msg/TypeSource.msg b/type_description_interfaces/msg/TypeSource.msg index 8024728c..ddef22c3 100644 --- a/type_description_interfaces/msg/TypeSource.msg +++ b/type_description_interfaces/msg/TypeSource.msg @@ -1,16 +1,12 @@ # Represents the original source of a ROS 2 interface definition. -uint8 ENCODING_NOT_SET = 0 -uint8 ENCODING_MSG = 1 -uint8 ENCODING_SRV = 2 -uint8 ENCODING_ACTION = 3 -uint8 ENCODING_IDL = 4 - -# ROS interface type name, in PACKAGE/NAMESPACE/TYPENAME format +# ROS interface type name, in PACKAGE/NAMESPACE/TYPENAME format. string type_name -# The type of the original source file, from the above constants -uint8 encoding +# The type of the original source file, typically matching the file extension. +# Well-known encodings: "idl", "msg", "srv", "action", "dynamic". +string encoding -# Dumped contents of the interface definition source file +# Dumped contents of the interface definition source file. +# If this was a type created programmatically (encoding "dynamic"), this field will be empty. string raw_file_contents diff --git a/type_description_interfaces/srv/GetTypeDescription.srv b/type_description_interfaces/srv/GetTypeDescription.srv index 6b9aa91c..8d104725 100644 --- a/type_description_interfaces/srv/GetTypeDescription.srv +++ b/type_description_interfaces/srv/GetTypeDescription.srv @@ -1,36 +1,26 @@ -# ROS interface type name, in PACKAGE/NAMESPACE/TYPENAME format +# ROS interface type name, in PACKAGE/NAMESPACE/TYPENAME format. string type_name -# REP-2011 RIHS hash string, which looks like RIHSxx_hashvalue +# REP-2011 RIHS hash string. string type_hash -# Whether to return the original idl or msg file(s) in the response, if available +# Whether to return the original idl/msg/etc. source file(s) in the response. bool include_type_sources true --- -# sources requested, and provided successfully -uint8 SOURCES_REQUESTED_PROVIDED = 0 -# sources disabled, so type_sources was left empty -uint8 SOURCES_NOT_REQUESTED_NOT_PROVIDED = 1 -# sources requested, but no source available (perhaps for dynamically created types) -uint8 SOURCES_REQUESTED_NOT_AVAILABLE = 2 - -# True if the type description information is available and populated in the response -# If false, all other fields except `reason` are considered undefined +# True if the type description information is available and populated in the response. +# If false, all other fields except `failure_reason` are considered undefined. bool successful # If `successful` is false, contains a reason for failure. -# On success, may contain a reason for missing sources. -string reason +# If `successful` is true, this is left empty. +string failure_reason -# Contains a value from above constants, explaining whether the -# `type_sources` fields contain valid data. -uint8 type_sources_result +# The parsed type description which can be used programmatically. +TypeDescription type_description -# List of idl or msg/srv/action source files, including all comments and whitespace. -# Sources can be matched with IndividualTypeDescriptions by their type_name +# List of sources, including all comments and whitespace. +# Sources can be matched with IndividualTypeDescriptions by their `type_name`. +# The `encoding` field of each entry informs how to interpret its contents. TypeSource[] type_sources -# The parsed type description which can be used programmatically -TypeDescription type_description - # Key-value pairs of extra information. KeyValue[] extra_information From a2b4f4ed0c904a8f7943a65159e3e2d8efa27f85 Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Thu, 23 Mar 2023 10:38:40 -0700 Subject: [PATCH 9/9] Add better documentation for TypeSource Signed-off-by: Emerson Knapp --- type_description_interfaces/msg/TypeSource.msg | 8 ++++++-- type_description_interfaces/srv/GetTypeDescription.srv | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/type_description_interfaces/msg/TypeSource.msg b/type_description_interfaces/msg/TypeSource.msg index ddef22c3..7c945270 100644 --- a/type_description_interfaces/msg/TypeSource.msg +++ b/type_description_interfaces/msg/TypeSource.msg @@ -4,9 +4,13 @@ string type_name # The type of the original source file, typically matching the file extension. -# Well-known encodings: "idl", "msg", "srv", "action", "dynamic". +# Well-known encodings: "idl", "msg", "srv", "action", "dynamic", "implicit". +# "dynamic" specifies a type created programmatically by a user, thus having no source. +# "implicit" specifies a type created automatically as a subtype of a +# complex type (service or action) - such as the request message for a service. +# Implicit types will have no contents, the full source will be available on the parent srv/action. string encoding # Dumped contents of the interface definition source file. -# If this was a type created programmatically (encoding "dynamic"), this field will be empty. +# If `encoding` is "dynamic" or "implicit", this field will be empty. string raw_file_contents diff --git a/type_description_interfaces/srv/GetTypeDescription.srv b/type_description_interfaces/srv/GetTypeDescription.srv index 8d104725..9d34d0d0 100644 --- a/type_description_interfaces/srv/GetTypeDescription.srv +++ b/type_description_interfaces/srv/GetTypeDescription.srv @@ -17,7 +17,10 @@ string failure_reason # The parsed type description which can be used programmatically. TypeDescription type_description -# List of sources, including all comments and whitespace. +# A list containing the interface definition source text of the requested type, +# plus all types it recursively depends on. +# Each source text is a copy of the original contents of the +# .msg, .srv, .action, .idl, or other file if it exists, including comments and whitespace. # Sources can be matched with IndividualTypeDescriptions by their `type_name`. # The `encoding` field of each entry informs how to interpret its contents. TypeSource[] type_sources