Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
5f95e86e
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,体验更适合开发者的 AI 搜索 >>
提交
5f95e86e
编写于
4月 10, 2018
作者:
L
Liangliang Zhang
提交者:
Dong Li
4月 10, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Perception: avoiding using bubble sort.
上级
1fb593b8
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
60 addition
and
58 deletion
+60
-58
modules/perception/BUILD
modules/perception/BUILD
+1
-1
modules/perception/model/traffic_light/reviser.config
modules/perception/model/traffic_light/reviser.config
+1
-1
modules/perception/obstacle/fusion/probabilistic_fusion/BUILD
...les/perception/obstacle/fusion/probabilistic_fusion/BUILD
+0
-1
modules/perception/obstacle/fusion/probabilistic_fusion/pbf_sensor.cc
...eption/obstacle/fusion/probabilistic_fusion/pbf_sensor.cc
+14
-18
modules/perception/obstacle/fusion/probabilistic_fusion/pbf_sensor.h
...ception/obstacle/fusion/probabilistic_fusion/pbf_sensor.h
+16
-9
modules/perception/obstacle/fusion/probabilistic_fusion/pbf_sensor_manager.cc
...bstacle/fusion/probabilistic_fusion/pbf_sensor_manager.cc
+15
-21
modules/perception/obstacle/fusion/probabilistic_fusion/pbf_sensor_manager.h
...obstacle/fusion/probabilistic_fusion/pbf_sensor_manager.h
+10
-5
modules/perception/obstacle/fusion/probabilistic_fusion/pbf_sensor_manager_test.cc
...le/fusion/probabilistic_fusion/pbf_sensor_manager_test.cc
+3
-2
未找到文件。
modules/perception/BUILD
浏览文件 @
5f95e86e
...
...
@@ -15,13 +15,13 @@ cc_library(
"//modules/perception/common"
,
"//modules/perception/lib/base"
,
"//modules/perception/obstacle/onboard:camera_subnode"
,
"//modules/perception/obstacle/onboard:cipv_subnode"
,
"//modules/perception/obstacle/onboard:fusion_subnode"
,
"//modules/perception/obstacle/onboard:lane_post_processing_subnode"
,
"//modules/perception/obstacle/onboard:lidar_subnode"
,
"//modules/perception/obstacle/onboard:perception_obstacle_shared_data"
,
"//modules/perception/obstacle/onboard:radar_subnode"
,
"//modules/perception/obstacle/onboard:visualization_subnode"
,
"//modules/perception/obstacle/onboard:cipv_subnode"
,
"//modules/perception/onboard"
,
"//modules/perception/proto:perception_proto"
,
"//modules/perception/traffic_light/onboard"
,
...
...
modules/perception/model/traffic_light/reviser.config
浏览文件 @
5f95e86e
...
...
@@ -5,7 +5,7 @@ model_configs {
name
:
"param_file"
value
:
"data/models/reviser/reviser.prototxt"
}
}
}
model_configs
{
name
:
"ColorReviser"
version
:
"1.0.0"
...
...
modules/perception/obstacle/fusion/probabilistic_fusion/BUILD
浏览文件 @
5f95e86e
load
(
"//tools:cpplint.bzl"
,
"cpplint"
)
load
(
"//tools:cpplint.bzl"
,
"cpplint"
)
package
(
default_visibility
=
[
"//visibility:public"
])
...
...
modules/perception/obstacle/fusion/probabilistic_fusion/pbf_sensor.cc
浏览文件 @
5f95e86e
...
...
@@ -24,27 +24,25 @@ namespace perception {
size_t
PbfSensor
::
s_max_cached_frame_number_
=
10
;
PbfSensor
::
PbfSensor
(
const
SensorType
&
type
,
const
std
::
string
&
sensor_id
)
:
sensor_id_
(
sensor_id
),
sensor_type_
(
type
)
,
latest_query_timestamp_
(
0.0
)
{}
PbfSensor
::
PbfSensor
(
const
std
::
string
&
sensor_id
,
const
SensorType
&
type
)
:
sensor_id_
(
sensor_id
),
sensor_type_
(
type
)
{}
PbfSensor
::~
PbfSensor
()
{}
void
PbfSensor
::
QueryLatestFrames
(
double
time_stamp
,
void
PbfSensor
::
QueryLatestFrames
(
const
double
time_stamp
,
std
::
vector
<
PbfSensorFramePtr
>
*
frames
)
{
if
(
frames
==
nullptr
)
{
return
;
}
CHECK_NOTNULL
(
frames
);
frames
->
clear
();
for
(
size_t
i
=
0
;
i
<
frames_
.
size
();
++
i
)
{
if
(
frames_
[
i
]
->
timestamp
>
latest_query_timestamp_
&&
frames_
[
i
]
->
timestamp
<=
time_stamp
)
{
(
*
frames
).
push_back
(
frames_
[
i
]);
frames
->
push_back
(
frames_
[
i
]);
}
}
latest_query_timestamp_
=
time_stamp
;
}
PbfSensorFramePtr
PbfSensor
::
QueryLatestFrame
(
double
time_stamp
)
{
PbfSensorFramePtr
PbfSensor
::
QueryLatestFrame
(
const
double
time_stamp
)
{
PbfSensorFramePtr
latest_frame
=
nullptr
;
for
(
size_t
i
=
0
;
i
<
frames_
.
size
();
++
i
)
{
if
(
frames_
[
i
]
->
timestamp
>
latest_query_timestamp_
&&
...
...
@@ -80,21 +78,19 @@ void PbfSensor::AddFrame(const SensorObjects &frame) {
frames_
.
push_back
(
pbf_frame
);
}
bool
PbfSensor
::
GetPose
(
double
time_stamp
,
Eigen
::
Matrix4d
*
pose
)
{
if
(
pose
==
nullptr
)
{
AERROR
<<
"parameter pose is nullptr for output"
;
return
false
;
}
bool
PbfSensor
::
GetPose
(
const
double
time_stamp
,
const
double
time_range
,
Eigen
::
Matrix4d
*
pose
)
{
CHECK_NOTNULL
(
pose
);
CHECK_GE
(
time_range
,
0.0
);
for
(
int
i
=
frames_
.
size
()
-
1
;
i
>=
0
;
i
--
)
{
double
time_diff
=
time_stamp
-
frames_
[
i
]
->
timestamp
;
if
(
fabs
(
time_diff
)
<
1.0e-3
)
{
*
pose
=
frames_
[
i
]
->
sensor2world_pose
;
for
(
auto
rit
=
frames_
.
rbegin
();
rit
!=
frames_
.
rend
();
++
rit
)
{
const
double
time_diff
=
time_stamp
-
(
*
rit
)
->
timestamp
;
if
(
fabs
(
time_diff
)
<
time_range
)
{
*
pose
=
(
*
rit
)
->
sensor2world_pose
;
return
true
;
}
}
AERROR
<<
"Failed to find velodyne2world pose for timestamp: "
<<
time_stamp
;
return
false
;
}
...
...
modules/perception/obstacle/fusion/probabilistic_fusion/pbf_sensor.h
浏览文件 @
5f95e86e
...
...
@@ -16,9 +16,11 @@
#ifndef MODULES_PERCEPTION_OBSTACLE_FUSION_PROBABILISTIC_FUSION_PBF_SENSOR_H_
#define MODULES_PERCEPTION_OBSTACLE_FUSION_PROBABILISTIC_FUSION_PBF_SENSOR_H_
#include <deque>
#include <string>
#include <vector>
#include "modules/common/log.h"
#include "modules/common/macro.h"
#include "modules/perception/obstacle/base/object.h"
...
...
@@ -29,26 +31,31 @@ namespace perception {
class
PbfSensor
{
public:
explicit
PbfSensor
(
const
SensorType
&
type
,
const
std
::
string
&
sensor_id
);
explicit
PbfSensor
(
const
std
::
string
&
sensor_id
,
const
SensorType
&
type
);
~
PbfSensor
();
/* @brief query frames whose time stamp is in range (latest_fused_time_stamp_,
* time_stamp)
/*
* @brief query frames whose time stamp is in range (latest_fused_time_stamp_,
* time_stamp); update latest_query_timestamp_ by time_stamp.
*/
void
QueryLatestFrames
(
double
time_stamp
,
std
::
vector
<
PbfSensorFramePtr
>
*
frames
);
/**@brief query latest frame whose time stamp is in range
* (latest_fused_time_stamp_, time_stamp]*/
PbfSensorFramePtr
QueryLatestFrame
(
double
time_stamp
);
/*
* @brief query latest frame whose time stamp is in range
* (latest_fused_time_stamp_, time_stamp]; update latest_query_timestamp_ by
* time_stamp
*/
PbfSensorFramePtr
QueryLatestFrame
(
const
double
time_stamp
);
/**@brief add a frame objects*/
void
AddFrame
(
const
SensorObjects
&
frame
);
/**@brief query pose at time_stamp, return false if not found*/
bool
GetPose
(
double
time_stamp
,
Eigen
::
Matrix4d
*
pose
);
bool
GetPose
(
const
double
time_stamp
,
const
double
time_range
,
Eigen
::
Matrix4d
*
pose
);
static
void
SetMaxCachedFrameNumber
(
int
number
)
{
static
void
SetMaxCachedFrameNumber
(
const
int
number
)
{
s_max_cached_frame_number_
=
number
;
}
...
...
@@ -62,7 +69,7 @@ class PbfSensor {
/**@brief max size of frames_*/
static
size_t
s_max_cached_frame_number_
;
double
latest_query_timestamp_
;
double
latest_query_timestamp_
=
0.0
;
private:
PbfSensor
();
...
...
modules/perception/obstacle/fusion/probabilistic_fusion/pbf_sensor_manager.cc
浏览文件 @
5f95e86e
...
...
@@ -16,6 +16,8 @@
#include "modules/perception/obstacle/fusion/probabilistic_fusion/pbf_sensor_manager.h"
#include <algorithm>
#include "modules/common/log.h"
namespace
apollo
{
...
...
@@ -29,8 +31,7 @@ PbfSensorManager *PbfSensorManager::Instance() {
PbfSensorManager
::
PbfSensorManager
()
{}
PbfSensorManager
::~
PbfSensorManager
()
{
std
::
map
<
std
::
string
,
PbfSensor
*>::
iterator
it
=
sensors_
.
begin
();
for
(;
it
!=
sensors_
.
end
();
++
it
)
{
for
(
auto
it
=
sensors_
.
begin
();
it
!=
sensors_
.
end
();
++
it
)
{
if
(
it
->
second
!=
nullptr
)
{
delete
(
it
->
second
);
it
->
second
=
nullptr
;
...
...
@@ -45,12 +46,12 @@ bool PbfSensorManager::Init() {
std
::
string
sensor_id
=
GetSensorType
(
SensorType
::
VELODYNE_64
);
SensorType
type
=
SensorType
::
VELODYNE_64
;
PbfSensor
*
velodyne_64
=
new
PbfSensor
(
type
,
sensor_id
);
PbfSensor
*
velodyne_64
=
new
PbfSensor
(
sensor_id
,
type
);
sensors_
[
sensor_id
]
=
velodyne_64
;
sensor_id
=
GetSensorType
(
SensorType
::
RADAR
);
type
=
SensorType
::
RADAR
;
PbfSensor
*
radar
=
new
PbfSensor
(
type
,
sensor_id
);
PbfSensor
*
radar
=
new
PbfSensor
(
sensor_id
,
type
);
if
(
radar
==
nullptr
)
{
AERROR
<<
"Fail to create PbfSensor. sensor_id = "
<<
sensor_id
;
return
false
;
...
...
@@ -74,7 +75,7 @@ void PbfSensorManager::AddSensorMeasurements(const SensorObjects &objects) {
if
(
it
==
sensors_
.
end
())
{
AWARN
<<
"Cannot find sensor "
<<
sensor_id
<<
" and create one in SensorManager"
;
sensor
=
new
PbfSensor
(
type
,
sensor_id
);
sensor
=
new
PbfSensor
(
sensor_id
,
type
);
if
(
sensor
==
nullptr
)
{
AERROR
<<
"Fail to create PbfSensor. sensor_id = "
<<
sensor_id
;
return
;
...
...
@@ -87,12 +88,12 @@ void PbfSensorManager::AddSensorMeasurements(const SensorObjects &objects) {
}
void
PbfSensorManager
::
GetLatestSensorFrames
(
double
time_stamp
,
const
std
::
string
&
sensor_id
,
const
double
time_stamp
,
const
std
::
string
&
sensor_id
,
std
::
vector
<
PbfSensorFramePtr
>
*
frames
)
{
if
(
frames
==
nullptr
)
{
return
;
}
std
::
map
<
std
::
string
,
PbfSensor
*>::
iterator
it
=
sensors_
.
find
(
sensor_id
);
auto
it
=
sensors_
.
find
(
sensor_id
);
if
(
it
==
sensors_
.
end
())
{
return
;
}
...
...
@@ -105,24 +106,17 @@ void PbfSensorManager::GetLatestFrames(const double time_stamp,
return
;
}
frames
->
clear
();
for
(
std
::
map
<
std
::
string
,
PbfSensor
*>::
iterator
it
=
sensors_
.
begin
();
it
!=
sensors_
.
end
();
++
it
)
{
for
(
auto
it
=
sensors_
.
begin
();
it
!=
sensors_
.
end
();
++
it
)
{
PbfSensor
*
sensor
=
it
->
second
;
PbfSensorFramePtr
frame
=
sensor
->
QueryLatestFrame
(
time_stamp
);
if
(
frame
!=
nullptr
)
{
frames
->
push_back
(
frame
);
}
}
int
frame_size
=
static_cast
<
int
>
(
frames
->
size
());
for
(
int
i
=
0
;
i
<
frame_size
-
1
;
i
++
)
{
for
(
int
j
=
i
+
1
;
j
<
frame_size
;
j
++
)
{
if
((
*
frames
)[
j
]
->
timestamp
<
(
*
frames
)[
i
]
->
timestamp
)
{
PbfSensorFramePtr
tf
=
(
*
frames
)[
i
];
(
*
frames
)[
i
]
=
(
*
frames
)[
j
];
(
*
frames
)[
j
]
=
tf
;
}
}
}
std
::
sort
(
frames
->
begin
(),
frames
->
end
(),
[](
const
PbfSensorFramePtr
&
p1
,
const
PbfSensorFramePtr
&
p2
)
{
return
p1
->
timestamp
<
p2
->
timestamp
;
});
}
PbfSensor
*
PbfSensorManager
::
GetSensor
(
const
std
::
string
&
sensor_id
)
{
...
...
@@ -135,7 +129,7 @@ PbfSensor *PbfSensorManager::GetSensor(const std::string &sensor_id) {
}
bool
PbfSensorManager
::
GetPose
(
const
std
::
string
&
sensor_id
,
double
time_stamp
,
Eigen
::
Matrix4d
*
pose
)
{
const
double
time_range
,
Eigen
::
Matrix4d
*
pose
)
{
if
(
pose
==
nullptr
)
{
AERROR
<<
"output parameter pose is nullptr"
;
return
false
;
...
...
@@ -148,7 +142,7 @@ bool PbfSensorManager::GetPose(const std::string &sensor_id, double time_stamp,
}
PbfSensor
*
sensor
=
it
->
second
;
return
sensor
->
GetPose
(
time_stamp
,
pose
);
return
sensor
->
GetPose
(
time_stamp
,
time_range
,
pose
);
}
}
// namespace perception
...
...
modules/perception/obstacle/fusion/probabilistic_fusion/pbf_sensor_manager.h
浏览文件 @
5f95e86e
...
...
@@ -35,19 +35,22 @@ class PbfSensorManager {
void
AddSensorMeasurements
(
const
SensorObjects
&
objects
);
void
GetLatestSensorFrames
(
double
time_stamp
,
const
std
::
string
&
sensor_id
,
void
GetLatestSensorFrames
(
const
double
time_stamp
,
const
std
::
string
&
sensor_id
,
std
::
vector
<
PbfSensorFramePtr
>
*
frames
);
/**@brief query one closest sensor frame for each sensor between last query
timestamp and
current timestamp, stored in ascending order of the frame timestamp */
/*
* @brief query one closest sensor frame for each sensor between last query
* timestamp and current timestamp, stored in ascending order of the frame
* timestamp
*/
void
GetLatestFrames
(
const
double
time_stamp
,
std
::
vector
<
PbfSensorFramePtr
>
*
frames
);
PbfSensor
*
GetSensor
(
const
std
::
string
&
sensor_id
);
bool
GetPose
(
const
std
::
string
&
sensor_id
,
double
time_stamp
,
Eigen
::
Matrix4d
*
pose
);
const
double
time_range
,
Eigen
::
Matrix4d
*
pose
);
protected:
bool
Init
();
...
...
@@ -65,4 +68,6 @@ class PbfSensorManager {
}
// namespace perception
}
// namespace apollo
/* clang-format off */
#endif // MODULES_PERCEPTION_OBSTACLE_FUSION_PROBABILISTIC_FUSION_PBF_SENSOR_MANAGER_H_ // NOLINT
/* clang-format on */
modules/perception/obstacle/fusion/probabilistic_fusion/pbf_sensor_manager_test.cc
浏览文件 @
5f95e86e
...
...
@@ -40,8 +40,9 @@ TEST(PbfSensorManagerTest, pbf_sensor_frame_manage_test) {
sensor_manager
->
AddSensorMeasurements
(
lidar_frame
);
EXPECT_TRUE
(
sensor_manager
->
GetSensor
(
lidar_name
)
!=
nullptr
);
Eigen
::
Matrix4d
pose
;
EXPECT_TRUE
(
sensor_manager
->
GetPose
(
lidar_name
,
lidar_frame
.
timestamp
,
&
pose
));
const
double
kEpsilon
=
1e-3
;
EXPECT_TRUE
(
sensor_manager
->
GetPose
(
lidar_name
,
lidar_frame
.
timestamp
,
kEpsilon
,
&
pose
));
sensor_manager
->
AddSensorMeasurements
(
radar_frame
);
std
::
vector
<
PbfSensorFramePtr
>
frames
;
sensor_manager
->
GetLatestFrames
(
radar_frame
.
timestamp
,
&
frames
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录