diff --git a/open-simulation-interface b/open-simulation-interface index 2c3953b..4a5f43f 160000 --- a/open-simulation-interface +++ b/open-simulation-interface @@ -1 +1 @@ -Subproject commit 2c3953b377673e92ee2846a5471bf257d37e6154 +Subproject commit 4a5f43ff6b5ae09ea33851b2928fbb0bb69a21fa diff --git a/osivalidator/osi_general_validator.py b/osivalidator/osi_general_validator.py index 3238a1f..133527d 100755 --- a/osivalidator/osi_general_validator.py +++ b/osivalidator/osi_general_validator.py @@ -54,7 +54,18 @@ def command_line_arguments(): "--type", "-t", help="Name of the type used to serialize data. Default is SensorView.", - choices=["SensorView", "GroundTruth", "SensorData"], + choices=[ + "SensorView", + "SensorViewConfiguration", + "GroundTruth", + "HostVehicleData", + "SensorData", + "TrafficUpdate", + "TrafficCommandUpdate", + "TrafficCommand", + "MotionRequest", + "StreamingUpdate", + ], type=str, required=False, ) @@ -136,8 +147,22 @@ 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: + return "TrafficUpdate" + if filename.find("_tcu_") != -1: + 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/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 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: diff --git a/tests/test_osi_general_validator.py b/tests/test_osi_general_validator.py new file mode 100644 index 0000000..704cacf --- /dev/null +++ b/tests/test_osi_general_validator.py @@ -0,0 +1,68 @@ +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()