Skip to content

Commit 81ae48d

Browse files
YajiaZhangycool
authored andcommitted
common: fixed a couple of problems due to code migration
1 parent ba9a80c commit 81ae48d

File tree

7 files changed

+54
-51
lines changed

7 files changed

+54
-51
lines changed

modules/common/math/BUILD

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,22 @@ cc_library(
186186
],
187187
)
188188

189+
cc_library(
190+
name = "nonlinear_interpolation",
191+
srcs = [
192+
"nonlinear_interpolation.cc",
193+
],
194+
hdrs = [
195+
"nonlinear_interpolation.h",
196+
],
197+
deps = [
198+
":geometry",
199+
":hermite_spline",
200+
":integral",
201+
"//modules/common/proto:pnc_point_proto",
202+
],
203+
)
204+
189205
cc_library(
190206
name = "integral",
191207
srcs = [
@@ -244,6 +260,16 @@ cc_library(
244260
],
245261
)
246262

263+
cc_library(
264+
name = "hermite_spline",
265+
hdrs = [
266+
"hermite_spline.h",
267+
],
268+
deps = [
269+
"//modules/common:log",
270+
],
271+
)
272+
247273
cc_test(
248274
name = "mpc_test",
249275
size = "small",

modules/planning/math/hermite_spline.h renamed to modules/common/math/hermite_spline.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/******************************************************************************
2-
* Copyright 2017 The Apollo Authors. All Rights Reserved.
2+
* Copyright 2018 The Apollo Authors. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,16 +18,17 @@
1818
* @file
1919
**/
2020

21-
#ifndef MODULES_PLANNING_MATH_HERMITE_SPLINE_H_
22-
#define MODULES_PLANNING_MATH_HERMITE_SPLINE_H_
21+
#ifndef MODULES_COMMON_MATH_HERMITE_SPLINE_H_
22+
#define MODULES_COMMON_MATH_HERMITE_SPLINE_H_
2323

2424
#include <array>
2525
#include <utility>
2626

2727
#include "modules/common/log.h"
2828

2929
namespace apollo {
30-
namespace planning {
30+
namespace common {
31+
namespace math {
3132

3233
// Hermite spline implementation that works for 1d and 2d space interpolation.
3334
// Valid input type T: double, Eigen::Vector2d
@@ -200,7 +201,8 @@ inline T HermiteSpline<T, N>::Evaluate(const std::uint32_t order,
200201
return T();
201202
}
202203

203-
} // namespace planning
204+
} // namespace math
205+
} // namespace common
204206
} // namespace apollo
205207

206-
#endif // MODULES_PLANNING_MATH_HERMITE_SPLINE_H_
208+
#endif // MODULES_COMMON_MATH_HERMITE_SPLINE_H_

modules/common/math/polynomial_interpolation.cc renamed to modules/common/math/nonlinear_interpolation.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/******************************************************************************
2-
* Copyright 2017 The Apollo Authors. All Rights Reserved.
2+
* Copyright 2018 The Apollo Authors. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,20 +13,21 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*****************************************************************************/
16-
17-
#include "modules/common/math/polynomial_interpolation.h"
16+
#include "modules/common/math/nonlinear_interpolation.h"
1817

1918
#include <cmath>
2019

2120
#include "modules/common/log.h"
21+
#include "modules/common/math/hermite_spline.h"
22+
#include "modules/common/math/integral.h"
2223
#include "modules/common/math/math_utils.h"
2324

2425
namespace apollo {
2526
namespace common {
2627
namespace math {
2728

28-
PathPoint PolynomialInterpolate(const PathPoint &p0, const PathPoint &p1,
29-
const double s) {
29+
PathPoint SplineInterpolate(const PathPoint &p0, const PathPoint &p1,
30+
const double s) {
3031
double s0 = p0.s();
3132
double s1 = p1.s();
3233
CHECK(s0 <= s && s <= s1);
@@ -64,9 +65,9 @@ PathPoint PolynomialInterpolate(const PathPoint &p0, const PathPoint &p1,
6465
return p;
6566
}
6667

67-
TrajectoryPoint PolynomialInterpolate(const TrajectoryPoint &tp0,
68-
const TrajectoryPoint &tp1,
69-
const double t) {
68+
TrajectoryPoint SplineInterpolate(const TrajectoryPoint &tp0,
69+
const TrajectoryPoint &tp1,
70+
const double t) {
7071
if (std::fabs(tp1.path_point().s() - tp0.path_point().s()) < 1.0e-4) {
7172
return tp1;
7273
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/******************************************************************************
2-
* Copyright 2017 The Apollo Authors. All Rights Reserved.
2+
* Copyright 2018 The Apollo Authors. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,33 +16,32 @@
1616

1717
/**
1818
* @file
19-
* @brief Linear interpolation functions.
19+
* @brief Nonlinear interpolation functions.
2020
*/
2121

22-
#ifndef MODULES_COMMON_MATH_LINEAR_INTERPOLATION_H_
23-
#define MODULES_COMMON_MATH_LINEAR_INTERPOLATION_H_
22+
#ifndef MODULES_COMMON_MATH_NONLINEAR_INTERPOLATION_H_
23+
#define MODULES_COMMON_MATH_NONLINEAR_INTERPOLATION_H_
2424

25-
#include <cmath>
26-
27-
#include "modules/common/log.h"
2825
#include "modules/common/proto/pnc_point.pb.h"
2926

3027
/**
3128
* @namespace apollo::common::math
3229
* @brief apollo::common::math
3330
*/
31+
3432
namespace apollo {
3533
namespace common {
3634
namespace math {
3735

38-
SLPoint PolynomialInterpolate(const SLPoint &start, const SLPoint &end,
39-
const double weight);
36+
PathPoint SplineInterpolate(const PathPoint &p0, const PathPoint &p1,
37+
const double s);
4038

41-
PathPoint PolynomialInterpolate(const PathPoint &p0, const PathPoint &p1,
42-
const double s);
39+
TrajectoryPoint SplineInterpolate(const TrajectoryPoint &tp0,
40+
const TrajectoryPoint &tp1,
41+
const double t);
4342

4443
} // namespace math
4544
} // namespace common
4645
} // namespace apollo
4746

48-
#endif // MODULES_COMMON_MATH_LINEAR_INTERPOLATION_H_
47+
#endif // MODULES_COMMON_MATH_NONLINEAR_INTERPOLATION_H_

modules/planning/common/BUILD

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ cc_library(
137137
deps = [
138138
":planning_gflags",
139139
"//modules/common/adapters:adapter_manager",
140-
"//modules/common/math",
141-
"//modules/common/proto:pnc_point_proto",
142-
"//modules/planning/math:hermite_spline",
143140
"//modules/planning/proto:planning_proto",
144141
"//modules/planning/proto:planning_status_proto",
145142
],

modules/planning/common/planning_util.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,13 @@
1616

1717
#include "modules/planning/common/planning_util.h"
1818

19-
#include <array>
20-
#include <cmath>
21-
#include <memory>
22-
#include <utility>
23-
2419
#include "modules/common/adapters/adapter_manager.h"
25-
#include "modules/common/math/integral.h"
26-
#include "modules/common/math/linear_interpolation.h"
27-
#include "modules/common/math/math_utils.h"
2820
#include "modules/planning/common/planning_gflags.h"
29-
#include "modules/planning/math/hermite_spline.h"
3021

3122
namespace apollo {
3223
namespace planning {
3324
namespace util {
3425

35-
using common::PathPoint;
36-
using common::SpeedPoint;
37-
using common::TrajectoryPoint;
3826
using common::adapter::AdapterManager;
3927

4028
PlanningStatus *GetPlanningStatus() {

modules/planning/math/BUILD

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,4 @@ cc_library(
3737
],
3838
)
3939

40-
cc_library(
41-
name = "hermite_spline",
42-
hdrs = [
43-
"hermite_spline.h",
44-
],
45-
deps = [
46-
"//modules/common:log",
47-
],
48-
)
49-
5040
cpplint()

0 commit comments

Comments
 (0)