Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
fb0322f5
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,发现更多精彩内容 >>
提交
fb0322f5
编写于
12月 24, 2017
作者:
J
Jiangtao Hu
提交者:
Qi Luo
12月 24, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
map: replace CHECK with log error handling.
上级
3a41ef06
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
51 addition
and
20 deletion
+51
-20
modules/common/log.h
modules/common/log.h
+24
-0
modules/map/hdmap/hdmap_common.cc
modules/map/hdmap/hdmap_common.cc
+27
-20
未找到文件。
modules/common/log.h
浏览文件 @
fb0322f5
...
...
@@ -40,4 +40,28 @@
#define AWARN_EVERY(freq) LOG_EVERY_N(WARNING, freq)
#define AERROR_EVERY(freq) LOG_EVERY_N(ERROR, freq)
#define RETURN_IF_NULL(ptr) \
if (ptr == nullptr) { \
AWARN << #ptr << " is nullptr."; \
return; \
}
#define RETURN_VAL_IF_NULL(ptr, val) \
if (ptr == nullptr) { \
AWARN << #ptr << " is nullptr."; \
return val; \
}
#define RETURN_IF(condition) \
if (condition) { \
AWARN << #condition << " is not met."; \
return; \
}
#define RETURN_VAL_IF(condition, val) \
if (condition) { \
AWARN << #condition << " is not met."; \
return val; \
}
#endif // MODULES_COMMON_LOG_H_
modules/map/hdmap/hdmap_common.cc
浏览文件 @
fb0322f5
...
...
@@ -41,7 +41,7 @@ const double kDuplicatedPointsEpsilon = 1e-7;
const
double
kEpsilon
=
0.1
;
void
RemoveDuplicates
(
std
::
vector
<
Vec2d
>
*
points
)
{
CHECK_NOT
NULL
(
points
);
RETURN_IF_
NULL
(
points
);
int
count
=
0
;
const
double
limit
=
kDuplicatedPointsEpsilon
*
kDuplicatedPointsEpsilon
;
...
...
@@ -54,7 +54,8 @@ void RemoveDuplicates(std::vector<Vec2d> *points) {
}
void
PointsFromCurve
(
const
Curve
&
input_curve
,
std
::
vector
<
Vec2d
>
*
points
)
{
CHECK_NOTNULL
(
points
)
->
clear
();
RETURN_IF_NULL
(
points
);
points
->
clear
();
for
(
const
auto
&
curve
:
input_curve
.
segment
())
{
if
(
curve
.
has_line_segment
())
{
...
...
@@ -62,7 +63,7 @@ void PointsFromCurve(const Curve &input_curve, std::vector<Vec2d> *points) {
points
->
emplace_back
(
point
.
x
(),
point
.
y
());
}
}
else
{
LOG
(
FATAL
)
<<
"Can not handle curve type."
;
AERROR
<<
"Can not handle curve type."
;
}
}
RemoveDuplicates
(
points
);
...
...
@@ -86,7 +87,7 @@ apollo::common::math::Polygon2d ConvertToPolygon2d(const Polygon &polygon) {
void
SegmentsFromCurve
(
const
Curve
&
curve
,
std
::
vector
<
apollo
::
common
::
math
::
LineSegment2d
>
*
segments
)
{
CHECK_NOT
NULL
(
segments
);
RETURN_IF_
NULL
(
segments
);
std
::
vector
<
Vec2d
>
points
;
PointsFromCurve
(
curve
,
&
points
);
...
...
@@ -188,10 +189,15 @@ void LaneInfo::GetWidth(const double s, double *left_width,
double
LaneInfo
::
Heading
(
const
double
s
)
const
{
const
double
kEpsilon
=
0.001
;
CHECK
(
s
+
kEpsilon
>=
accumulated_s_
.
front
())
<<
"s:"
<<
s
<<
" should be >= "
<<
accumulated_s_
.
front
();
CHECK
(
s
-
kEpsilon
<=
accumulated_s_
.
back
())
<<
"s:"
<<
s
<<
" should be <= "
<<
accumulated_s_
.
back
();
if
(
s
+
kEpsilon
<
accumulated_s_
.
front
())
{
AERROR
<<
"s:"
<<
s
<<
" should be >= "
<<
accumulated_s_
.
front
();
return
0.0
;
}
if
(
s
-
kEpsilon
>
accumulated_s_
.
back
())
{
AERROR
<<
"s:"
<<
s
<<
" should be <= "
<<
accumulated_s_
.
back
();
return
0.0
;
}
auto
iter
=
std
::
lower_bound
(
accumulated_s_
.
begin
(),
accumulated_s_
.
end
(),
s
);
int
index
=
std
::
distance
(
accumulated_s_
.
begin
(),
iter
);
if
(
index
==
0
||
*
iter
-
s
<=
common
::
math
::
kMathEpsilon
)
{
...
...
@@ -199,7 +205,6 @@ double LaneInfo::Heading(const double s) const {
}
else
{
return
common
::
math
::
slerp
(
headings_
[
index
-
1
],
accumulated_s_
[
index
-
1
],
headings_
[
index
],
accumulated_s_
[
index
],
s
);
// return headings_[index - 1];
}
}
...
...
@@ -277,7 +282,8 @@ bool LaneInfo::IsOnLane(const apollo::common::math::Box2d &box) const {
}
PointENU
LaneInfo
::
GetSmoothPoint
(
double
s
)
const
{
CHECK_GE
(
points_
.
size
(),
2
);
PointENU
point
;
RETURN_VAL_IF
(
points_
.
size
()
<
2
,
point
);
if
(
s
<=
0.0
)
{
return
PointFromVec2d
(
points_
[
0
]);
}
...
...
@@ -288,7 +294,7 @@ PointENU LaneInfo::GetSmoothPoint(double s) const {
const
auto
low_itr
=
std
::
lower_bound
(
accumulated_s_
.
begin
(),
accumulated_s_
.
end
(),
s
);
CHECK
(
low_itr
!=
accumulated_s_
.
end
()
);
RETURN_VAL_IF
(
low_itr
==
accumulated_s_
.
end
(),
point
);
size_t
index
=
low_itr
-
accumulated_s_
.
begin
();
double
delta_s
=
*
low_itr
-
s
;
if
(
delta_s
<
apollo
::
common
::
math
::
kMathEpsilon
)
{
...
...
@@ -302,18 +308,18 @@ PointENU LaneInfo::GetSmoothPoint(double s) const {
double
LaneInfo
::
DistanceTo
(
const
Vec2d
&
point
)
const
{
const
auto
segment_box
=
lane_segment_kdtree_
->
GetNearestObject
(
point
);
CHECK
(
segment_box
!=
nullptr
);
RETURN_VAL_IF_NULL
(
segment_box
,
0.0
);
return
segment_box
->
DistanceTo
(
point
);
}
double
LaneInfo
::
DistanceTo
(
const
Vec2d
&
point
,
Vec2d
*
map_point
,
double
*
s_offset
,
int
*
s_offset_index
)
const
{
CHECK_NOTNULL
(
map_point
);
CHECK_NOTNULL
(
s_offset
);
CHECK_NOTNULL
(
s_offset_index
);
RETURN_VAL_IF_NULL
(
map_point
,
0.0
);
RETURN_VAL_IF_NULL
(
s_offset
,
0.0
);
RETURN_VAL_IF_NULL
(
s_offset_index
,
0.0
);
const
auto
segment_box
=
lane_segment_kdtree_
->
GetNearestObject
(
point
);
CHECK
(
segment_box
!=
nullptr
);
RETURN_VAL_IF_NULL
(
segment_box
,
0.0
);
int
index
=
segment_box
->
id
();
double
distance
=
segments_
[
index
].
DistanceTo
(
point
,
map_point
);
*
s_offset_index
=
index
;
...
...
@@ -323,10 +329,11 @@ double LaneInfo::DistanceTo(const Vec2d &point, Vec2d *map_point,
}
PointENU
LaneInfo
::
GetNearestPoint
(
const
Vec2d
&
point
,
double
*
distance
)
const
{
CHECK_NOTNULL
(
distance
);
PointENU
empty_point
;
RETURN_VAL_IF_NULL
(
distance
,
empty_point
);
const
auto
segment_box
=
lane_segment_kdtree_
->
GetNearestObject
(
point
);
CHECK
(
segment_box
!=
nullptr
);
RETURN_VAL_IF_NULL
(
segment_box
,
empty_point
);
int
index
=
segment_box
->
id
();
Vec2d
nearest_point
;
*
distance
=
segments_
[
index
].
DistanceTo
(
point
,
&
nearest_point
);
...
...
@@ -336,8 +343,8 @@ PointENU LaneInfo::GetNearestPoint(const Vec2d &point, double *distance) const {
bool
LaneInfo
::
GetProjection
(
const
Vec2d
&
point
,
double
*
accumulate_s
,
double
*
lateral
)
const
{
CHECK_NOTNULL
(
accumulate_s
);
CHECK_NOTNULL
(
lateral
);
RETURN_VAL_IF_NULL
(
accumulate_s
,
false
);
RETURN_VAL_IF_NULL
(
lateral
,
false
);
if
(
segments_
.
empty
())
{
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录