Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
f5ea3546
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f5ea3546
编写于
9月 24, 2018
作者:
J
jmtao
提交者:
Jiangtao Hu
9月 24, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perception: add tests for camera/image
上级
77369e9e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
446 deletion
+25
-446
modules/perception/base/BUILD
modules/perception/base/BUILD
+25
-27
modules/perception/base/camera_test.cc
modules/perception/base/camera_test.cc
+0
-0
modules/perception/base/image_test.cc
modules/perception/base/image_test.cc
+0
-0
modules/perception/base/test/base_point_cloud_test.cc
modules/perception/base/test/base_point_cloud_test.cc
+0
-419
未找到文件。
modules/perception/base/BUILD
浏览文件 @
f5ea3546
...
...
@@ -31,34 +31,35 @@ cc_test(
)
cc_library
(
name
=
"
common
"
,
name
=
"
box
"
,
hdrs
=
[
"common.h"
,
"box.h"
,
"comparison_traits.h"
,
],
deps
=
[
":point_cloud"
,
],
)
cc_test
(
name
=
"
common
_test"
,
name
=
"
box
_test"
,
size
=
"small"
,
srcs
=
[
"
common
_test.cc"
,
"
box
_test.cc"
,
],
deps
=
[
":common"
,
"//modules/perception/base/test:test_helper"
,
"@cuda"
,
":box"
,
"@gtest//:main"
,
],
)
cc_library
(
name
=
"point_cloud"
,
name
=
"camera"
,
srcs
=
[
"camera.cc"
,
],
hdrs
=
[
"point.h"
,
"point_cloud.h"
,
"point_cloud_types.h"
,
"camera.h"
,
],
deps
=
[
"@eigen"
,
...
...
@@ -66,27 +67,23 @@ cc_library(
)
cc_test
(
name
=
"
point_cloud
_test"
,
name
=
"
camera
_test"
,
size
=
"small"
,
srcs
=
[
"
point_cloud
_test.cc"
,
"
camera
_test.cc"
,
],
deps
=
[
":camera"
,
"@gtest//:main"
,
":point_cloud"
,
],
)
cc_library
(
name
=
"camera"
,
srcs
=
[
"camera.cc"
,
],
name
=
"common"
,
hdrs
=
[
"c
amera
.h"
,
"c
ommon
.h"
,
],
deps
=
[
"@eigen"
,
],
)
...
...
@@ -120,25 +117,26 @@ cc_test(
)
cc_library
(
name
=
"
box
"
,
name
=
"
point_cloud
"
,
hdrs
=
[
"box.h"
,
"comparison_traits.h"
,
"point.h"
,
"point_cloud.h"
,
"point_cloud_types.h"
,
],
deps
=
[
"
:point_cloud
"
,
"
@eigen
"
,
],
)
cc_test
(
name
=
"
box
_test"
,
name
=
"
point_cloud
_test"
,
size
=
"small"
,
srcs
=
[
"
box
_test.cc"
,
"
point_cloud
_test.cc"
,
],
deps
=
[
":box"
,
"@gtest//:main"
,
":point_cloud"
,
],
)
...
...
modules/perception/base/
test/base_
camera_test.cc
→
modules/perception/base/camera_test.cc
浏览文件 @
f5ea3546
文件已移动
modules/perception/base/
test/base_
image_test.cc
→
modules/perception/base/image_test.cc
浏览文件 @
f5ea3546
文件已移动
modules/perception/base/test/base_point_cloud_test.cc
已删除
100644 → 0
浏览文件 @
77369e9e
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include <gtest/gtest.h>
#include <limits>
#include "modules/perception/base/point_cloud_types.h"
namespace
apollo
{
namespace
perception
{
namespace
base
{
TEST
(
PointTest
,
point_test
)
{
{
PointXYZIF
point
;
EXPECT_EQ
(
point
.
x
,
0.
f
);
EXPECT_EQ
(
point
.
y
,
0.
f
);
EXPECT_EQ
(
point
.
z
,
0.
f
);
EXPECT_EQ
(
point
.
intensity
,
0.
f
);
}
{
PointXYZID
point
;
EXPECT_EQ
(
point
.
x
,
0.0
);
EXPECT_EQ
(
point
.
y
,
0.0
);
EXPECT_EQ
(
point
.
z
,
0.0
);
EXPECT_EQ
(
point
.
intensity
,
0.0
);
}
{
PointXYZITF
point
;
EXPECT_EQ
(
point
.
x
,
0.
f
);
EXPECT_EQ
(
point
.
timestamp
,
0.0
);
}
{
PointXYZITD
point
;
EXPECT_EQ
(
point
.
x
,
0.0
);
EXPECT_EQ
(
point
.
timestamp
,
0.0
);
}
{
PointXYZITHF
point
;
EXPECT_EQ
(
point
.
x
,
0.
f
);
EXPECT_EQ
(
point
.
timestamp
,
0.0
);
EXPECT_EQ
(
point
.
height
,
FLT_MAX
);
}
{
PointXYZITHD
point
;
EXPECT_EQ
(
point
.
x
,
0.0
);
EXPECT_EQ
(
point
.
timestamp
,
0.0
);
EXPECT_EQ
(
point
.
height
,
FLT_MAX
);
}
{
PointXYZITHBF
point
;
EXPECT_EQ
(
point
.
x
,
0.
f
);
EXPECT_EQ
(
point
.
timestamp
,
0.0
);
EXPECT_EQ
(
point
.
height
,
FLT_MAX
);
EXPECT_EQ
(
point
.
beam_id
,
-
1
);
}
{
PointXYZITHBD
point
;
EXPECT_EQ
(
point
.
x
,
0.0
);
EXPECT_EQ
(
point
.
timestamp
,
0.0
);
EXPECT_EQ
(
point
.
height
,
FLT_MAX
);
EXPECT_EQ
(
point
.
beam_id
,
-
1
);
}
{
PointXYZITHBLF
point
;
EXPECT_EQ
(
point
.
x
,
0.
f
);
EXPECT_EQ
(
point
.
timestamp
,
0.0
);
EXPECT_EQ
(
point
.
height
,
FLT_MAX
);
EXPECT_EQ
(
point
.
beam_id
,
-
1
);
EXPECT_EQ
(
point
.
label
,
0
);
}
{
PointXYZITHBLD
point
;
EXPECT_EQ
(
point
.
x
,
0.0
);
EXPECT_EQ
(
point
.
timestamp
,
0.0
);
EXPECT_EQ
(
point
.
height
,
FLT_MAX
);
EXPECT_EQ
(
point
.
beam_id
,
-
1
);
EXPECT_EQ
(
point
.
label
,
0
);
}
}
TEST
(
PointIndicesTest
,
point_test
)
{
PointIndices
indices
;
EXPECT_EQ
(
indices
.
indices
.
capacity
(),
kDefaultReservePointNum
);
}
TEST
(
PointCloudTest
,
point_cloud_constructor_test
)
{
{
typedef
PointCloud
<
PointF
>
TestPointCloud
;
TestPointCloud
cloud1
;
EXPECT_EQ
(
cloud1
.
width_
,
0
);
EXPECT_EQ
(
cloud1
.
height_
,
0
);
EXPECT_EQ
(
cloud1
.
size
(),
0
);
EXPECT_TRUE
(
cloud1
.
empty
());
TestPointCloud
cloud2
(
cloud1
);
EXPECT_EQ
(
cloud2
.
width_
,
0
);
EXPECT_EQ
(
cloud2
.
height_
,
0
);
EXPECT_EQ
(
cloud2
.
size
(),
0
);
cloud2
.
resize
(
10
);
EXPECT_EQ
(
cloud2
.
width_
,
10
);
EXPECT_EQ
(
cloud2
.
height_
,
1
);
EXPECT_EQ
(
cloud2
.
size
(),
10
);
PointIndices
indices
;
indices
.
indices
=
{
0
,
3
,
5
};
EXPECT_EQ
(
indices
.
indices
.
size
(),
3
);
TestPointCloud
cloud3
(
cloud2
,
indices
);
EXPECT_EQ
(
cloud3
.
width
(),
3
);
EXPECT_EQ
(
cloud3
.
height
(),
1
);
TestPointCloud
cloud4
(
cloud2
,
indices
.
indices
);
EXPECT_EQ
(
cloud4
.
width
(),
3
);
EXPECT_EQ
(
cloud4
.
height
(),
1
);
TestPointCloud
cloud5
(
6
,
7
);
EXPECT_TRUE
(
cloud5
.
IsOrganized
());
EXPECT_EQ
(
cloud5
.
width
(),
6
);
EXPECT_EQ
(
cloud5
.
height
(),
7
);
cloud5
+=
cloud4
;
EXPECT_EQ
(
cloud5
.
width
(),
45
);
EXPECT_EQ
(
cloud5
.
height
(),
1
);
}
{
typedef
AttributePointCloud
<
PointF
>
TestPointCloud
;
TestPointCloud
cloud1
;
EXPECT_EQ
(
cloud1
.
width_
,
0
);
EXPECT_EQ
(
cloud1
.
height_
,
0
);
EXPECT_EQ
(
cloud1
.
size
(),
0
);
EXPECT_TRUE
(
cloud1
.
empty
());
TestPointCloud
cloud2
(
cloud1
);
EXPECT_EQ
(
cloud2
.
width_
,
0
);
EXPECT_EQ
(
cloud2
.
height_
,
0
);
EXPECT_EQ
(
cloud2
.
size
(),
0
);
cloud2
.
resize
(
10
);
EXPECT_EQ
(
cloud2
.
width_
,
10
);
EXPECT_EQ
(
cloud2
.
height_
,
1
);
EXPECT_EQ
(
cloud2
.
size
(),
10
);
PointIndices
indices
;
indices
.
indices
=
{
0
,
3
,
5
};
EXPECT_EQ
(
indices
.
indices
.
size
(),
3
);
TestPointCloud
cloud3
(
cloud2
,
indices
);
EXPECT_EQ
(
cloud3
.
width
(),
3
);
EXPECT_EQ
(
cloud3
.
height
(),
1
);
TestPointCloud
cloud4
(
cloud2
,
indices
.
indices
);
EXPECT_EQ
(
cloud4
.
width
(),
3
);
EXPECT_EQ
(
cloud4
.
height
(),
1
);
TestPointCloud
cloud5
(
6
,
7
);
EXPECT_TRUE
(
cloud5
.
IsOrganized
());
EXPECT_EQ
(
cloud5
.
width
(),
6
);
EXPECT_EQ
(
cloud5
.
height
(),
7
);
cloud5
+=
cloud4
;
EXPECT_EQ
(
cloud5
.
width
(),
45
);
EXPECT_EQ
(
cloud5
.
height
(),
1
);
}
}
TEST
(
PointCloudTest
,
point_cloud_interface_test
)
{
typedef
PointCloud
<
PointF
>
TestPointCloud
;
TestPointCloud
cloud
;
cloud
.
reserve
(
2
);
cloud
.
resize
(
2
);
EXPECT_FALSE
(
cloud
.
IsOrganized
());
TestPointCloud
organized_cloud
(
2
,
2
);
organized_cloud
.
resize
(
4
);
EXPECT_TRUE
(
organized_cloud
.
IsOrganized
());
auto
const_check_null
=
[](
const
TestPointCloud
&
cloud
)
{
EXPECT_EQ
(
cloud
.
at
(
0
,
0
),
nullptr
);
EXPECT_EQ
(
cloud
(
0
,
0
),
nullptr
);
};
auto
const_check_not_null
=
[](
const
TestPointCloud
&
cloud
)
{
EXPECT_NE
(
cloud
.
at
(
0
,
0
),
nullptr
);
EXPECT_NE
(
cloud
(
0
,
0
),
nullptr
);
};
EXPECT_NE
(
organized_cloud
.
at
(
0
,
0
),
nullptr
);
EXPECT_NE
(
organized_cloud
(
0
,
0
),
nullptr
);
const_check_not_null
(
organized_cloud
);
cloud
.
push_back
(
PointF
());
EXPECT_EQ
(
cloud
.
at
(
0
,
0
),
nullptr
);
EXPECT_EQ
(
cloud
(
0
,
0
),
nullptr
);
const_check_null
(
cloud
);
EXPECT_EQ
(
cloud
.
size
(),
3
);
auto
const_check_eq
=
[](
const
TestPointCloud
&
cloud
)
{
EXPECT_EQ
(
&
(
cloud
[
0
]),
&
(
cloud
.
front
()));
EXPECT_EQ
(
&
(
cloud
[
2
]),
&
(
cloud
.
back
()));
};
EXPECT_EQ
(
&
(
cloud
[
0
]),
&
(
cloud
.
front
()));
EXPECT_EQ
(
&
(
cloud
[
2
]),
&
(
cloud
.
back
()));
const_check_eq
(
cloud
);
for
(
TestPointCloud
::
iterator
it
=
cloud
.
begin
();
it
!=
cloud
.
end
();
++
it
)
{
EXPECT_EQ
(
it
->
x
,
0.
f
);
}
for
(
TestPointCloud
::
const_iterator
it
=
cloud
.
begin
();
it
!=
cloud
.
end
();
++
it
)
{
EXPECT_EQ
(
it
->
x
,
0.
f
);
}
cloud
.
clear
();
EXPECT_EQ
(
cloud
.
size
(),
0
);
cloud
.
resize
(
1
);
EXPECT_FALSE
(
cloud
.
SwapPoint
(
0
,
3
));
EXPECT_FALSE
(
cloud
.
SwapPoint
(
3
,
0
));
cloud
.
resize
(
2
);
cloud
[
0
].
x
=
1.
f
;
cloud
[
1
].
x
=
2.
f
;
EXPECT_TRUE
(
cloud
.
SwapPoint
(
0
,
1
));
EXPECT_EQ
(
cloud
[
0
].
x
,
2.
f
);
EXPECT_EQ
(
cloud
[
1
].
x
,
1.
f
);
TestPointCloud
cloud2
;
cloud2
.
resize
(
1
);
cloud2
[
0
].
x
=
10.
f
;
EXPECT_FALSE
(
cloud
.
CopyPoint
(
0
,
10
,
cloud2
));
EXPECT_TRUE
(
cloud
.
CopyPoint
(
0
,
0
,
cloud2
));
EXPECT_EQ
(
cloud
[
0
].
x
,
10.
f
);
cloud
.
resize
(
1
);
cloud
.
set_timestamp
(
10.0
);
Eigen
::
Affine3d
pose
=
Eigen
::
Affine3d
::
Identity
();
pose
.
translate
(
Eigen
::
Vector3d
(
20.0
,
0
,
0
));
cloud
.
set_sensor2world_pose
(
pose
);
cloud2
.
clear
();
cloud2
.
SwapPointCloud
(
&
cloud
);
EXPECT_EQ
(
cloud2
.
size
(),
1
);
EXPECT_NEAR
(
cloud2
.
get_timestamp
(),
10.0
,
1e-9
);
EXPECT_NEAR
(
cloud2
.
get_sensor2world_pose
().
translation
()(
0
),
20.0
,
1e-9
);
}
TEST
(
PointCloudTest
,
attribute_point_cloud_interface_test
)
{
typedef
AttributePointCloud
<
PointF
>
TestPointCloud
;
TestPointCloud
cloud
;
cloud
.
reserve
(
2
);
cloud
.
resize
(
2
);
cloud
.
push_back
(
PointF
());
cloud
.
push_back
(
PointF
(),
1.0
,
0.5
f
,
1
,
2
);
auto
const_check_eq
=
[](
const
TestPointCloud
&
cloud
)
{
EXPECT_EQ
(
cloud
.
points_timestamp
(
3
),
1.0
);
EXPECT_EQ
(
cloud
.
points_height
(
3
),
0.5
f
);
EXPECT_EQ
(
cloud
.
points_beam_id
(
3
),
1
);
EXPECT_EQ
(
cloud
.
points_timestamp
(
0
,
0
),
nullptr
);
EXPECT_EQ
(
cloud
.
points_height
(
0
,
0
),
nullptr
);
EXPECT_EQ
(
cloud
.
points_beam_id
(
0
,
0
),
nullptr
);
EXPECT_EQ
(
cloud
.
points_label
(
0
,
0
),
nullptr
);
};
EXPECT_EQ
(
cloud
.
points_timestamp
(
3
),
1.0
);
EXPECT_EQ
(
cloud
.
points_height
(
3
),
0.5
f
);
EXPECT_EQ
(
cloud
.
points_beam_id
(
3
),
1
);
EXPECT_EQ
(
cloud
.
points_label
(
3
),
2
);
const_check_eq
(
cloud
);
TestPointCloud
organized_cloud
(
2
,
2
);
organized_cloud
.
reserve
(
4
);
organized_cloud
.
resize
(
4
);
EXPECT_TRUE
(
organized_cloud
.
IsOrganized
());
organized_cloud
.
points_timestamp
(
3
)
=
1.0
;
organized_cloud
.
points_height
(
3
)
=
0.5
f
;
organized_cloud
.
points_beam_id
(
3
)
=
1
;
organized_cloud
.
points_label
(
3
)
=
2
;
auto
const_check_eq_organized
=
[](
const
TestPointCloud
&
cloud
)
{
EXPECT_EQ
(
cloud
.
points_timestamp
(
3
),
1.0
);
EXPECT_EQ
(
cloud
.
points_height
(
3
),
0.5
f
);
EXPECT_EQ
(
cloud
.
points_beam_id
(
3
),
1
);
EXPECT_EQ
(
cloud
.
points_label
(
3
),
2
);
EXPECT_NE
(
cloud
.
points_timestamp
(
0
,
0
),
nullptr
);
EXPECT_NE
(
cloud
.
points_height
(
0
,
0
),
nullptr
);
EXPECT_NE
(
cloud
.
points_beam_id
(
0
,
0
),
nullptr
);
EXPECT_NE
(
cloud
.
points_label
(
0
,
0
),
nullptr
);
};
EXPECT_EQ
(
organized_cloud
.
points_timestamp
(
3
),
1.0
);
EXPECT_EQ
(
organized_cloud
.
points_height
(
3
),
0.5
f
);
EXPECT_EQ
(
organized_cloud
.
points_beam_id
(
3
),
1
);
EXPECT_EQ
(
organized_cloud
.
points_label
(
3
),
2
);
const_check_eq_organized
(
organized_cloud
);
cloud
.
clear
();
EXPECT_EQ
(
cloud
.
size
(),
0
);
cloud
.
resize
(
1
);
EXPECT_FALSE
(
cloud
.
SwapPoint
(
0
,
3
));
EXPECT_FALSE
(
cloud
.
SwapPoint
(
3
,
0
));
cloud
.
resize
(
2
);
cloud
[
0
].
x
=
1.
f
;
cloud
.
points_timestamp
(
0
)
=
0.0
;
cloud
.
points_height
(
0
)
=
0.
f
;
cloud
.
points_beam_id
(
0
)
=
0
;
cloud
.
points_label
(
0
)
=
0
;
cloud
[
1
].
x
=
2.
f
;
cloud
.
points_timestamp
(
1
)
=
1.0
;
cloud
.
points_height
(
1
)
=
1.
f
;
cloud
.
points_beam_id
(
1
)
=
1
;
cloud
.
points_label
(
1
)
=
1
;
EXPECT_TRUE
(
cloud
.
SwapPoint
(
0
,
1
));
EXPECT_EQ
(
cloud
[
0
].
x
,
2.
f
);
EXPECT_EQ
(
cloud
.
points_timestamp
(
0
),
1.0
);
EXPECT_EQ
(
cloud
.
points_height
(
0
),
1.
f
);
EXPECT_EQ
(
cloud
.
points_beam_id
(
0
),
1
);
EXPECT_EQ
(
cloud
.
points_label
(
0
),
1
);
EXPECT_EQ
(
cloud
[
1
].
x
,
1.
f
);
EXPECT_EQ
(
cloud
.
points_timestamp
(
1
),
0.0
);
EXPECT_EQ
(
cloud
.
points_height
(
1
),
0.
f
);
EXPECT_EQ
(
cloud
.
points_beam_id
(
1
),
0
);
EXPECT_EQ
(
cloud
.
points_label
(
1
),
0
);
TestPointCloud
cloud2
;
cloud2
.
resize
(
1
);
cloud2
[
0
].
x
=
10.
f
;
cloud2
.
points_timestamp
(
0
)
=
10.0
;
cloud2
.
points_height
(
0
)
=
10.
f
;
cloud2
.
points_beam_id
(
0
)
=
10
;
cloud2
.
points_label
(
0
)
=
10
;
EXPECT_FALSE
(
cloud
.
CopyPoint
(
0
,
10
,
cloud2
));
EXPECT_TRUE
(
cloud
.
CopyPoint
(
0
,
0
,
cloud2
));
EXPECT_EQ
(
cloud
[
0
].
x
,
10.
f
);
EXPECT_EQ
(
cloud
.
points_timestamp
(
0
),
10.0
);
EXPECT_EQ
(
cloud
.
points_height
(
0
),
10.
f
);
EXPECT_EQ
(
cloud
.
points_beam_id
(
0
),
10
);
EXPECT_EQ
(
cloud
.
points_label
(
0
),
10
);
cloud
.
resize
(
1
);
cloud
.
set_timestamp
(
10.0
);
Eigen
::
Affine3d
pose
=
Eigen
::
Affine3d
::
Identity
();
pose
.
translate
(
Eigen
::
Vector3d
(
20.0
,
0
,
0
));
cloud
.
set_sensor2world_pose
(
pose
);
cloud
.
points_timestamp
(
1
)
=
2.0
;
cloud
.
points_height
(
1
)
=
3.
f
;
cloud
.
points_beam_id
(
1
)
=
4
;
cloud
.
points_label
(
1
)
=
5
;
cloud2
.
clear
();
cloud2
.
SwapPointCloud
(
&
cloud
);
EXPECT_EQ
(
cloud2
.
size
(),
1
);
EXPECT_NEAR
(
cloud2
.
get_timestamp
(),
10.0
,
1e-9
);
EXPECT_NEAR
(
cloud2
.
get_sensor2world_pose
().
translation
()(
0
),
20.0
,
1e-9
);
EXPECT_NEAR
(
cloud2
.
points_timestamp
(
1
),
2.0
,
1e-9
);
EXPECT_NEAR
(
cloud2
.
points_height
(
1
),
3.
f
,
1e-9
);
EXPECT_EQ
(
cloud2
.
points_beam_id
(
1
),
4
);
EXPECT_EQ
(
cloud2
.
points_label
(
1
),
5
);
}
TEST
(
PointCloudTest
,
transform_test
)
{
Eigen
::
Affine3d
affine
=
Eigen
::
Affine3d
::
Identity
();
affine
.
rotate
(
Eigen
::
AngleAxisd
(
M_PI
/
2
,
Eigen
::
Vector3d
(
1
,
0
,
0
)));
affine
.
translate
(
Eigen
::
Vector3d
(
1
,
1
,
1
));
typedef
AttributePointCloud
<
PointF
>
TestPointCloud
;
TestPointCloud
cloud
(
4
,
4
);
cloud
.
set_timestamp
(
1.0
);
EXPECT_EQ
(
cloud
.
get_timestamp
(),
1.0
);
cloud
.
set_sensor2world_pose
(
affine
);
EXPECT_EQ
((
cloud
.
get_sensor2world_pose
().
matrix
()
-
affine
.
matrix
()).
trace
(),
0.0
);
cloud
.
RotatePointCloud
(
false
);
EXPECT_EQ
(
cloud
.
get_sensor2world_pose
().
linear
().
trace
(),
3.0
);
cloud
.
TransformPointCloud
(
false
);
EXPECT_EQ
(
cloud
.
get_sensor2world_pose
().
translation
().
x
(),
0.0
);
EXPECT_EQ
(
cloud
.
get_sensor2world_pose
().
translation
().
y
(),
0.0
);
EXPECT_EQ
(
cloud
.
get_sensor2world_pose
().
translation
().
z
(),
0.0
);
EXPECT_EQ
(
cloud
.
get_sensor2world_pose
().
matrix
().
determinant
(),
1.0
);
cloud
[
0
].
x
=
std
::
numeric_limits
<
float
>::
quiet_NaN
();
cloud
[
1
].
y
=
std
::
numeric_limits
<
float
>::
quiet_NaN
();
cloud
[
2
].
z
=
std
::
numeric_limits
<
float
>::
quiet_NaN
();
cloud
.
RotatePointCloud
(
true
);
EXPECT_EQ
(
cloud
.
get_sensor2world_pose
().
linear
().
trace
(),
3.0
);
cloud
.
TransformPointCloud
(
true
);
EXPECT_EQ
(
cloud
.
get_sensor2world_pose
().
translation
().
x
(),
0.0
);
EXPECT_EQ
(
cloud
.
get_sensor2world_pose
().
translation
().
y
(),
0.0
);
EXPECT_EQ
(
cloud
.
get_sensor2world_pose
().
translation
().
z
(),
0.0
);
EXPECT_EQ
(
cloud
.
get_sensor2world_pose
().
matrix
().
determinant
(),
1.0
);
}
template
<
typename
PointT
>
void
cloud_check
(
const
std
::
shared_ptr
<
const
PointCloud
<
PointT
>>
cloud
)
{
for
(
auto
&
point
:
*
cloud
)
{
EXPECT_EQ
(
point
.
x
,
0.
f
);
EXPECT_EQ
(
point
.
y
,
0.
f
);
EXPECT_EQ
(
point
.
z
,
0.
f
);
}
}
template
<
typename
PointT
>
void
resize_cloud
(
const
std
::
shared_ptr
<
PointCloud
<
PointT
>>
cloud
)
{
cloud
->
resize
(
cloud
->
size
()
*
2
);
}
TEST
(
PointCloudTest
,
dynamic_binding_test
)
{
std
::
shared_ptr
<
PointCloud
<
PointF
>>
cloud
;
cloud
.
reset
(
new
PointCloud
<
PointF
>
);
cloud
->
resize
(
10
);
cloud_check
<
PointF
>
(
cloud
);
EXPECT_TRUE
(
cloud
->
CheckConsistency
());
std
::
shared_ptr
<
AttributePointCloud
<
PointF
>>
attribute_cloud
;
attribute_cloud
.
reset
(
new
AttributePointCloud
<
PointF
>
);
attribute_cloud
->
resize
(
10
);
cloud_check
<
PointF
>
(
attribute_cloud
);
resize_cloud
<
PointF
>
(
attribute_cloud
);
EXPECT_EQ
(
attribute_cloud
->
size
(),
20
);
EXPECT_TRUE
(
attribute_cloud
->
CheckConsistency
());
}
}
// namespace base
}
// namespace perception
}
// namespace apollo
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录