Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
827ca120
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,发现更多精彩内容 >>
提交
827ca120
编写于
9月 25, 2018
作者:
J
jmtao
提交者:
Jiangtao Hu
9月 25, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perception: enable test for lib/config_manager
上级
c7778a23
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
45 deletion
+34
-45
modules/perception/common/sensor_manager/sensor_manager.cc
modules/perception/common/sensor_manager/sensor_manager.cc
+1
-2
modules/perception/lib/config_manager/BUILD
modules/perception/lib/config_manager/BUILD
+11
-11
modules/perception/lib/config_manager/config_manager.cc
modules/perception/lib/config_manager/config_manager.cc
+13
-20
modules/perception/lib/config_manager/config_manager_test.cc
modules/perception/lib/config_manager/config_manager_test.cc
+9
-12
未找到文件。
modules/perception/common/sensor_manager/sensor_manager.cc
浏览文件 @
827ca120
...
...
@@ -22,10 +22,9 @@
#include "cybertron/common/log.h"
//#include "modules/perception/common/io/io_util.h"
//
#include "modules/perception/common/io/io_util.h"
#include "modules/perception/lib/config_manager/config_manager.h"
#include "modules/perception/lib/io/file_util.h"
//#include "modules/perception/lib/thread/mutex.h"
#include "modules/perception/proto/sensor_meta_schema.pb.h"
namespace
apollo
{
...
...
modules/perception/lib/config_manager/BUILD
浏览文件 @
827ca120
...
...
@@ -20,15 +20,15 @@ cc_library(
],
)
#
cc_test(
#
name = "config_manager_test",
#
size = "small",
#
srcs = [
#
"config_manager_test.cc",
#
],
#
deps = [
#
":config_manager",
#
"@gtest//:main",
#
],
#
)
cc_test
(
name
=
"config_manager_test"
,
size
=
"small"
,
srcs
=
[
"config_manager_test.cc"
,
],
deps
=
[
":config_manager"
,
"@gtest//:main"
,
],
)
cpplint
()
modules/perception/lib/config_manager/config_manager.cc
浏览文件 @
827ca120
...
...
@@ -16,10 +16,9 @@
#include "modules/perception/lib/config_manager/config_manager.h"
#include <utility>
#include "cybertron/common/log.h"
#include "google/protobuf/text_format.h"
#include "cybertron/common/log.h"
#include "modules/perception/common/perception_gflags.h"
#include "modules/perception/lib/io/file_util.h"
...
...
@@ -28,12 +27,6 @@ namespace perception {
namespace
lib
{
using
google
::
protobuf
::
TextFormat
;
using
std
::
map
;
using
std
::
move
;
using
std
::
pair
;
using
std
::
string
;
using
std
::
stringstream
;
using
std
::
vector
;
ConfigManager
::
ConfigManager
()
{
work_root_
=
FLAGS_work_root
;
...
...
@@ -64,7 +57,7 @@ bool ConfigManager::InitInternal() {
}
model_config_map_
.
clear
();
string
config_module_path
=
st
d
::
st
ring
config_module_path
=
FileUtil
::
GetAbsolutePath
(
work_root_
,
FLAGS_config_manager_path
);
AINFO
<<
"WORK_ROOT: "
<<
work_root_
<<
" config_root_path: "
<<
config_module_path
...
...
@@ -94,11 +87,11 @@ bool ConfigManager::InitInternal() {
return
false
;
}
for
(
const
string
&
model_config_file
:
for
(
const
st
d
::
st
ring
&
model_config_file
:
file_list_proto
.
model_config_path
())
{
string
abs_path
=
st
d
::
st
ring
abs_path
=
FileUtil
::
GetAbsolutePath
(
work_root_
,
model_config_file
);
string
config_content
;
st
d
::
st
ring
config_content
;
if
(
!
FileUtil
::
GetFileContent
(
abs_path
,
&
config_content
))
{
AERROR
<<
"failed to get file content: "
<<
abs_path
;
return
false
;
...
...
@@ -121,7 +114,7 @@ bool ConfigManager::InitInternal() {
AINFO
<<
"load ModelConfig succ. name: "
<<
model_config
->
name
();
pair
<
std
::
map
<
std
::
string
,
ModelConfig
*>::
iterator
,
bool
>
result
=
std
::
pair
<
std
::
map
<
std
::
string
,
ModelConfig
*>::
iterator
,
bool
>
result
=
model_config_map_
.
emplace
(
model_config
->
name
(),
model_config
);
if
(
!
result
.
second
)
{
AWARN
<<
"duplicate ModelConfig, name: "
<<
model_config
->
name
();
...
...
@@ -154,7 +147,7 @@ std::string ConfigManager::get_env(const std::string &var_name) {
return
std
::
string
(
var
);
}
bool
ConfigManager
::
GetModelConfig
(
const
string
&
model_name
,
bool
ConfigManager
::
GetModelConfig
(
const
st
d
::
st
ring
&
model_name
,
const
ModelConfig
**
model_config
)
{
if
(
!
inited_
&&
!
Init
())
{
return
false
;
...
...
@@ -214,34 +207,34 @@ bool ModelConfig::Reset(const ModelConfigProto &proto) {
}
for
(
const
KeyValueArrayInt
&
pair
:
proto
.
array_integer_params
())
{
vector
<
int
>
values
;
std
::
vector
<
int
>
values
;
RepeatedToVector
(
pair
.
values
(),
&
values
);
array_integer_param_map_
.
emplace
(
pair
.
name
(),
values
);
}
for
(
const
KeyValueArrayString
&
pair
:
proto
.
array_string_params
())
{
vector
<
string
>
values
;
std
::
vector
<
std
::
string
>
values
;
values
.
reserve
(
pair
.
values_size
());
for
(
const
string
&
value
:
pair
.
values
())
{
for
(
const
st
d
::
st
ring
&
value
:
pair
.
values
())
{
values
.
push_back
(
value
);
}
array_string_param_map_
.
emplace
(
pair
.
name
(),
values
);
}
for
(
const
KeyValueArrayDouble
&
pair
:
proto
.
array_double_params
())
{
vector
<
double
>
values
;
std
::
vector
<
double
>
values
;
RepeatedToVector
(
pair
.
values
(),
&
values
);
array_double_param_map_
.
emplace
(
pair
.
name
(),
values
);
}
for
(
const
KeyValueArrayFloat
&
pair
:
proto
.
array_float_params
())
{
vector
<
float
>
values
;
std
::
vector
<
float
>
values
;
RepeatedToVector
(
pair
.
values
(),
&
values
);
array_float_param_map_
.
emplace
(
pair
.
name
(),
values
);
}
for
(
const
KeyValueArrayBool
&
pair
:
proto
.
array_bool_params
())
{
vector
<
bool
>
values
;
std
::
vector
<
bool
>
values
;
RepeatedToVector
(
pair
.
values
(),
&
values
);
array_bool_param_map_
.
emplace
(
pair
.
name
(),
values
);
}
...
...
modules/perception/lib/config_manager/config_manager_test.cc
浏览文件 @
827ca120
...
...
@@ -16,17 +16,14 @@
#include <gflags/gflags.h>
#include <gtest/gtest.h>
#define private public
#define protected public
#include "modules/perception/lib/config_manager/config_manager.h"
namespace
apollo
{
namespace
perception
{
namespace
lib
{
using
std
::
string
;
using
std
::
vector
;
DECLARE_string
(
config_manager_path
);
class
ConfigManagerTest
:
public
testing
::
Test
{
protected:
ConfigManagerTest
()
:
config_manager_
(
NULL
)
{}
...
...
@@ -63,7 +60,7 @@ TEST_F(ConfigManagerTest, TestInit) {
}
TEST_F
(
ConfigManagerTest
,
TestGetModelConfig
)
{
string
model_name
=
"FrameClassifier"
;
st
d
::
st
ring
model_name
=
"FrameClassifier"
;
const
ModelConfig
*
model_config
=
NULL
;
EXPECT_TRUE
(
config_manager_
->
GetModelConfig
(
model_name
,
&
model_config
));
...
...
@@ -77,7 +74,7 @@ TEST_F(ConfigManagerTest, TestGetModelConfig) {
}
TEST_F
(
ConfigManagerTest
,
TestModelConfig
)
{
string
model_name
=
"FrameClassifier"
;
st
d
::
st
ring
model_name
=
"FrameClassifier"
;
const
ModelConfig
*
model_config
=
NULL
;
ASSERT_TRUE
(
config_manager_
->
Init
());
ASSERT_EQ
(
config_manager_
->
NumModels
(),
2u
);
...
...
@@ -93,7 +90,7 @@ TEST_F(ConfigManagerTest, TestModelConfig) {
EXPECT_TRUE
(
model_config
->
get_value
(
"threshold2"
,
&
int_value
));
EXPECT_EQ
(
int_value
,
2
);
string
str_value
;
st
d
::
st
ring
str_value
;
EXPECT_TRUE
(
model_config
->
get_value
(
"threshold3"
,
&
str_value
));
EXPECT_EQ
(
str_value
,
"str3"
);
...
...
@@ -111,22 +108,22 @@ TEST_F(ConfigManagerTest, TestModelConfig) {
EXPECT_TRUE
(
model_config
->
get_value
(
"bool_value_false"
,
&
bool_value
));
EXPECT_EQ
(
bool_value
,
false
);
vector
<
int
>
int_list
;
std
::
vector
<
int
>
int_list
;
EXPECT_TRUE
(
model_config
->
get_value
(
"array_p1"
,
&
int_list
));
EXPECT_EQ
(
int_list
.
size
(),
3u
);
EXPECT_EQ
(
int_list
[
2
],
3
);
vector
<
string
>
str_list
;
std
::
vector
<
std
::
string
>
str_list
;
EXPECT_TRUE
(
model_config
->
get_value
(
"array_p2"
,
&
str_list
));
EXPECT_EQ
(
str_list
.
size
(),
4u
);
EXPECT_EQ
(
str_list
[
2
],
"str3"
);
vector
<
double
>
double_list
;
std
::
vector
<
double
>
double_list
;
EXPECT_TRUE
(
model_config
->
get_value
(
"array_p4"
,
&
double_list
));
EXPECT_EQ
(
double_list
.
size
(),
4u
);
EXPECT_EQ
(
double_list
[
2
],
1.3
);
vector
<
bool
>
bool_list
;
std
::
vector
<
bool
>
bool_list
;
EXPECT_TRUE
(
model_config
->
get_value
(
"array_bool"
,
&
bool_list
));
EXPECT_EQ
(
bool_list
.
size
(),
4u
);
EXPECT_EQ
(
bool_list
[
2
],
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录