Fixes and updates for IO Module
- Modifies obj and mtl files to be compatible with config xml files
- Updates car model config files to use vhal properties
- Adds soc_specific true tag for config files
- Fixes formatting and nits from ag/11800623
Bug: 158480203
Test: atest io_module_tests
Change-Id: I4838419db5ddca68ab808ff3d9387c7ee52428e2
diff --git a/surround_view/service-impl/Android.bp b/surround_view/service-impl/Android.bp
index 97da1bb..f01cd4a 100644
--- a/surround_view/service-impl/Android.bp
+++ b/surround_view/service-impl/Android.bp
@@ -38,8 +38,8 @@
"libutils",
],
required: [
- "cube.obj",
- "cube.mtl",
+ "sample_car.obj",
+ "sample_car_material.mtl",
],
}
@@ -230,47 +230,56 @@
prebuilt_etc{
name : "cam0.png",
+ soc_specific : true,
src : "test_data/0.png",
sub_dir : "automotive/sv",
}
prebuilt_etc{
name : "cam1.png",
+ soc_specific : true,
src : "test_data/1.png",
sub_dir : "automotive/sv",
}
prebuilt_etc{
name : "cam2.png",
+ soc_specific : true,
src : "test_data/2.png",
sub_dir : "automotive/sv",
}
prebuilt_etc {
-name:
- "cam3.png", src : "test_data/3.png", sub_dir : "automotive/sv",
+ name :"cam3.png",
+ soc_specific : true,
+ src : "test_data/3.png",
+ sub_dir : "automotive/sv",
}
prebuilt_etc {
- name: "cube.obj",
- src: "test_data/cube.obj",
+ name : "sample_car.obj",
+ soc_specific : true,
+ src : "test_data/sample_car.obj",
+ sub_dir : "automotive/sv",
+}
+
+prebuilt_etc {
+ name : "sample_car_material.mtl",
+ soc_specific : true,
+ src: "test_data/sample_car_material.mtl",
sub_dir: "automotive/sv",
}
prebuilt_etc {
- name: "cube.mtl",
- src: "test_data/cube.mtl",
- sub_dir: "automotive/sv",
-}
-
-prebuilt_etc {
- name: "sv_sample_config.xml",
- src: "test_data/sv_sample_config.xml",
- sub_dir: "automotive/sv",
+ name : "sv_sample_config.xml",
+ soc_specific : true,
+ src : "test_data/sv_sample_config.xml",
+ sub_dir : "automotive/sv",
}
prebuilt_etc {
name:"sv_sample_car_model_config.xml",
+ soc_specific : true,
src : "test_data/sv_sample_car_model_config.xml",
sub_dir : "automotive/sv",
}
diff --git a/surround_view/service-impl/CarModelConfigReader.cpp b/surround_view/service-impl/CarModelConfigReader.cpp
index 737d84a..5bfb0a6 100644
--- a/surround_view/service-impl/CarModelConfigReader.cpp
+++ b/surround_view/service-impl/CarModelConfigReader.cpp
@@ -279,8 +279,7 @@
const XMLElement* rootElem = xmlDoc.RootElement();
if (strcmp(rootElem->Name(), "SurroundViewCarModelConfig")) {
- LOG(ERROR) << "A configuration file is not in the required format. "
- << "See /etc/automotive/sv/sv_car_model_config.dtd";
+ LOG(ERROR) << "Config file is not in the required format: " << carModelConfigFile;
return IOStatus::ERROR_READ_ANIMATION;
}
diff --git a/surround_view/service-impl/CarModelConfigReaderTests.cpp b/surround_view/service-impl/CarModelConfigReaderTests.cpp
index c3c30d5..916002b 100644
--- a/surround_view/service-impl/CarModelConfigReaderTests.cpp
+++ b/surround_view/service-impl/CarModelConfigReaderTests.cpp
@@ -34,7 +34,7 @@
TEST(CarModelConfigReaderTests, CarModelReadConfigSuccess) {
AnimationConfig animationConfig;
- EXPECT_EQ(ReadCarModelConfig("/etc/automotive/sv/sv_sample_car_model_config.xml",
+ EXPECT_EQ(ReadCarModelConfig("/vendor/automotive/sv/sv_sample_car_model_config.xml",
&animationConfig),
IOStatus::OK);
@@ -43,48 +43,48 @@
ASSERT_EQ(animationConfig.animations.size(), 2);
{
- AnimationInfo frontLeftDoorAnimation = animationConfig.animations.at(0);
- EXPECT_EQ(frontLeftDoorAnimation.partId, "front_left_door");
- EXPECT_EQ(frontLeftDoorAnimation.childIds.size(), 2);
- EXPECT_EQ(frontLeftDoorAnimation.pose, gMat4Identity);
+ AnimationInfo doorAnimation = animationConfig.animations.at(0);
+ EXPECT_EQ(doorAnimation.partId, "door");
+ EXPECT_EQ(doorAnimation.childIds.size(), 2);
+ EXPECT_EQ(doorAnimation.pose, gMat4Identity);
- EXPECT_EQ(frontLeftDoorAnimation.rotationOpsMap.size(), 1);
+ EXPECT_EQ(doorAnimation.rotationOpsMap.size(), 1);
{
- RotationOp frontLeftDoorRotationOp =
- (frontLeftDoorAnimation.rotationOpsMap.at(0x100000002)).at(0);
- EXPECT_EQ(frontLeftDoorRotationOp.vhalProperty, 0x100000002);
- EXPECT_EQ(frontLeftDoorRotationOp.type, AnimationType::ROTATION_ANGLE);
- EXPECT_EQ(frontLeftDoorRotationOp.animationTime, 2000);
- std::array<float, 3> axis = {1, 0, 0};
- EXPECT_EQ(frontLeftDoorRotationOp.axis.axisVector, axis);
- std::array<float, 3> point = {2, 2, 2};
- EXPECT_EQ(frontLeftDoorRotationOp.axis.rotationPoint, point);
- EXPECT_EQ(frontLeftDoorRotationOp.rotationRange.start, 0.0);
- EXPECT_EQ(frontLeftDoorRotationOp.rotationRange.end, 90.0);
- EXPECT_EQ(frontLeftDoorRotationOp.vhalRange.start, 0);
- EXPECT_EQ(frontLeftDoorRotationOp.vhalRange.end, 0xFFFF);
+ RotationOp rotationOp = (doorAnimation.rotationOpsMap.at(0x16000B0000000001)).at(0);
+ EXPECT_EQ(rotationOp.vhalProperty, 0x16000B0000000001);
+ EXPECT_EQ(rotationOp.type, AnimationType::ROTATION_ANGLE);
+ EXPECT_EQ(rotationOp.animationTime, 2000);
+ std::array<float, 3> axis = {0, 0, 1};
+ EXPECT_EQ(rotationOp.axis.axisVector, axis);
+ std::array<float, 3> point = {0, 0, 0};
+ EXPECT_EQ(rotationOp.axis.rotationPoint, point);
+ EXPECT_EQ(rotationOp.rotationRange.start, 0.0);
+ EXPECT_EQ(rotationOp.rotationRange.end, 90.0);
+ EXPECT_EQ(rotationOp.vhalRange.start, 0);
+ EXPECT_EQ(rotationOp.vhalRange.end, 0x7FFFFFFF);
}
}
{
AnimationInfo windowAnimation = animationConfig.animations.at(1);
- EXPECT_EQ(windowAnimation.partId, "front_left_window");
+ EXPECT_EQ(windowAnimation.partId, "window");
EXPECT_EQ(windowAnimation.childIds.size(), 0);
EXPECT_EQ(windowAnimation.pose, gMat4Identity);
EXPECT_EQ(windowAnimation.translationOpsMap.size(), 1);
{
- TranslationOp translationOp = (windowAnimation.translationOpsMap.at(0x200000001)).at(0);
- EXPECT_EQ(translationOp.vhalProperty, 0x200000001);
+ TranslationOp translationOp =
+ (windowAnimation.translationOpsMap.at(0x13000BC000000010)).at(0);
+ EXPECT_EQ(translationOp.vhalProperty, 0x13000BC000000010);
EXPECT_EQ(translationOp.type, AnimationType::TRANSLATION);
EXPECT_EQ(translationOp.animationTime, 2000);
std::array<float, 3> dir = {0.0, 0.0, -1.0};
EXPECT_EQ(translationOp.direction, dir);
EXPECT_EQ(translationOp.defaultTranslationValue, 0.0);
EXPECT_EQ(translationOp.translationRange.start, 0.0);
- EXPECT_EQ(translationOp.translationRange.end, 5.0);
+ EXPECT_EQ(translationOp.translationRange.end, 1.0);
EXPECT_EQ(translationOp.vhalRange.start, 0);
- EXPECT_EQ(translationOp.vhalRange.end, 0xFFFF);
+ EXPECT_EQ(translationOp.vhalRange.end, 0x7FFFFFFF);
}
}
}
diff --git a/surround_view/service-impl/ConfigReader.cpp b/surround_view/service-impl/ConfigReader.cpp
index 919427e..674bf7b 100644
--- a/surround_view/service-impl/ConfigReader.cpp
+++ b/surround_view/service-impl/ConfigReader.cpp
@@ -70,9 +70,6 @@
}
bool ReadSvConfig2d(const XMLElement* parent, SvConfig2d* sv2dConfig) {
- LOG(INFO) << "Seraching elem:"
- << "Sv2dEnabled"
- << "in parent: " << parent->Name();
RETURN_IF_FALSE(ReadValue(parent, "Sv2dEnabled", &sv2dConfig->sv2dEnabled));
if (!sv2dConfig->sv2dEnabled) {
return true;
@@ -234,7 +231,7 @@
IOStatus ReadSurroundViewConfig(const std::string& configFile, SurroundViewConfig* svConfig) {
XMLDocument xmlDoc;
- /* load and parse a configuration file */
+ // load and parse a configuration file
xmlDoc.LoadFile(configFile.c_str());
if (xmlDoc.ErrorID() != XML_SUCCESS) {
LOG(ERROR) << "Failed to load and/or parse a configuration file, " << xmlDoc.ErrorStr();
@@ -243,8 +240,7 @@
const XMLElement* rootElem = xmlDoc.RootElement();
if (strcmp(rootElem->Name(), "SurroundViewConfig")) {
- LOG(ERROR) << "A configuration file is not in the required format. "
- << "See /etc/automotive/sv/sv_config.dtd";
+ LOG(ERROR) << "Config file is not in the required format: " << configFile;
return IOStatus::ERROR_READ_CONFIG_FILE;
}
diff --git a/surround_view/service-impl/ConfigReaderTests.cpp b/surround_view/service-impl/ConfigReaderTests.cpp
index a7042b7..ef51a5f 100644
--- a/surround_view/service-impl/ConfigReaderTests.cpp
+++ b/surround_view/service-impl/ConfigReaderTests.cpp
@@ -36,19 +36,19 @@
TEST(ConfigReaderTests, ReadConfigSuccess) {
SurroundViewConfig svConfig;
- EXPECT_EQ(ReadSurroundViewConfig("/etc/automotive/sv/sv_sample_config.xml", &svConfig),
+ EXPECT_EQ(ReadSurroundViewConfig("/vendor/automotive/sv/sv_sample_config.xml", &svConfig),
IOStatus::OK);
EXPECT_EQ(svConfig.version, "1.0");
// Camera config
- EXPECT_EQ(svConfig.cameraConfig.evsGroupId, "group0");
+ EXPECT_EQ(svConfig.cameraConfig.evsGroupId, "v4l2loopback_group0");
// Camera Ids
- EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[0], "/dev/video0");
- EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[1], "/dev/video1");
- EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[2], "/dev/video2");
- EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[3], "/dev/video3");
+ EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[0], "/dev/video90");
+ EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[1], "/dev/video91");
+ EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[2], "/dev/video92");
+ EXPECT_EQ(svConfig.cameraConfig.evsCameraIds[3], "/dev/video93");
// Masks
EXPECT_EQ(svConfig.cameraConfig.maskFilenames.size(), 4);
diff --git a/surround_view/service-impl/ConfigReaderUtil.h b/surround_view/service-impl/ConfigReaderUtil.h
index d4bd713..030cc0f 100644
--- a/surround_view/service-impl/ConfigReaderUtil.h
+++ b/surround_view/service-impl/ConfigReaderUtil.h
@@ -43,16 +43,16 @@
bool GetElement(const tinyxml2::XMLElement* parent, const char* elementName,
tinyxml2::XMLElement const** element);
-// Reads a boolean value from a element.
+// Reads a boolean value from a element, returns false if not found.
bool ReadValue(const tinyxml2::XMLElement* parent, const char* elementName, bool* value);
-// Reads a string value from a element.
+// Reads a string value from a element, returns false if not found.
bool ReadValue(const tinyxml2::XMLElement* parent, const char* elementName, std::string* value);
-// Reads a float value from a element.
+// Reads a float value from a element, returns false if not found.
bool ReadValue(const tinyxml2::XMLElement* parent, const char* elementName, float* value);
-// Reads a int value from a element.
+// Reads a int value from a element, returns false if not found.
bool ReadValue(const tinyxml2::XMLElement* parent, const char* elementName, int* value);
} // namespace implementation
diff --git a/surround_view/service-impl/IOModuleCommon.h b/surround_view/service-impl/IOModuleCommon.h
index fba878f..5550fd5 100644
--- a/surround_view/service-impl/IOModuleCommon.h
+++ b/surround_view/service-impl/IOModuleCommon.h
@@ -29,7 +29,7 @@
namespace implementation {
// Struct for camera related configurations.
-// Note: Does not camera intrinsics and extrinsics, these are specified in EVS metadata.
+// Note: Does not include camera intrinsics and extrinsics, these are specified in EVS metadata.
struct CameraConfig {
// Id of logical group containing surronnd view cameras.
std::string evsGroupId;
diff --git a/surround_view/service-impl/test_data/cube.mtl b/surround_view/service-impl/test_data/cube.mtl
deleted file mode 100644
index 2f4e865..0000000
--- a/surround_view/service-impl/test_data/cube.mtl
+++ /dev/null
@@ -1,5 +0,0 @@
-newmtl flatwhite
-d 1.0000
-illum 1
-Ka 0.5000 0.5000 0.5000
-Kd 1.0000 1.0000 1.0000
diff --git a/surround_view/service-impl/test_data/cube.obj b/surround_view/service-impl/test_data/cube.obj
deleted file mode 100644
index 60ae1b2..0000000
--- a/surround_view/service-impl/test_data/cube.obj
+++ /dev/null
@@ -1,32 +0,0 @@
-mtllib cube.mtl
-g cube
-
-v 0.0 0.0 0.0
-v 0.0 0.0 1.0
-v 0.0 1.0 0.0
-v 0.0 1.0 1.0
-v 1.0 0.0 0.0
-v 1.0 0.0 1.0
-v 1.0 1.0 0.0
-v 1.0 1.0 1.0
-
-vn 0.0 0.0 1.0
-vn 0.0 0.0 -1.0
-vn 0.0 1.0 0.0
-vn 0.0 -1.0 0.0
-vn 1.0 0.0 0.0
-vn -1.0 0.0 0.0
-usemtl flatwhite
-f 1//2 7//2 5//2
-f 1//2 3//2 7//2
-f 1//6 4//6 3//6
-f 1//6 2//6 4//6
-f 3//3 8//3 7//3
-f 3//3 4//3 8//3
-f 5//5 7//5 8//5
-f 5//5 8//5 6//5
-f 1//4 5//4 6//4
-f 1//4 6//4 2//4
-f 2//1 6//1 8//1
-f 2//1 8//1 4//1
-
diff --git a/surround_view/service-impl/test_data/sample_car.obj b/surround_view/service-impl/test_data/sample_car.obj
new file mode 100644
index 0000000..3600a7b
--- /dev/null
+++ b/surround_view/service-impl/test_data/sample_car.obj
@@ -0,0 +1,64 @@
+# Sample Car Model Obj files
+# Consist of cubes representing a car part
+
+mtllib sample_car_material.mtl
+
+# Car Door Object
+v 0.0 0.0 0.0
+v 0.0 0.0 1.0
+v 0.0 1.0 0.0
+v 0.0 1.0 1.0
+v 1.0 0.0 0.0
+v 1.0 0.0 1.0
+v 1.0 1.0 0.0
+v 1.0 1.0 1.0
+vn 0.0 0.0 1.0
+vn 0.0 0.0 -1.0
+vn 0.0 1.0 0.0
+vn 0.0 -1.0 0.0
+vn 1.0 0.0 0.0
+vn -1.0 0.0 0.0
+g door
+usemtl door
+f 1//2 7//2 5//2
+f 1//2 3//2 7//2
+f 1//6 4//6 3//6
+f 1//6 2//6 4//6
+f 3//3 8//3 7//3
+f 3//3 4//3 8//3
+f 5//5 7//5 8//5
+f 5//5 8//5 6//5
+f 1//4 5//4 6//4
+f 1//4 6//4 2//4
+f 2//1 6//1 8//1
+f 2//1 8//1 4//1
+
+# Car Window Object
+v 0.0 0.0 0.0
+v 0.0 0.0 -1.0
+v 0.0 -1.0 0.0
+v 0.0 -1.0 1.0
+v -1.0 0.0 0.0
+v -1.0 0.0 -1.0
+v -1.0 -1.0 0.0
+v -1.0 -1.0 -1.0
+vn 0.0 0.0 1.0
+vn 0.0 0.0 -1.0
+vn 0.0 1.0 0.0
+vn 0.0 -1.0 0.0
+vn 1.0 0.0 0.0
+vn -1.0 0.0 0.0
+g window
+usemtl window
+f 1//2 7//2 5//2
+f 1//2 3//2 7//2
+f 1//6 4//6 3//6
+f 1//6 2//6 4//6
+f 3//3 8//3 7//3
+f 3//3 4//3 8//3
+f 5//5 7//5 8//5
+f 5//5 8//5 6//5
+f 1//4 5//4 6//4
+f 1//4 6//4 2//4
+f 2//1 6//1 8//1
+f 2//1 8//1 4//1
diff --git a/surround_view/service-impl/test_data/sample_car_material.mtl b/surround_view/service-impl/test_data/sample_car_material.mtl
new file mode 100644
index 0000000..346d5bd
--- /dev/null
+++ b/surround_view/service-impl/test_data/sample_car_material.mtl
@@ -0,0 +1,14 @@
+# Sample material file for car model.
+# referenced by sample_car.obj
+
+newmtl door
+ d 1.0000
+ illum 1
+ Ka 0.5000 0.5000 0.5000
+ Kd 1.0000 1.0000 1.0000
+
+newmtl window
+ d 1.0000
+ illum 1
+ Ka 0.5000 0.5000 0.5000
+ Kd 1.0000 0.0000 0.0000
diff --git a/surround_view/service-impl/test_data/sv_sample_car_model_config.xml b/surround_view/service-impl/test_data/sv_sample_car_model_config.xml
index 9bc0118..60541a8 100644
--- a/surround_view/service-impl/test_data/sv_sample_car_model_config.xml
+++ b/surround_view/service-impl/test_data/sv_sample_car_model_config.xml
@@ -2,30 +2,31 @@
<SurroundViewCarModelConfig>
<Version>1.0</Version>
- <!-- Rotation animation for front left door -->
+ <!-- Rotation animation for door -->
<Animation>
- <PartId>front_left_door</PartId>
+ <PartId>door</PartId>
<ChildParts>
- <PartId>left_mirror</PartId>
- <PartId>front_left_window</PartId>
+ <PartId>window</PartId>
</ChildParts>
<ParentPartId>car_frame</ParentPartId>
<RotationOp>
<VhalProperty>
- <PropertyId>0x0001</PropertyId>
- <AreaId>0x0002</AreaId>
+ <!-- Uses VHAL Property DOOR_POS -->
+ <PropertyId>0x16000B00</PropertyId>
+ <!-- AreadId = VehicleAreaDoor::ROW_1_LEFT -->
+ <AreaId>0x00000001</AreaId>
</VhalProperty>
<AnimationType>RotationAngle</AnimationType>
<AnimationTimeMs>2000</AnimationTimeMs>
<RotationAxis>
- <X>1.0</X>
+ <X>0.0</X>
<Y>0.0</Y>
- <Z>0.0</Z>
+ <Z>1.0</Z>
</RotationAxis>
<RotationPoint>
- <X>2.0</X>
- <Y>2.0</Y>
- <Z>2.0</Z>
+ <X>0.0</X>
+ <Y>0.0</Y>
+ <Z>0.0</Z>
</RotationPoint>
<DefaultRotationValue>0.0</DefaultRotationValue>
<RotationRange>
@@ -33,22 +34,26 @@
<End>90</End>
</RotationRange>
<VhalRange>
- <Start>0</Start>
- <End>0xFFFF</End>
+ <!-- 0 => door closed -->
+ <Start>0x00000000</Start>
+ <!-- INT32_MAX => door fully open -->
+ <End>0x7FFFFFFF</End>
</VhalRange>
</RotationOp>
</Animation>
- <!-- Translation animation for front left window -->
+ <!-- Translation animation for window -->
<Animation>
- <PartId>front_left_window</PartId>
- <ParentPartId>front_left_door</ParentPartId>
+ <PartId>window</PartId>
+ <ParentPartId>window</ParentPartId>
<ChildParts>
</ChildParts>
<TranslationOp>
<VhalProperty>
- <PropertyId>0x0002</PropertyId>
- <AreaId>0x0001</AreaId>
+ <!-- Uses VHAL Property WINDOW_POS -->
+ <PropertyId>0x13000BC0</PropertyId>
+ <!-- AreaId = VehicleAreaWindow::ROW_1_LEFT -->
+ <AreaId>0x00000010</AreaId>
</VhalProperty>
<AnimationType>Translation</AnimationType>
<AnimationTimeMs>2000</AnimationTimeMs>
@@ -60,11 +65,13 @@
<DefaultTranslationValue>0.0</DefaultTranslationValue>
<TranslationRange>
<Start>0.0</Start>
- <End>5</End>
+ <End>1.0</End>
</TranslationRange>
<VhalRange>
- <Start>0</Start>
- <End>0xFFFF</End>
+ <!-- 0 => window up/closed -->
+ <Start>0x00000000</Start>
+ <!-- INT32_MAX => window down/open -->
+ <End>0x7FFFFFFF</End>
</VhalRange>
</TranslationOp>
</Animation>
diff --git a/surround_view/service-impl/test_data/sv_sample_config.xml b/surround_view/service-impl/test_data/sv_sample_config.xml
index b831849..484e2fd 100644
--- a/surround_view/service-impl/test_data/sv_sample_config.xml
+++ b/surround_view/service-impl/test_data/sv_sample_config.xml
@@ -3,12 +3,12 @@
<Version>1.0</Version>
<CameraConfig>
- <EvsGroupId>group0</EvsGroupId>
+ <EvsGroupId>v4l2loopback_group0</EvsGroupId>
<EvsCameraIds>
- <Front>/dev/video0</Front>
- <Right>/dev/video1</Right>
- <Rear>/dev/video2</Rear>
- <Left>/dev/video3</Left>
+ <Front>/dev/video90</Front>
+ <Right>/dev/video91</Right>
+ <Rear>/dev/video92</Rear>
+ <Left>/dev/video93</Left>
</EvsCameraIds>
<Masks>
<Front>/vendor/mask_front.png</Front>
@@ -48,8 +48,8 @@
<Sv3dEnabled>true</Sv3dEnabled>
<Sv3dAnimationsEnabled>true</Sv3dAnimationsEnabled>
- <CarModelConfigFile>/vendor/car_model_config.xml</CarModelConfigFile>
- <CarModelObjFile>/vendor/car.obj</CarModelObjFile>
+ <CarModelConfigFile>/etc/automotive/sv/sv_sample_car_model_config.xml</CarModelConfigFile>
+ <CarModelObjFile>/etc/automotive/sv/sample_car.obj</CarModelObjFile>
<Sv3dParams>
<OutputResolution>
<Width>1920</Width>