From 61f13567295c6b8d40c43a3a3cceb018c8de8e30 Mon Sep 17 00:00:00 2001 From: Raphael Riebl Date: Fri, 3 Jan 2025 12:37:59 +0100 Subject: [PATCH] codegen-py: fix missing DENM msg files in CMakeLists.txt --- .../etsi_its_denm_msgs/CMakeLists.txt | 24 ++++++++++++++++++ .../codegen-py/asn1ToConversionHeader.py | 23 ++++++++++++----- utils/codegen/codegen-py/asn1ToRosMsg.py | 25 +++++++++++++------ 3 files changed, 59 insertions(+), 13 deletions(-) diff --git a/etsi_its_msgs/etsi_its_denm_msgs/CMakeLists.txt b/etsi_its_msgs/etsi_its_denm_msgs/CMakeLists.txt index 10485538..a3de37e0 100644 --- a/etsi_its_msgs/etsi_its_denm_msgs/CMakeLists.txt +++ b/etsi_its_msgs/etsi_its_denm_msgs/CMakeLists.txt @@ -11,7 +11,12 @@ if(${ROS_VERSION} EQUAL 2) find_package(rosidl_default_generators REQUIRED) set(msg_files + "msg/AccidentSubCauseCode.msg" "msg/ActionID.msg" + "msg/AdverseWeatherConditionAdhesionSubCauseCode.msg" + "msg/AdverseWeatherConditionExtremeWeatherConditionSubCauseCode.msg" + "msg/AdverseWeatherConditionPrecipitationSubCauseCode.msg" + "msg/AdverseWeatherConditionVisibilitySubCauseCode.msg" "msg/AlacarteContainer.msg" "msg/Altitude.msg" "msg/AltitudeConfidence.msg" @@ -19,23 +24,33 @@ if(${ROS_VERSION} EQUAL 2) "msg/CauseCode.msg" "msg/CauseCodeType.msg" "msg/ClosedLanes.msg" + "msg/CollisionRiskSubCauseCode.msg" "msg/DENM.msg" + "msg/DangerousEndOfQueueSubCauseCode.msg" "msg/DangerousGoodsBasic.msg" "msg/DangerousGoodsExtended.msg" + "msg/DangerousSituationSubCauseCode.msg" "msg/DecentralizedEnvironmentalNotificationMessage.msg" "msg/DeltaAltitude.msg" "msg/DeltaLatitude.msg" "msg/DeltaLongitude.msg" "msg/DeltaReferencePosition.msg" "msg/DrivingLaneStatus.msg" + "msg/EmergencyVehicleApproachingSubCauseCode.msg" "msg/EnergyStorageType.msg" "msg/EventHistory.msg" "msg/EventPoint.msg" "msg/HardShoulderStatus.msg" + "msg/HazardousLocationAnimalOnTheRoadSubCauseCode.msg" + "msg/HazardousLocationDangerousCurveSubCauseCode.msg" + "msg/HazardousLocationObstacleOnTheRoadSubCauseCode.msg" + "msg/HazardousLocationSurfaceConditionSubCauseCode.msg" "msg/Heading.msg" "msg/HeadingConfidence.msg" "msg/HeadingValue.msg" "msg/HeightLonCarr.msg" + "msg/HumanPresenceOnTheRoadSubCauseCode.msg" + "msg/HumanProblemSubCauseCode.msg" "msg/ImpactReductionContainer.msg" "msg/InformationQuality.msg" "msg/ItineraryPath.msg" @@ -59,17 +74,22 @@ if(${ROS_VERSION} EQUAL 2) "msg/PositionOfOccupants.msg" "msg/PositionOfPillars.msg" "msg/PositioningSolutionType.msg" + "msg/PostCrashSubCauseCode.msg" "msg/ReferenceDenms.msg" "msg/ReferencePosition.msg" "msg/RelevanceDistance.msg" "msg/RelevanceTrafficDirection.msg" "msg/RequestResponseIndication.msg" + "msg/RescueAndRecoveryWorkInProgressSubCauseCode.msg" "msg/RestrictedTypes.msg" "msg/RoadType.msg" "msg/RoadWorksContainerExtended.msg" + "msg/RoadworksSubCauseCode.msg" "msg/SemiAxisLength.msg" "msg/SequenceNumber.msg" + "msg/SignalViolationSubCauseCode.msg" "msg/SituationContainer.msg" + "msg/SlowVehicleSubCauseCode.msg" "msg/Speed.msg" "msg/SpeedConfidence.msg" "msg/SpeedLimit.msg" @@ -78,20 +98,24 @@ if(${ROS_VERSION} EQUAL 2) "msg/StationType.msg" "msg/StationarySince.msg" "msg/StationaryVehicleContainer.msg" + "msg/StationaryVehicleSubCauseCode.msg" "msg/SubCauseCodeType.msg" "msg/Temperature.msg" "msg/Termination.msg" "msg/TimestampIts.msg" "msg/Traces.msg" + "msg/TrafficConditionSubCauseCode.msg" "msg/TrafficRule.msg" "msg/TransmissionInterval.msg" "msg/TurningRadius.msg" "msg/VDS.msg" "msg/ValidityDuration.msg" + "msg/VehicleBreakdownSubCauseCode.msg" "msg/VehicleIdentification.msg" "msg/VehicleMass.msg" "msg/WMInumber.msg" "msg/WheelBaseVehicle.msg" + "msg/WrongWayDrivingSubCauseCode.msg" ) rosidl_generate_interfaces(${PROJECT_NAME} diff --git a/utils/codegen/codegen-py/asn1ToConversionHeader.py b/utils/codegen/codegen-py/asn1ToConversionHeader.py index 4c78a41b..4bb7e64e 100755 --- a/utils/codegen/codegen-py/asn1ToConversionHeader.py +++ b/utils/codegen/codegen-py/asn1ToConversionHeader.py @@ -166,11 +166,22 @@ def findDependenciesOfConversionHeaders(parent_file_path: str, type: str, file_l new_file_list.append(msg_type) new_file_list = findDependenciesOfConversionHeaders(f"{os.path.dirname(parent_file_path)}/{msg_type}.h", type, new_file_list) - # make sure there are no duplicates and sort alphabetically - new_file_list = sorted(list(set(new_file_list))) - return new_file_list +def additionalMessageTypes(path: str, msg_type: str) -> List[str]: + additional = [] + + for f in glob.glob(os.path.join(path, "*.h")): + msg_filename = os.path.splitext(os.path.basename(f))[0] + if msg_type == "DENM" and msg_filename.endswith("SubCauseCode"): + additional.append(msg_filename) + + return additional + +def sortHeaderFiles(files: List[str]) -> List[str]: + # make sure there are no duplicates and sort alphabetically + return sorted(list(set(files))) + def main(): args = parseCli() @@ -206,11 +217,11 @@ def main(): elif args.type == "vam_ts": msg_type = "VAM" header_files = findDependenciesOfConversionHeaders(os.path.join(args.output_dir, f"convert{msg_type}.h"), args.type, [f"convert{msg_type}"]) + header_files += additionalMessageTypes(args.output_dir, msg_type) + header_files = sortHeaderFiles(header_files) + for f in glob.glob(os.path.join(args.output_dir, "*.h")): header_filename = os.path.splitext(os.path.basename(f))[0] - if msg_type == "DENM" and header_filename.endswith("SubCauseCode"): - # keep all SubCauseCode variants for DENM - continue if header_filename not in header_files: os.remove(f) diff --git a/utils/codegen/codegen-py/asn1ToRosMsg.py b/utils/codegen/codegen-py/asn1ToRosMsg.py index cc4ca51f..0408bb16 100755 --- a/utils/codegen/codegen-py/asn1ToRosMsg.py +++ b/utils/codegen/codegen-py/asn1ToRosMsg.py @@ -138,11 +138,22 @@ def findDependenciesOfRosMessageType(parent_file_path: str, file_list: List[str] new_file_list.append(msg_type) new_file_list = findDependenciesOfRosMessageType(f"{os.path.dirname(parent_file_path)}/{msg_type}.msg", new_file_list) - # make sure there are no duplicates and sort alphabetically - new_file_list = sorted(list(set(new_file_list))) - return new_file_list +def additionalMessageTypes(path: str, msg_type: str) -> List[str]: + additional = [] + + for f in glob.glob(os.path.join(path, "*.msg")): + msg_filename = os.path.splitext(os.path.basename(f))[0] + if msg_type == "DENM" and msg_filename.endswith("SubCauseCode"): + additional.append(msg_filename) + + return additional + +def sortMessageFiles(files: List[str]) -> List[str]: + # make sure there are no duplicates and sort alphabetically + return sorted(list(set(files))) + def generateCMakeLists(msg_files: list, file_path: str, type: str) -> None: with open(file_path, "w") as f: msg_file_lines = "\n".join([f" \"msg/{msg_file}.msg\"" for msg_file in msg_files]) @@ -233,15 +244,15 @@ def main(): elif args.type == "vam_ts": msg_type = "VAM" msg_files = findDependenciesOfRosMessageType(os.path.join(args.output_dir, f"{msg_type}.msg"), [msg_type]) + msg_files += additionalMessageTypes(args.output_dir, msg_type) + msg_files = sortMessageFiles(msg_files) + print("Generating CMakeLists.txt ...") generateCMakeLists(msg_files, os.path.join(args.output_dir, "../CMakeLists.txt"), args.type) print("Removing files not required for top-level message type ...") for f in glob.glob(os.path.join(args.output_dir, "*.msg")): msg_filename = os.path.splitext(os.path.basename(f))[0] - if msg_type == "DENM" and msg_filename.endswith("SubCauseCode"): - # keep all SubCauseCode variants for DENM - continue - elif msg_filename not in msg_files: + if msg_filename not in msg_files: os.remove(f) print(f"Generated {len(msg_files)} ROS .msg files for {msg_type}")