From 119004ea5fbc634e04ac816a92e8c0fabafcf1e6 Mon Sep 17 00:00:00 2001 From: ClemensLinnhoff Date: Tue, 28 May 2024 14:43:49 +0200 Subject: [PATCH 1/9] Remove parsing proto.in as osi is build anyways before, so the .proto file already exists. Signed-off-by: ClemensLinnhoff --- rules2yml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules2yml.py b/rules2yml.py index 3c30179..c4dfd43 100644 --- a/rules2yml.py +++ b/rules2yml.py @@ -44,7 +44,7 @@ def gen_yml_rules(dir_name="rules", full_osi=False): if not os.path.exists(dir_name + "/schema"): os.makedirs(dir_name + "/schema") - for file in glob("open-simulation-interface/*.proto*"): + for file in glob("open-simulation-interface/*.proto"): filename = file.split("open-simulation-interface/")[1].split(".proto")[0] if os.path.exists(f"{dir_name}/{filename}.yml"): From 387460e14eccd18cb05d1d8609ee5dd71da227bd Mon Sep 17 00:00:00 2001 From: ClemensLinnhoff Date: Tue, 28 May 2024 14:46:26 +0200 Subject: [PATCH 2/9] Add more message types Signed-off-by: ClemensLinnhoff --- open-simulation-interface | 2 +- osivalidator/osi_general_validator.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/open-simulation-interface b/open-simulation-interface index 2c3953b..8f5a8fc 160000 --- a/open-simulation-interface +++ b/open-simulation-interface @@ -1 +1 @@ -Subproject commit 2c3953b377673e92ee2846a5471bf257d37e6154 +Subproject commit 8f5a8fc5d80ce646c770d34b905a5f7f0a3c3d20 diff --git a/osivalidator/osi_general_validator.py b/osivalidator/osi_general_validator.py index e6a9f25..657a113 100755 --- a/osivalidator/osi_general_validator.py +++ b/osivalidator/osi_general_validator.py @@ -54,7 +54,7 @@ def command_line_arguments(): "--type", "-t", help="Name of the type used to serialize data. Default is SensorView.", - choices=["SensorView", "GroundTruth", "SensorData"], + choices=["SensorView", "GroundTruth", "SensorData", "TrafficUpdate", "TrafficCommandUpdate", "TrafficCommand"], type=str, required=False, ) @@ -138,6 +138,12 @@ def detect_message_type(path: str): return "SensorView" if filename.find("_gt_") != -1: return "GroundTruth" + if filename.find("_tu_") != -1: + return "TrafficUpdate" + if filename.find("_tcu_") != -1: + return "TrafficCommandUpdate" + if filename.find("_tc_") != -1: + return "TrafficCommand" return "SensorView" From 40f542f966c2c11743c4881ed3e8ae71aa74ba44 Mon Sep 17 00:00:00 2001 From: ClemensLinnhoff Date: Tue, 28 May 2024 14:50:05 +0200 Subject: [PATCH 3/9] Formatting Signed-off-by: ClemensLinnhoff --- osivalidator/osi_general_validator.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osivalidator/osi_general_validator.py b/osivalidator/osi_general_validator.py index 657a113..a7c6b49 100755 --- a/osivalidator/osi_general_validator.py +++ b/osivalidator/osi_general_validator.py @@ -54,7 +54,14 @@ def command_line_arguments(): "--type", "-t", help="Name of the type used to serialize data. Default is SensorView.", - choices=["SensorView", "GroundTruth", "SensorData", "TrafficUpdate", "TrafficCommandUpdate", "TrafficCommand"], + choices=[ + "SensorView", + "GroundTruth", + "SensorData", + "TrafficUpdate", + "TrafficCommandUpdate", + "TrafficCommand", + ], type=str, required=False, ) From dd3f775008f8dc5720ebe5ac20493fe7b3ec8b77 Mon Sep 17 00:00:00 2001 From: ClemensLinnhoff Date: Tue, 28 May 2024 14:53:53 +0200 Subject: [PATCH 4/9] Readd proto.in Signed-off-by: ClemensLinnhoff --- rules2yml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules2yml.py b/rules2yml.py index c4dfd43..3c30179 100644 --- a/rules2yml.py +++ b/rules2yml.py @@ -44,7 +44,7 @@ def gen_yml_rules(dir_name="rules", full_osi=False): if not os.path.exists(dir_name + "/schema"): os.makedirs(dir_name + "/schema") - for file in glob("open-simulation-interface/*.proto"): + for file in glob("open-simulation-interface/*.proto*"): filename = file.split("open-simulation-interface/")[1].split(".proto")[0] if os.path.exists(f"{dir_name}/{filename}.yml"): From 788666bab8d9dac3e9057828156e17629a7803df Mon Sep 17 00:00:00 2001 From: ClemensLinnhoff Date: Tue, 28 May 2024 14:58:37 +0200 Subject: [PATCH 5/9] Fix double version schema bug Signed-off-by: ClemensLinnhoff --- rules2yml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules2yml.py b/rules2yml.py index 3c30179..fd9a9c8 100644 --- a/rules2yml.py +++ b/rules2yml.py @@ -47,7 +47,7 @@ def gen_yml_rules(dir_name="rules", full_osi=False): for file in glob("open-simulation-interface/*.proto*"): filename = file.split("open-simulation-interface/")[1].split(".proto")[0] - if os.path.exists(f"{dir_name}/{filename}.yml"): + if os.path.exists(f"{dir_name}/schema/{filename}_schema.yml"): continue with open(f"{dir_name}/schema/{filename}_schema.yml", "a") as schema_file: From 37b435679eae1364a2a09bf88da2e9b93e65b401 Mon Sep 17 00:00:00 2001 From: ClemensLinnhoff Date: Tue, 11 Jun 2024 09:46:31 +0200 Subject: [PATCH 6/9] Update osi to current master Signed-off-by: ClemensLinnhoff --- open-simulation-interface | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open-simulation-interface b/open-simulation-interface index 8f5a8fc..4a5f43f 160000 --- a/open-simulation-interface +++ b/open-simulation-interface @@ -1 +1 @@ -Subproject commit 8f5a8fc5d80ce646c770d34b905a5f7f0a3c3d20 +Subproject commit 4a5f43ff6b5ae09ea33851b2928fbb0bb69a21fa From e8bc22ca23f063857379396bfe56d290e11483f8 Mon Sep 17 00:00:00 2001 From: ClemensLinnhoff Date: Tue, 11 Jun 2024 09:47:29 +0200 Subject: [PATCH 7/9] Change osi requirement to current master Signed-off-by: ClemensLinnhoff --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ef661b6..49d94f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ ruamel.yaml>=0.18.5 defusedxml>=0.7.1 iso3166>=2.1.1 protobuf>=4.24.4 -open-simulation-interface @ git+https://github.com/OpenSimulationInterface/open-simulation-interface.git@v3.7.0-rc1 +open-simulation-interface @ git+https://github.com/OpenSimulationInterface/open-simulation-interface.git@master From 614a3cc67510f1cf43feaeadfa7763c11e924ce7 Mon Sep 17 00:00:00 2001 From: ClemensLinnhoff Date: Tue, 11 Jun 2024 10:47:04 +0200 Subject: [PATCH 8/9] Add remaining message types and unit tests Signed-off-by: ClemensLinnhoff --- osivalidator/osi_general_validator.py | 12 +++++ tests/test_osi_general_validator.py | 69 +++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 tests/test_osi_general_validator.py diff --git a/osivalidator/osi_general_validator.py b/osivalidator/osi_general_validator.py index fd348c9..c35984c 100755 --- a/osivalidator/osi_general_validator.py +++ b/osivalidator/osi_general_validator.py @@ -56,11 +56,15 @@ def command_line_arguments(): help="Name of the type used to serialize data. Default is SensorView.", choices=[ "SensorView", + "SensorViewConfiguration", "GroundTruth", + "HostVehicleData", "SensorData", "TrafficUpdate", "TrafficCommandUpdate", "TrafficCommand", + "MotionRequest", + "StreamingUpdate" ], type=str, required=False, @@ -143,6 +147,8 @@ def detect_message_type(path: str): return "SensorData" if filename.find("_sv_") != -1: return "SensorView" + if filename.find("_svc_") != -1: + return "SensorViewConfiguration" if filename.find("_gt_") != -1: return "GroundTruth" if filename.find("_tu_") != -1: @@ -151,6 +157,12 @@ def detect_message_type(path: str): return "TrafficCommandUpdate" if filename.find("_tc_") != -1: return "TrafficCommand" + if filename.find("_hvd_") != -1: + return "HostVehicleData" + if filename.find("_mr_") != -1: + return "MotionRequest" + if filename.find("_su_") != -1: + return "StreamingUpdate" return "SensorView" diff --git a/tests/test_osi_general_validator.py b/tests/test_osi_general_validator.py new file mode 100644 index 0000000..4fc8544 --- /dev/null +++ b/tests/test_osi_general_validator.py @@ -0,0 +1,69 @@ +import unittest +from osivalidator.osi_general_validator import detect_message_type + + +class TestDetectMessageType(unittest.TestCase): + + def test_detect_message_type_sensor_data(self): + path = "path/to/file_sd_123.osi" + message_type = detect_message_type(path) + self.assertEqual(message_type, "SensorData") + + def test_detect_message_type_sensor_view(self): + path = "path/to/file_sv_123.osi" + message_type = detect_message_type(path) + self.assertEqual(message_type, "SensorView") + + def test_detect_message_type_sensor_view_config(self): + path = "path/to/file_svc_123.osi" + message_type = detect_message_type(path) + self.assertEqual(message_type, "SensorViewConfiguration") + + def test_detect_message_type_ground_truth(self): + path = "path/to/file_gt_123.osi" + message_type = detect_message_type(path) + self.assertEqual(message_type, "GroundTruth") + + def test_detect_message_type_traffic_update(self): + path = "path/to/file_tu_123.osi" + message_type = detect_message_type(path) + self.assertEqual(message_type, "TrafficUpdate") + + def test_detect_message_type_traffic_command_update(self): + path = "path/to/file_tcu_123.osi" + message_type = detect_message_type(path) + self.assertEqual(message_type, "TrafficCommandUpdate") + + def test_detect_message_type_traffic_command(self): + path = "path/to/file_tc_123.osi" + message_type = detect_message_type(path) + self.assertEqual(message_type, "TrafficCommand") + + def test_detect_message_type_host_vehicle_data(self): + path = "path/to/file_hvd_123.osi" + message_type = detect_message_type(path) + self.assertEqual(message_type, "HostVehicleData") + + def test_detect_message_type_motion_request(self): + path = "path/to/file_mr_123.osi" + message_type = detect_message_type(path) + self.assertEqual(message_type, "MotionRequest") + + def test_detect_message_type_streaming_update(self): + path = "path/to/file_su_123.osi" + message_type = detect_message_type(path) + self.assertEqual(message_type, "StreamingUpdate") + + def test_detect_message_type_unknown(self): + path = "path/to/unknown_file.osi" + message_type = detect_message_type(path) + self.assertEqual(message_type, "SensorView") + + def test_detect_message_type_empty_path(self): + path = "" + message_type = detect_message_type(path) + self.assertEqual(message_type, "SensorView") + + +if __name__ == '__main__': + unittest.main() From 2df777613e1e782862cf0ecfae4ff3e1343bdd79 Mon Sep 17 00:00:00 2001 From: ClemensLinnhoff Date: Tue, 11 Jun 2024 10:48:09 +0200 Subject: [PATCH 9/9] Formatting Signed-off-by: ClemensLinnhoff --- osivalidator/osi_general_validator.py | 2 +- tests/test_osi_general_validator.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/osivalidator/osi_general_validator.py b/osivalidator/osi_general_validator.py index c35984c..133527d 100755 --- a/osivalidator/osi_general_validator.py +++ b/osivalidator/osi_general_validator.py @@ -64,7 +64,7 @@ def command_line_arguments(): "TrafficCommandUpdate", "TrafficCommand", "MotionRequest", - "StreamingUpdate" + "StreamingUpdate", ], type=str, required=False, diff --git a/tests/test_osi_general_validator.py b/tests/test_osi_general_validator.py index 4fc8544..704cacf 100644 --- a/tests/test_osi_general_validator.py +++ b/tests/test_osi_general_validator.py @@ -3,7 +3,6 @@ class TestDetectMessageType(unittest.TestCase): - def test_detect_message_type_sensor_data(self): path = "path/to/file_sd_123.osi" message_type = detect_message_type(path) @@ -65,5 +64,5 @@ def test_detect_message_type_empty_path(self): self.assertEqual(message_type, "SensorView") -if __name__ == '__main__': +if __name__ == "__main__": unittest.main()