diff --git a/src/v2i-hub/CDASimAdapter/src/CDASimConnection.cpp b/src/v2i-hub/CDASimAdapter/src/CDASimConnection.cpp index ae9f5f35c..1ef089082 100644 --- a/src/v2i-hub/CDASimAdapter/src/CDASimConnection.cpp +++ b/src/v2i-hub/CDASimAdapter/src/CDASimConnection.cpp @@ -298,7 +298,7 @@ namespace CDASimAdapter{ } sensor["location"] = sensor_configuration[index]["ref"]["location"]; sensor["orientation"] =sensor_configuration[index]["ref"]["orientation"]; - sensors_registration[index] = sensor; + sensors_registration.append(sensor); } /** Sensor Registration JSON Format [ diff --git a/src/v2i-hub/CDASimAdapter/src/include/CDASimConnection.hpp b/src/v2i-hub/CDASimAdapter/src/include/CDASimConnection.hpp index 156151af4..7899af4f7 100644 --- a/src/v2i-hub/CDASimAdapter/src/include/CDASimConnection.hpp +++ b/src/v2i-hub/CDASimAdapter/src/include/CDASimConnection.hpp @@ -180,6 +180,8 @@ namespace CDASimAdapter { FRIEND_TEST(TestCDASimConnection, get_handshake_json_no_sensor_config); FRIEND_TEST(TestCDASimConnection, read_json_file); FRIEND_TEST(TestCDASimConnection, string_to_json); + FRIEND_TEST(TestCDASimConnection, read_sensor_configuration_file); + }; diff --git a/src/v2i-hub/CDASimAdapter/test/TestCDASimConnection.cpp b/src/v2i-hub/CDASimAdapter/test/TestCDASimConnection.cpp index a8accc02f..80a47cc2f 100644 --- a/src/v2i-hub/CDASimAdapter/test/TestCDASimConnection.cpp +++ b/src/v2i-hub/CDASimAdapter/test/TestCDASimConnection.cpp @@ -115,4 +115,12 @@ namespace CDASimAdapter { { EXPECT_THROW(connection->string_to_json("Invalid Json"), std::invalid_argument); } + + TEST_F(TestCDASimConnection, read_sensor_configuration_file) { + auto sensor_registration = connection->read_sensor_configuration_file("../../CDASimAdapter/test/sensors_including_invalid_entries.json"); + EXPECT_EQ(2, sensor_registration.size()); + EXPECT_EQ("SomeID", sensor_registration[0]["sensorId"].asString()); + EXPECT_EQ("SomeID2", sensor_registration[1]["sensorId"].asString()); + + } } \ No newline at end of file diff --git a/src/v2i-hub/CDASimAdapter/test/sensors_including_invalid_entries.json b/src/v2i-hub/CDASimAdapter/test/sensors_including_invalid_entries.json new file mode 100755 index 000000000..edf290686 --- /dev/null +++ b/src/v2i-hub/CDASimAdapter/test/sensors_including_invalid_entries.json @@ -0,0 +1,48 @@ +[ + { + "sensorId": "SomeID", + "type": "SemanticLidar", + "ref": { + "type": "CARTESIAN", + "location": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "orientation": { + "yaw": 0.0, + "pitch": 0.0, + "roll": 0.0 + } + } + }, + { + "sensorId": "sensor_1", + "type": "SemanticLidar", + "ref": { + "type": "WGS84", + "location": { + "latitude": 38.9549716548523, + "longitude": -77.14935313519123, + "altitude": 5.5 + } + } + }, + { + "sensorId": "SomeID2", + "type": "SemanticLidar", + "ref": { + "type": "CARTESIAN", + "location": { + "x": 1.0, + "y": 2.0, + "z": 0.0 + }, + "orientation": { + "yaw": 23.0, + "pitch": 0.0, + "roll": 0.0 + } + } + } +] \ No newline at end of file