Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
ec5f9f09
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,发现更多精彩内容 >>
提交
ec5f9f09
编写于
7月 28, 2017
作者:
A
Aaron Xiao
提交者:
Dong Li
7月 28, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add helper function to print DebugStrings.
上级
0ff0b6a1
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
90 addition
and
55 deletion
+90
-55
modules/common/math/polygon2d.cc
modules/common/math/polygon2d.cc
+5
-11
modules/common/math/polygon2d_test.cc
modules/common/math/polygon2d_test.cc
+1
-1
modules/common/util/string_util.h
modules/common/util/string_util.h
+24
-0
modules/common/util/string_util_internal.h
modules/common/util/string_util_internal.h
+28
-0
modules/planning/common/path/path_data.cc
modules/planning/common/path/path_data.cc
+10
-15
modules/planning/common/planning_data.cc
modules/planning/common/planning_data.cc
+4
-5
modules/planning/common/speed/speed_data.cc
modules/planning/common/speed/speed_data.cc
+9
-14
modules/planning/reference_line/BUILD
modules/planning/reference_line/BUILD
+1
-0
modules/planning/reference_line/reference_line.cc
modules/planning/reference_line/reference_line.cc
+8
-9
未找到文件。
modules/common/math/polygon2d.cc
浏览文件 @
ec5f9f09
...
...
@@ -19,12 +19,11 @@
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>
#include <utility>
#include "modules/common/log.h"
#include "modules/common/math/math_utils.h"
#include "modules/common/util/string_util.h"
namespace
apollo
{
namespace
common
{
...
...
@@ -579,15 +578,10 @@ Polygon2d Polygon2d::ExpandByDistance(const double distance) const {
}
std
::
string
Polygon2d
::
DebugString
()
const
{
std
::
ostringstream
sout
;
sout
<<
"polygon2d ( num_points = "
<<
num_points_
<<
" points = ("
;
for
(
const
auto
&
pt
:
points_
)
{
sout
<<
" "
<<
pt
.
DebugString
();
}
sout
<<
" ) "
<<
(
is_convex_
?
"convex"
:
"non-convex"
)
<<
" area = "
<<
area_
<<
" )"
;
sout
.
flush
();
return
sout
.
str
();
return
util
::
StrCat
(
"polygon2d ( num_points = "
,
num_points_
,
" points = ("
,
util
::
PrintDebugStringIter
(
points_
),
" ) "
,
is_convex_
?
"convex"
:
"non-convex"
,
" area = "
,
area_
,
" )"
);
}
}
// namespace math
...
...
modules/common/math/polygon2d_test.cc
浏览文件 @
ec5f9f09
...
...
@@ -54,7 +54,7 @@ bool ProjectByXSlow(const std::vector<Vec2d> &points, double x,
TEST
(
Polygon2dTest
,
polygon_IsPointIn
)
{
const
Polygon2d
poly1
(
Box2d
::
CreateAABox
({
0
,
0
},
{
1
,
1
}));
EXPECT_EQ
(
poly1
.
DebugString
(),
"polygon2d ( num_points = 4 points = (
vec2d ( x = 1 y = 0 ) "
"polygon2d ( num_points = 4 points = (vec2d ( x = 1 y = 0 ) "
"vec2d ( x = 1 y = 1 ) vec2d ( x = 0 y = 1 ) vec2d ( x = 0 y = "
"0 ) ) convex area = 1 )"
);
EXPECT_TRUE
(
poly1
.
IsPointIn
({
0.5
,
0.5
}));
...
...
modules/common/util/string_util.h
浏览文件 @
ec5f9f09
...
...
@@ -98,6 +98,23 @@ internal::IterPrinter<T*> PrintIter(
return
{
array
,
end
,
delimiter
};
}
/**
* @brief Make conatiners and iterators printable. Similar to PrintIter but
* output the DebugString().
*/
template
<
typename
Container
,
typename
Iter
=
typename
Container
::
const_iterator
>
internal
::
DebugStringIterPrinter
<
Iter
>
PrintDebugStringIter
(
const
Container
&
container
,
const
std
::
string
&
delimiter
=
" "
)
{
return
{
container
.
begin
(),
container
.
end
(),
delimiter
};
}
template
<
typename
Iter
>
internal
::
DebugStringIterPrinter
<
Iter
>
PrintDebugStringIter
(
const
Iter
&
begin
,
const
Iter
&
end
,
const
std
::
string
&
delimiter
=
" "
)
{
return
{
begin
,
end
,
delimiter
};
}
}
// namespace util
}
// namespace common
...
...
@@ -109,6 +126,13 @@ std::ostream& operator<<(
return
printer
.
Print
(
os
);
}
template
<
typename
Iter
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
common
::
util
::
internal
::
DebugStringIterPrinter
<
Iter
>&
printer
)
{
return
printer
.
Print
(
os
);
}
}
// namespace apollo
#endif // MODULES_COMMON_STRING_UTIL_H_
modules/common/util/string_util_internal.h
浏览文件 @
ec5f9f09
...
...
@@ -61,6 +61,34 @@ class IterPrinter {
const
std
::
string
&
delimiter_
;
};
/**
* @brief Iterator printer which output iter->DebugString().
*/
template
<
typename
Iter
>
class
DebugStringIterPrinter
{
public:
DebugStringIterPrinter
(
const
Iter
&
begin
,
const
Iter
&
end
,
const
std
::
string
&
delimiter
)
:
begin_
(
begin
),
end_
(
end
),
delimiter_
(
delimiter
)
{}
std
::
ostream
&
Print
(
std
::
ostream
&
os
)
const
{
for
(
Iter
it
=
begin_
;
it
!=
end_
;
++
it
)
{
// Print first item without delimiter.
if
(
it
==
begin_
)
{
os
<<
it
->
DebugString
();
}
else
{
os
<<
delimiter_
<<
it
->
DebugString
();
}
}
return
os
;
}
private:
const
Iter
begin_
;
const
Iter
end_
;
const
std
::
string
&
delimiter_
;
};
}
// namespace internal
}
// namespace util
}
// namespace common
...
...
modules/planning/common/path/path_data.cc
浏览文件 @
ec5f9f09
...
...
@@ -21,9 +21,9 @@
#include "modules/planning/common/path/path_data.h"
#include <algorithm>
#include <sstream>
#include "modules/common/log.h"
#include "modules/common/util/string_util.h"
#include "modules/planning/common/planning_gflags.h"
#include "modules/planning/common/planning_util.h"
#include "modules/planning/math/double.h"
...
...
@@ -96,21 +96,16 @@ void PathData::Clear() {
}
std
::
string
PathData
::
DebugString
()
const
{
std
::
ostringstream
sout
;
sout
<<
"["
<<
std
::
endl
;
const
auto
&
path_points
=
discretized_path_
.
points
();
for
(
std
::
size_t
i
=
0
;
i
<
path_points
.
size
()
&&
i
<
static_cast
<
std
::
size_t
>
(
FLAGS_trajectory_point_num_for_debug
);
++
i
)
{
if
(
i
>
0
)
{
sout
<<
","
<<
std
::
endl
;
}
sout
<<
path_points
[
i
].
DebugString
();
}
sout
<<
"]"
<<
std
::
endl
;
sout
.
flush
();
return
sout
.
str
();
const
auto
limit
=
std
::
min
(
path_points
.
size
(),
static_cast
<
size_t
>
(
FLAGS_trajectory_point_num_for_debug
));
return
apollo
::
common
::
util
::
StrCat
(
"[
\n
"
,
apollo
::
common
::
util
::
PrintDebugStringIter
(
path_points
.
begin
(),
path_points
.
begin
()
+
limit
,
",
\n
"
),
"]
\n
"
);
}
}
// namespace planning
...
...
modules/planning/common/planning_data.cc
浏览文件 @
ec5f9f09
...
...
@@ -22,6 +22,7 @@
#include <utility>
#include "modules/common/util/string_util.h"
#include "modules/planning/common/path/path_data.h"
#include "modules/planning/proto/planning.pb.h"
...
...
@@ -94,7 +95,6 @@ bool PlanningData::aggregate(const double time_resolution,
if
(
!
path_data_
.
get_path_point_with_path_s
(
speed_point
.
s
(),
&
path_point
))
{
AERROR
<<
"Fail to get path data with s "
<<
speed_point
.
s
()
<<
"path total length "
<<
path_data_
.
discretized_path
().
length
();
;
return
false
;
}
...
...
@@ -110,10 +110,9 @@ bool PlanningData::aggregate(const double time_resolution,
}
std
::
string
PlanningData
::
DebugString
()
const
{
std
::
ostringstream
ss
;
ss
<<
"path_data:"
<<
path_data_
.
DebugString
();
ss
<<
"speed_data:"
<<
speed_data_
.
DebugString
();
return
ss
.
str
();
return
apollo
::
common
::
util
::
StrCat
(
"path_data:"
,
path_data_
.
DebugString
(),
"speed_data:"
,
speed_data_
.
DebugString
());
}
}
// namespace planning
...
...
modules/planning/common/speed/speed_data.cc
浏览文件 @
ec5f9f09
...
...
@@ -21,9 +21,9 @@
#include "modules/planning/common/speed/speed_data.h"
#include <algorithm>
#include <sstream>
#include <utility>
#include "modules/common/util/string_util.h"
#include "modules/planning/common/planning_gflags.h"
#include "modules/planning/common/planning_util.h"
#include "modules/planning/math/double.h"
...
...
@@ -93,19 +93,14 @@ void SpeedData::Clear() {
}
std
::
string
SpeedData
::
DebugString
()
const
{
std
::
ostringstream
sout
;
sout
<<
"["
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
speed_vector_
.
size
())
&&
i
<
FLAGS_trajectory_point_num_for_debug
;
++
i
)
{
if
(
i
>
0
)
{
sout
<<
","
<<
std
::
endl
;
}
sout
<<
speed_vector_
[
i
].
DebugString
();
}
sout
<<
"]"
<<
std
::
endl
;
sout
.
flush
();
return
sout
.
str
();
const
auto
limit
=
std
::
min
(
speed_vector_
.
size
(),
static_cast
<
size_t
>
(
FLAGS_trajectory_point_num_for_debug
));
return
apollo
::
common
::
util
::
StrCat
(
"[
\n
"
,
apollo
::
common
::
util
::
PrintDebugStringIter
(
speed_vector_
.
begin
(),
speed_vector_
.
begin
()
+
limit
,
",
\n
"
),
"]
\n
"
);
}
std
::
uint32_t
SpeedData
::
find_index
(
const
double
t
)
const
{
...
...
modules/planning/reference_line/BUILD
浏览文件 @
ec5f9f09
...
...
@@ -16,6 +16,7 @@ cc_library(
"//modules/common:log"
,
"//modules/common/math"
,
"//modules/common/proto:path_point_proto"
,
"//modules/common/util:string_util"
,
"//modules/map/pnc_map:pnc_path"
,
"//modules/planning/common:planning_gflags"
,
"//modules/planning/math:double"
,
...
...
modules/planning/reference_line/reference_line.cc
浏览文件 @
ec5f9f09
...
...
@@ -21,7 +21,6 @@
#include "modules/planning/reference_line/reference_line.h"
#include <algorithm>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
...
...
@@ -31,6 +30,7 @@
#include "modules/common/log.h"
#include "modules/common/math/angle.h"
#include "modules/common/math/linear_interpolation.h"
#include "modules/common/util/string_util.h"
#include "modules/planning/common/planning_gflags.h"
#include "modules/planning/math/double.h"
...
...
@@ -244,14 +244,13 @@ bool ReferenceLine::is_on_road(const common::SLPoint& sl_point) const {
}
std
::
string
ReferenceLine
::
DebugString
()
const
{
std
::
ostringstream
ss
;
ss
<<
"point num:"
<<
reference_points_
.
size
();
for
(
int32_t
i
=
0
;
i
<
static_cast
<
int32_t
>
(
reference_points_
.
size
())
&&
i
<
FLAGS_trajectory_point_num_for_debug
;
++
i
)
{
ss
<<
reference_points_
[
i
].
DebugString
();
}
return
ss
.
str
();
const
auto
limit
=
std
::
min
(
reference_points_
.
size
(),
static_cast
<
size_t
>
(
FLAGS_trajectory_point_num_for_debug
));
return
apollo
::
common
::
util
::
StrCat
(
"point num:"
,
reference_points_
.
size
(),
apollo
::
common
::
util
::
PrintDebugStringIter
(
reference_points_
.
begin
(),
reference_points_
.
begin
()
+
limit
,
""
));
}
}
// namespace planning
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录