From c8b399b12da725bb6939965691a94f35713ff03b Mon Sep 17 00:00:00 2001 From: "Pierre R. Mai" Date: Thu, 15 Jun 2023 13:17:05 +0200 Subject: [PATCH 1/4] Fix flatbuffer build against previous build changes This fixes the flatc calls which were broken due to clearer separation of build and source directory usage. Signed-off-by: Pierre R. Mai --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f37803ff..4fe9c0acc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,9 +111,9 @@ if(OSI_BUILD_FLATBUFFER) set(fbs "${proto_base}.fbs") add_custom_command( OUTPUT "${fbs}" - COMMAND $ -I "${PROTOBUF_IMPORT_DIRS}" -o "${CMAKE_CURRENT_BINARY_DIR}" --proto "${CMAKE_CURRENT_SOURCE_DIR}/${proto}" + COMMAND $ -I "${PROTOBUF_IMPORT_DIRS}" -I "${CMAKE_CURRENT_BINARY_DIR}" -o "${CMAKE_CURRENT_BINARY_DIR}" --proto "${proto}" DEPENDS "${proto}" flatc - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMENT "Convert ${proto} to ${fbs} using flatc" ) list(APPEND FLAT_FBS "${CMAKE_CURRENT_BINARY_DIR}/${fbs}") From 55bfcf7460c988cd6191c003f8096483000f08d7 Mon Sep 17 00:00:00 2001 From: "Pierre R. Mai" Date: Thu, 15 Jun 2023 17:39:54 +0200 Subject: [PATCH 2/4] Switch to findpackage for flatbuffers dependency Signed-off-by: Pierre R. Mai --- .gitmodules | 3 --- CMakeLists.txt | 17 +++++++++-------- flatbuffers | 1 - 3 files changed, 9 insertions(+), 12 deletions(-) delete mode 160000 flatbuffers diff --git a/.gitmodules b/.gitmodules index af7fa7314..e69de29bb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "flatbuffers"] - path = flatbuffers - url = https://github.com/google/flatbuffers.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fe9c0acc..4d4334747 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,9 +100,10 @@ protobuf_generate_cpp(PROTO_SRCS PROTO_HEADERS ${OSI_PROTO_FILES}) set(FLAT_HEADERS "") if(OSI_BUILD_FLATBUFFER) set(FLAT_FBS "") - add_subdirectory("flatbuffers" - ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-build - EXCLUDE_FROM_ALL) + find_package(flatbuffers REQUIRED) + if(NOT FLATBUFFERS_FLATC_EXECUTABLE) + set(FLATBUFFERS_FLATC_EXECUTABLE ${flatbuffers_DIR}/../../tools/flatbuffers/flatc) + endif() file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/descriptor.fbs" "namespace osi3;") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include") list(APPEND FLAT_FBS "${CMAKE_CURRENT_BINARY_DIR}/descriptor.fbs") @@ -111,8 +112,8 @@ if(OSI_BUILD_FLATBUFFER) set(fbs "${proto_base}.fbs") add_custom_command( OUTPUT "${fbs}" - COMMAND $ -I "${PROTOBUF_IMPORT_DIRS}" -I "${CMAKE_CURRENT_BINARY_DIR}" -o "${CMAKE_CURRENT_BINARY_DIR}" --proto "${proto}" - DEPENDS "${proto}" flatc + COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} -I "${PROTOBUF_IMPORT_DIRS}" -I "${CMAKE_CURRENT_BINARY_DIR}" -o "${CMAKE_CURRENT_BINARY_DIR}" --proto "${proto}" + DEPENDS "${proto}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMENT "Convert ${proto} to ${fbs} using flatc" ) @@ -125,8 +126,8 @@ if(OSI_BUILD_FLATBUFFER) set(fbh "${flat_base}_generated.h") add_custom_command( OUTPUT "include/${fbh}" - COMMAND $ -o "${CMAKE_CURRENT_BINARY_DIR}/include" --cpp --gen-mutable --gen-name-strings --scoped-enums "${fbs}" - DEPENDS "${FLAT_FBS}" flatc + COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} -o "${CMAKE_CURRENT_BINARY_DIR}/include" --cpp --gen-mutable --gen-name-strings --scoped-enums "${fbs}" + DEPENDS "${FLAT_FBS}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" COMMENT "Process ${fbs} to ${fbh} using flatc" ) @@ -137,7 +138,7 @@ if(OSI_BUILD_FLATBUFFER) add_library(${PROJECT_NAME}_fbs INTERFACE) target_include_directories(${PROJECT_NAME}_fbs INTERFACE $) target_include_directories(${PROJECT_NAME}_fbs SYSTEM INTERFACE $/include>) - target_link_libraries(${PROJECT_NAME}_fbs INTERFACE flatbuffers) + target_link_libraries(${PROJECT_NAME}_fbs INTERFACE flatbuffers::flatbuffers) endif() add_library(${PROJECT_NAME}_static STATIC ${PROTO_SRCS} ${PROTO_HEADERS}) diff --git a/flatbuffers b/flatbuffers deleted file mode 160000 index 6df40a247..000000000 --- a/flatbuffers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6df40a2471737b27271bdd9b900ab5f3aec746c7 From 1f113a3e4413446e397cf31003b06957d37f5550 Mon Sep 17 00:00:00 2001 From: "Pierre R. Mai" Date: Thu, 15 Jun 2023 17:56:02 +0200 Subject: [PATCH 3/4] Reorder enum declaration and use for duplicated type names This is a temporary work-around for a bug in the flatc compiler when translating protobuf idl to fbs idl, where definition after use will confuse the compiler when type names are reused in the same file but different surrounding types. Signed-off-by: Pierre R. Mai --- osi_lane.proto | 43 ++++---- osi_object.proto | 104 +++++++++---------- osi_trafficsign.proto | 226 +++++++++++++++++++++--------------------- 3 files changed, 187 insertions(+), 186 deletions(-) diff --git a/osi_lane.proto b/osi_lane.proto index 062eb6a00..c95a30de1 100644 --- a/osi_lane.proto +++ b/osi_lane.proto @@ -973,27 +973,6 @@ message LaneBoundary // message Classification { - // The type of the lane boundary. - // - optional Type type = 1; - - // The semantic color of the lane boundary in case of lane markings. - // - // \note The color types represent the semantic classification of - // lane markings only. They do not represent an actual visual appearance. - // - optional Color color = 2; - - // The ids of \c StationaryObject which limit the corresponding lane. - // This field must be set if the \c #type is set to - // \c #TYPE_STRUCTURE - // - // \rules - // refers_to: StationaryObject - // \endrules - // - repeated Identifier limiting_structure_id = 3; - // The lane boundary type. // There is no special representation for double lines, e.g. solid / // solid or dashed / solid. In such cases, each lane will define its own @@ -1070,6 +1049,28 @@ message LaneBoundary TYPE_SOUND_BARRIER = 15; } + // The type of the lane boundary. + // + optional Type type = 1; + + // The semantic color of the lane boundary in case of lane markings. + // + // \note The color types represent the semantic classification of + // lane markings only. They do not represent an actual visual appearance. + // + optional Color color = 2; + + // The ids of \c StationaryObject which limit the corresponding lane. + // This field must be set if the \c #type is set to + // \c #TYPE_STRUCTURE + // + // \rules + // refers_to: StationaryObject + // \endrules + // + repeated Identifier limiting_structure_id = 3; + + // The semantic color of the lane boundary in case of a lane markings. // Lane markings that alternate in color must be represented by // individual \c LaneBoundary segments. diff --git a/osi_object.proto b/osi_object.proto index 94065881b..f2471e433 100644 --- a/osi_object.proto +++ b/osi_object.proto @@ -400,6 +400,31 @@ message MovingObject // optional BaseMoving base = 2; + // Definition of object types. + // + enum Type + { + // Type of the object is unknown (must not be used in ground truth). + // + TYPE_UNKNOWN = 0; + + // Other (unspecified but known) type of moving object. + // + TYPE_OTHER = 1; + + // Object is a vehicle. + // + TYPE_VEHICLE = 2; + + // Object is a pedestrian. + // + TYPE_PEDESTRIAN = 3; + + // Object is an animal. + // + TYPE_ANIMAL = 4; + } + // The type of the object. // optional Type type = 3; @@ -488,31 +513,6 @@ message MovingObject // optional ColorDescription color_description = 11; - // Definition of object types. - // - enum Type - { - // Type of the object is unknown (must not be used in ground truth). - // - TYPE_UNKNOWN = 0; - - // Other (unspecified but known) type of moving object. - // - TYPE_OTHER = 1; - - // Object is a vehicle. - // - TYPE_VEHICLE = 2; - - // Object is a pedestrian. - // - TYPE_PEDESTRIAN = 3; - - // Object is an animal. - // - TYPE_ANIMAL = 4; - } - // // \brief The vehicle attributes for \c MovingObject (host or other). // @@ -727,33 +727,6 @@ message MovingObject // message VehicleClassification { - // The type of the vehicle. - // - optional Type type = 1; - - // The light state of the vehicle. - // - optional LightState light_state = 2; - - // Flag defining whether the vehicle has an attached trailer. - // - optional bool has_trailer = 3; - - // Id of the attached trailer. - // - // \note Field need not be set if has_Trailer is set to false or use - // value for non valid id. - // - // \rules - // check_if this.has_trailer is_equal_to true else do_check is_set - // \endrules - // - optional Identifier trailer_id = 4; - - // The role of the vehicle. - // - optional Role role = 5; - // Definition of vehicle types. // // \note OSI provides a richer set of vehicle types than is supported by some @@ -873,6 +846,33 @@ message MovingObject TYPE_STANDUP_SCOOTER = 17; } + // The type of the vehicle. + // + optional Type type = 1; + + // The light state of the vehicle. + // + optional LightState light_state = 2; + + // Flag defining whether the vehicle has an attached trailer. + // + optional bool has_trailer = 3; + + // Id of the attached trailer. + // + // \note Field need not be set if has_Trailer is set to false or use + // value for non valid id. + // + // \rules + // check_if this.has_trailer is_equal_to true else do_check is_set + // \endrules + // + optional Identifier trailer_id = 4; + + // The role of the vehicle. + // + optional Role role = 5; + // // \brief The state of the lights of a vehicle. // diff --git a/osi_trafficsign.proto b/osi_trafficsign.proto index 8bc362d72..f15aad856 100644 --- a/osi_trafficsign.proto +++ b/osi_trafficsign.proto @@ -5630,119 +5630,6 @@ message TrafficSign // optional Variability variability = 1; - // Type of the supplementary sign. - // - // \attention Deprecated: A revision is planned for version 4.0.0 to - // replace the type enum with a more semantically defined enumeration, - // with the exact sign specification being relegated to the newly - // introduced 4-tupel traffic sign catalog specification as used in - // OpenDRIVE. - // - optional Type type = 2; - - // Additional value(s) associated with the traffic sign, e.g. - // length, mass or starting time in time range. - // - // \note Field need not be set if traffic sign type does not require - // it. - // - // \note OSI uses singular instead of plural for repeated field - // names. - // - repeated TrafficSignValue value = 3; - - // The IDs of the lanes that the sign is assigned to. - // May be multiple if the sign is valid for multiple lanes. - // - // \note OSI uses singular instead of plural for repeated field - // names. - // - // \rules - // refers_to: Lane - // \endrules - // - repeated Identifier assigned_lane_id = 4; - - // This enumerator indicates a traffic actor (e.g. - // bikes, cars, trucks and so on), that the supplementary sign - // makes reference to. - // - // \attention Deprecated: A revision is planned for version 4.0.0 to - // replace the type enum with a more semantically defined enumeration, - // with the exact sign specification being relegated to the newly - // introduced 4-tupel traffic sign catalog specification as used in - // OpenDRIVE. - // - repeated Actor actor = 5; - - // A direction arrow shown on the supplementary sign. - // - // \attention Deprecated: A revision is planned for version 4.0.0 to - // replace the type enum with a more semantically defined enumeration, - // with the exact sign specification being relegated to the newly - // introduced 4-tupel traffic sign catalog specification as used in - // OpenDRIVE. - // - repeated Arrow arrow = 6; - - // Boolean flag to indicate that the supplementary traffic sign is taken out of service. - // This can be achieved by visibly crossing the sign or covering it completely. - // - optional bool is_out_of_service = 7; - - // Country specification of the traffic sign catalog specification - // that identifies the actual traffic sign. This is part of the - // 4-tupel traffic sign catalog specification as used in - // OpenDRIVE. - // - // Country is specified using the ISO 3166-1, alpha-2 code - // https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2, or the - // special OpenDRIVE country for generic signs.
- // - optional string country = 8; - - // Revision specification of the traffic sign catalog specification - // that identifies the actual traffic sign. This is part of the - // 4-tupel traffic sign catalog specification as used in - // OpenDRIVE. - // - // The year the traffic rules came into force.
- // e.g. "2017" - // - optional string country_revision = 9; - - // Code specification of the traffic sign catalog specification - // that identifies the actual traffic sign. This is part of the - // 4-tupel traffic sign catalog specification as used in - // OpenDRIVE. - // - // Code identifier according to country and country revision, - // corresponds to the type field of OpenDRIVE.
- // code is only unique in combination with #country and #country_revision.
- // e.g. http://www.vzkat.de/2017/VzKat.htm - // - optional string code = 10; - - // Sub-code specification of the traffic sign catalog specification - // that identifies the actual traffic sign. This is part of the - // 4-tupel traffic sign catalog specification as used in - // OpenDRIVE. - // - // Sub-code identifier according to country, country revision and code, - // corresponds to the subtype field of OpenDRIVE.
- // sub_code is only unique in combination with #country, #country_revision, - // and #code.
- // e.g. http://www.vzkat.de/2017/VzKat.htm - // - optional string sub_code = 11; - - // Assignment of this object to logical lanes. - // - // \note OSI uses singular instead of plural for repeated field - // names. - // - repeated LogicalLaneAssignment logical_lane_assignment = 12; - // Definition of supplementary sign types. // // For general supplementary signs use \c #TYPE_TEXT. @@ -9175,6 +9062,119 @@ message TrafficSign // After that, manually increment last_counter } + // Type of the supplementary sign. + // + // \attention Deprecated: A revision is planned for version 4.0.0 to + // replace the type enum with a more semantically defined enumeration, + // with the exact sign specification being relegated to the newly + // introduced 4-tupel traffic sign catalog specification as used in + // OpenDRIVE. + // + optional Type type = 2; + + // Additional value(s) associated with the traffic sign, e.g. + // length, mass or starting time in time range. + // + // \note Field need not be set if traffic sign type does not require + // it. + // + // \note OSI uses singular instead of plural for repeated field + // names. + // + repeated TrafficSignValue value = 3; + + // The IDs of the lanes that the sign is assigned to. + // May be multiple if the sign is valid for multiple lanes. + // + // \note OSI uses singular instead of plural for repeated field + // names. + // + // \rules + // refers_to: Lane + // \endrules + // + repeated Identifier assigned_lane_id = 4; + + // This enumerator indicates a traffic actor (e.g. + // bikes, cars, trucks and so on), that the supplementary sign + // makes reference to. + // + // \attention Deprecated: A revision is planned for version 4.0.0 to + // replace the type enum with a more semantically defined enumeration, + // with the exact sign specification being relegated to the newly + // introduced 4-tupel traffic sign catalog specification as used in + // OpenDRIVE. + // + repeated Actor actor = 5; + + // A direction arrow shown on the supplementary sign. + // + // \attention Deprecated: A revision is planned for version 4.0.0 to + // replace the type enum with a more semantically defined enumeration, + // with the exact sign specification being relegated to the newly + // introduced 4-tupel traffic sign catalog specification as used in + // OpenDRIVE. + // + repeated Arrow arrow = 6; + + // Boolean flag to indicate that the supplementary traffic sign is taken out of service. + // This can be achieved by visibly crossing the sign or covering it completely. + // + optional bool is_out_of_service = 7; + + // Country specification of the traffic sign catalog specification + // that identifies the actual traffic sign. This is part of the + // 4-tupel traffic sign catalog specification as used in + // OpenDRIVE. + // + // Country is specified using the ISO 3166-1, alpha-2 code + // https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2, or the + // special OpenDRIVE country for generic signs.
+ // + optional string country = 8; + + // Revision specification of the traffic sign catalog specification + // that identifies the actual traffic sign. This is part of the + // 4-tupel traffic sign catalog specification as used in + // OpenDRIVE. + // + // The year the traffic rules came into force.
+ // e.g. "2017" + // + optional string country_revision = 9; + + // Code specification of the traffic sign catalog specification + // that identifies the actual traffic sign. This is part of the + // 4-tupel traffic sign catalog specification as used in + // OpenDRIVE. + // + // Code identifier according to country and country revision, + // corresponds to the type field of OpenDRIVE.
+ // code is only unique in combination with #country and #country_revision.
+ // e.g. http://www.vzkat.de/2017/VzKat.htm + // + optional string code = 10; + + // Sub-code specification of the traffic sign catalog specification + // that identifies the actual traffic sign. This is part of the + // 4-tupel traffic sign catalog specification as used in + // OpenDRIVE. + // + // Sub-code identifier according to country, country revision and code, + // corresponds to the subtype field of OpenDRIVE.
+ // sub_code is only unique in combination with #country, #country_revision, + // and #code.
+ // e.g. http://www.vzkat.de/2017/VzKat.htm + // + optional string sub_code = 11; + + // Assignment of this object to logical lanes. + // + // \note OSI uses singular instead of plural for repeated field + // names. + // + repeated LogicalLaneAssignment logical_lane_assignment = 12; + // Definition of the traffic actors the supplementary sign makes // reference to. E.g. bikes, trucks, cars, etc. // From ba5b394da2c034e3e0f62419f45072260c67a6f7 Mon Sep 17 00:00:00 2001 From: "Pierre R. Mai" Date: Thu, 15 Jun 2023 18:07:33 +0200 Subject: [PATCH 4/4] Add missing project-scope alias for flatbuffers library Signed-off-by: Pierre R. Mai --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d4334747..8cb07187e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,7 @@ if(OSI_BUILD_FLATBUFFER) add_custom_target(${PROJECT_NAME}_fbs_build ALL DEPENDS "${FLAT_HEADERS}") add_library(${PROJECT_NAME}_fbs INTERFACE) + add_library(${PROJECT_NAME}::${PROJECT_NAME}_fbs ALIAS ${PROJECT_NAME}_fbs) target_include_directories(${PROJECT_NAME}_fbs INTERFACE $) target_include_directories(${PROJECT_NAME}_fbs SYSTEM INTERFACE $/include>) target_link_libraries(${PROJECT_NAME}_fbs INTERFACE flatbuffers::flatbuffers)