Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
4b8b9ada
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,发现更多精彩内容 >>
提交
4b8b9ada
编写于
3月 19, 2018
作者:
G
gchen-apollo
提交者:
Jiangtao Hu
3月 19, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Perception: add tiemstamp trigger procedure in motion manager service
上级
c2240318
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
85 addition
and
26 deletion
+85
-26
modules/perception/obstacle/camera/motion/BUILD
modules/perception/obstacle/camera/motion/BUILD
+2
-0
modules/perception/obstacle/camera/motion/plane_motion.cc
modules/perception/obstacle/camera/motion/plane_motion.cc
+36
-20
modules/perception/obstacle/camera/motion/plane_motion.h
modules/perception/obstacle/camera/motion/plane_motion.h
+5
-1
modules/perception/obstacle/onboard/BUILD
modules/perception/obstacle/onboard/BUILD
+1
-0
modules/perception/obstacle/onboard/motion_service.cc
modules/perception/obstacle/onboard/motion_service.cc
+22
-2
modules/perception/obstacle/onboard/motion_service.h
modules/perception/obstacle/onboard/motion_service.h
+3
-1
modules/perception/onboard/common_shared_data.h
modules/perception/onboard/common_shared_data.h
+16
-2
未找到文件。
modules/perception/obstacle/camera/motion/BUILD
浏览文件 @
4b8b9ada
...
...
@@ -14,6 +14,8 @@ cc_library(
"-Wno-deprecated"
,
],
deps
=
[
"//modules/common"
,
"//modules/common:log"
,
"//modules/perception/obstacle/base"
,
],
)
...
...
modules/perception/obstacle/camera/motion/plane_motion.cc
浏览文件 @
4b8b9ada
...
...
@@ -14,6 +14,7 @@
* limitations under the License.
*****************************************************************************/
#include "modules/common/log.h"
#include "modules/perception/obstacle/camera/motion/plane_motion.h"
namespace
apollo
{
...
...
@@ -52,29 +53,44 @@ void PlaneMotion::generate_motion_matrix(VehicleStatus *vehicledata) {
vehicledata
->
motion
=
motion_2d
;
}
void
PlaneMotion
::
a
dd_new
_motion
(
VehicleStatus
*
vehicledata
,
float
motion_time_dif
,
bool
image_read
)
{
void
PlaneMotion
::
a
ccumulate
_motion
(
VehicleStatus
*
vehicledata
,
float
motion_time_dif
)
{
generate_motion_matrix
(
vehicledata
);
// compute vehicledata.motion
// accumulate CAN+IMU / Localization motion
mat_motion_2d_image_
*=
vehicledata
->
motion
;
time_difference_
+=
motion_time_dif
;
}
// both CAN+IMU and image time stamp
mat_motion_2d_image_
=
mat_motion_2d_image_
*
vehicledata
->
motion
;
// accumulate CAN+IMU motion
time_difference_
+=
motion_time_dif
;
// accumulate time diff before inserting into buffer
if
(
image_read
)
{
// image capture time stamp to insert the buffer for the accumulated motion
for
(
int
k
=
0
;
k
<
static_cast
<
int
>
(
mot_buffer_
->
size
());
k
++
)
{
(
*
mot_buffer_
)[
k
].
motion
*=
mat_motion_2d_image_
;
}
void
PlaneMotion
::
update_motion_buffer
(
VehicleStatus
*
vehicledata
)
{
for
(
int
k
=
0
;
k
<
static_cast
<
int
>
(
mot_buffer_
->
size
());
k
++
)
{
(
*
mot_buffer_
)[
k
].
motion
*=
mat_motion_2d_image_
;
}
vehicledata
->
time_d
=
time_difference_
;
vehicledata
->
motion
=
mat_motion_2d_image_
;
mot_buffer_
->
push_back
(
*
vehicledata
);
// a new image frame is added
mat_motion_2d_image_
=
Eigen
::
Matrix3f
::
Identity
();
// reset image accumulated motion
time_difference_
=
0
;
// reset the accumulated time difference
vehicledata
->
time_d
=
time_difference_
;
vehicledata
->
motion
=
mat_motion_2d_image_
;
mot_buffer_
->
push_back
(
*
vehicledata
);
// a new image frame is added
mat_motion_2d_image_
=
Eigen
::
Matrix3f
::
Identity
();
// reset image accumulated motion
time_difference_
=
0
;
// reset the accumulated time difference
}
void
PlaneMotion
::
add_new_motion
(
VehicleStatus
*
vehicledata
,
float
motion_time_dif
,
int
motion_operation_flag
)
{
switch
(
motion_operation_flag
)
{
case
ACCUM_MOTION
:
accumulate_motion
(
vehicledata
,
motion_time_dif
);
break
;
case
ACCUM_PUSH_MOTION
:
accumulate_motion
(
vehicledata
,
motion_time_dif
);
update_motion_buffer
(
vehicledata
);
break
;
case
PUSH_ACCUM_MOTION
:
update_motion_buffer
(
vehicledata
);
accumulate_motion
(
vehicledata
,
motion_time_dif
);
break
;
default:
AERROR
<<
"motion operation flag:wrong type"
;
return
;
}
}
...
...
modules/perception/obstacle/camera/motion/plane_motion.h
浏览文件 @
4b8b9ada
...
...
@@ -37,6 +37,7 @@ class PlaneMotion {
explicit
PlaneMotion
(
int
s
,
bool
sync_time_stamp
,
float
time_unit
);
~
PlaneMotion
(
void
);
enum
{
ACCUM_MOTION
=
0
,
ACCUM_PUSH_MOTION
,
PUSH_ACCUM_MOTION
};
private:
MotionBufferPtr
mot_buffer_
;
...
...
@@ -48,6 +49,9 @@ class PlaneMotion {
// motion matrix of accumulation through high sampling CAN+IMU input sequence
void
generate_motion_matrix
(
VehicleStatus
*
vehicledata
);
// generate inverse motion
void
accumulate_motion
(
VehicleStatus
*
vehicledata
,
float
motion_time_dif
);
void
update_motion_buffer
(
VehicleStatus
*
vehicledata
);
public:
void
cleanbuffer
()
{
...
...
@@ -73,7 +77,7 @@ class PlaneMotion {
// void init(int s) { set_buffer_size(s); }
void
add_new_motion
(
VehicleStatus
*
vehicledata
,
float
motion_time_dif
,
bool
image_read
);
int
motion_operation_flag
);
MotionBufferPtr
get_buffer
()
{
return
mot_buffer_
;
}
};
...
...
modules/perception/obstacle/onboard/BUILD
浏览文件 @
4b8b9ada
...
...
@@ -159,6 +159,7 @@ cc_library(
"motion_service.h"
,
],
deps
=
[
":perception_obstacle_shared_data"
,
"//modules/common/adapters:adapter_manager"
,
"//modules/perception/lib/config_manager"
,
"//modules/perception/obstacle/camera/motion"
,
...
...
modules/perception/obstacle/onboard/motion_service.cc
浏览文件 @
4b8b9ada
...
...
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include<limits>
#include "modules/perception/obstacle/onboard/motion_service.h"
#include "modules/perception/lib/base/mutex.h"
#include "modules/perception/onboard/event_manager.h"
...
...
@@ -31,6 +31,13 @@ bool MotionService::InitInternal() {
vehicle_planemotion_
=
new
PlaneMotion
(
motion_buffer_size_
,
false
,
1.0
f
/
motion_sensor_frequency_
);
CHECK
(
shared_data_manager_
!=
NULL
);
camera_shared_data_
=
dynamic_cast
<
CameraSharedData
*>
(
shared_data_manager_
->
GetSharedData
(
"CameraSharedData"
));
if
(
camera_shared_data_
==
nullptr
)
{
AERROR
<<
"Failed to get CameraSharedData."
;
return
false
;
}
AINFO
<<
"init MotionService success."
;
return
true
;
}
...
...
@@ -68,7 +75,20 @@ void MotionService::OnLocalization(
pre_timestamp
=
localization
.
measurement_time
();
// add motion to buffer
vehicle_planemotion_
->
add_new_motion
(
&
vehicle_status
,
timestamp_diff
,
false
);
double
camera_timestamp
=
camera_shared_data_
->
GetLatestTimestamp
();
if
(
std
::
abs
(
pre_timestamp
-
camera_timestamp
)
<
std
::
numeric_limits
<
double
>::
epsilon
())
{
// exactly same timestamp
vehicle_planemotion_
->
add_new_motion
(
&
vehicle_status
,
timestamp_diff
,
PlaneMotion
::
ACCUM_PUSH_MOTION
);
}
else
if
(
pre_timestamp
<
camera_timestamp
)
{
vehicle_planemotion_
->
add_new_motion
(
&
vehicle_status
,
timestamp_diff
,
PlaneMotion
::
ACCUM_MOTION
);
}
else
{
vehicle_planemotion_
->
add_new_motion
(
&
vehicle_status
,
timestamp_diff
,
PlaneMotion
::
PUSH_ACCUM_MOTION
);
}
}
void
MotionService
::
GetVehicleInformation
(
...
...
modules/perception/obstacle/onboard/motion_service.h
浏览文件 @
4b8b9ada
...
...
@@ -25,7 +25,7 @@
#include "modules/perception/obstacle/camera/motion/plane_motion.h"
#include "modules/perception/onboard/subnode.h"
#include "modules/perception/onboard/subnode_helper.h"
#include "modules/perception/obstacle/onboard/camera_shared_data.h"
namespace
apollo
{
namespace
perception
{
...
...
@@ -55,11 +55,13 @@ class MotionService : public Subnode {
PlaneMotion
*
vehicle_planemotion_
=
nullptr
;
double
pre_azimuth
=
0
;
// a invalid value
double
pre_timestamp
=
0
;
// double pre_camera_timestamp = 0;
bool
start_flag_
=
false
;
const
int
motion_buffer_size_
=
6000
;
const
int
motion_sensor_frequency_
=
100
;
Mutex
mutex_
;
std
::
list
<
VehicleInformation
>
vehicle_information_buffer_
;
CameraSharedData
*
camera_shared_data_
=
nullptr
;
// MotionBufferPtr motion_buffer_;
DISALLOW_COPY_AND_ASSIGN
(
MotionService
);
};
...
...
modules/perception/onboard/common_shared_data.h
浏览文件 @
4b8b9ada
...
...
@@ -23,6 +23,8 @@
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <limits>
#include "boost/format.hpp"
#include "gflags/gflags.h"
...
...
@@ -77,7 +79,10 @@ class CommonSharedData : public SharedData {
CommonSharedData
()
{}
virtual
~
CommonSharedData
()
{}
bool
Init
()
override
{
return
true
;
}
bool
Init
()
override
{
latest_timestamp_
=
std
::
numeric_limits
<
double
>::
min
();
return
true
;
}
// @brief: you must impl your own name func
// @return: name of your own class
virtual
std
::
string
name
()
const
=
0
;
...
...
@@ -103,6 +108,7 @@ class CommonSharedData : public SharedData {
bool
Get
(
const
CommonSharedDataKey
&
key
,
SharedDataPtr
<
M
>
*
data
);
double
GetLatestTimestamp
()
const
;
// @brief: remove shared data with the given key
// @param [in]: key
// @return : true or false
...
...
@@ -135,6 +141,7 @@ class CommonSharedData : public SharedData {
Mutex
mutex_
;
CommonSharedDataStat
stat_
;
DataAddedTimeMap
data_added_time_map_
;
double
latest_timestamp_
=
std
::
numeric_limits
<
double
>::
min
();
DISALLOW_COPY_AND_ASSIGN
(
CommonSharedData
);
};
...
...
@@ -145,6 +152,7 @@ void CommonSharedData<M>::Reset() {
AINFO
<<
"Reset "
<<
name
()
<<
", map size: "
<<
data_map_
.
size
();
data_map_
.
clear
();
data_added_time_map_
.
clear
();
latest_timestamp_
=
std
::
numeric_limits
<
double
>::
min
();
}
template
<
class
M
>
...
...
@@ -186,7 +194,6 @@ bool CommonSharedData<M>::Add(const std::string &key,
const
uint64_t
timestamp
=
::
time
(
NULL
);
data_added_time_map_
.
emplace
(
DataKeyTimestampPair
(
key
,
timestamp
));
++
stat_
.
add_cnt
;
return
true
;
}
...
...
@@ -194,6 +201,8 @@ bool CommonSharedData<M>::Add(const std::string &key,
template
<
class
M
>
bool
CommonSharedData
<
M
>::
Add
(
const
CommonSharedDataKey
&
key
,
const
SharedDataPtr
<
M
>
&
data
)
{
// update latest_timestamp for SharedData
latest_timestamp_
=
std
::
max
(
latest_timestamp_
,
key
.
timestamp
);
return
Add
(
key
.
ToString
(),
data
);
}
...
...
@@ -216,6 +225,11 @@ bool CommonSharedData<M>::Get(const CommonSharedDataKey &key,
return
Get
(
key
.
ToString
(),
data
);
}
template
<
class
M
>
double
CommonSharedData
<
M
>::
GetLatestTimestamp
()
const
{
return
latest_timestamp_
;
}
template
<
class
M
>
bool
CommonSharedData
<
M
>::
Remove
(
const
std
::
string
&
key
)
{
MutexLock
lock
(
&
mutex_
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录