From 81ae48db50ecc8154bec8b4adce524dde9791cab Mon Sep 17 00:00:00 2001 From: YajiaZhang Date: Tue, 17 Apr 2018 14:48:56 -0700 Subject: [PATCH] common: fixed a couple of problems due to code migration --- modules/common/math/BUILD | 26 +++++++++++++++++++ .../math/hermite_spline.h | 14 +++++----- ...polation.cc => nonlinear_interpolation.cc} | 17 ++++++------ ...erpolation.h => nonlinear_interpolation.h} | 23 ++++++++-------- modules/planning/common/BUILD | 3 --- modules/planning/common/planning_util.cc | 12 --------- modules/planning/math/BUILD | 10 ------- 7 files changed, 54 insertions(+), 51 deletions(-) rename modules/{planning => common}/math/hermite_spline.h (96%) rename modules/common/math/{polynomial_interpolation.cc => nonlinear_interpolation.cc} (89%) rename modules/common/math/{polynomial_interpolation.h => nonlinear_interpolation.h} (63%) diff --git a/modules/common/math/BUILD b/modules/common/math/BUILD index e66e05f3a1..3600dec81b 100644 --- a/modules/common/math/BUILD +++ b/modules/common/math/BUILD @@ -186,6 +186,22 @@ cc_library( ], ) +cc_library( + name = "nonlinear_interpolation", + srcs = [ + "nonlinear_interpolation.cc", + ], + hdrs = [ + "nonlinear_interpolation.h", + ], + deps = [ + ":geometry", + ":hermite_spline", + ":integral", + "//modules/common/proto:pnc_point_proto", + ], +) + cc_library( name = "integral", srcs = [ @@ -244,6 +260,16 @@ cc_library( ], ) +cc_library( + name = "hermite_spline", + hdrs = [ + "hermite_spline.h", + ], + deps = [ + "//modules/common:log", + ], +) + cc_test( name = "mpc_test", size = "small", diff --git a/modules/planning/math/hermite_spline.h b/modules/common/math/hermite_spline.h similarity index 96% rename from modules/planning/math/hermite_spline.h rename to modules/common/math/hermite_spline.h index 83496be105..cc751e53f0 100644 --- a/modules/planning/math/hermite_spline.h +++ b/modules/common/math/hermite_spline.h @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright 2017 The Apollo Authors. All Rights Reserved. + * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * @file **/ -#ifndef MODULES_PLANNING_MATH_HERMITE_SPLINE_H_ -#define MODULES_PLANNING_MATH_HERMITE_SPLINE_H_ +#ifndef MODULES_COMMON_MATH_HERMITE_SPLINE_H_ +#define MODULES_COMMON_MATH_HERMITE_SPLINE_H_ #include #include @@ -27,7 +27,8 @@ #include "modules/common/log.h" namespace apollo { -namespace planning { +namespace common { +namespace math { // Hermite spline implementation that works for 1d and 2d space interpolation. // Valid input type T: double, Eigen::Vector2d @@ -200,7 +201,8 @@ inline T HermiteSpline::Evaluate(const std::uint32_t order, return T(); } -} // namespace planning +} // namespace math +} // namespace common } // namespace apollo -#endif // MODULES_PLANNING_MATH_HERMITE_SPLINE_H_ +#endif // MODULES_COMMON_MATH_HERMITE_SPLINE_H_ diff --git a/modules/common/math/polynomial_interpolation.cc b/modules/common/math/nonlinear_interpolation.cc similarity index 89% rename from modules/common/math/polynomial_interpolation.cc rename to modules/common/math/nonlinear_interpolation.cc index 7b685c3b02..7a0e755cde 100644 --- a/modules/common/math/polynomial_interpolation.cc +++ b/modules/common/math/nonlinear_interpolation.cc @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright 2017 The Apollo Authors. All Rights Reserved. + * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,20 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ - -#include "modules/common/math/polynomial_interpolation.h" +#include "modules/common/math/nonlinear_interpolation.h" #include #include "modules/common/log.h" +#include "modules/common/math/hermite_spline.h" +#include "modules/common/math/integral.h" #include "modules/common/math/math_utils.h" namespace apollo { namespace common { namespace math { -PathPoint PolynomialInterpolate(const PathPoint &p0, const PathPoint &p1, - const double s) { +PathPoint SplineInterpolate(const PathPoint &p0, const PathPoint &p1, + const double s) { double s0 = p0.s(); double s1 = p1.s(); CHECK(s0 <= s && s <= s1); @@ -64,9 +65,9 @@ PathPoint PolynomialInterpolate(const PathPoint &p0, const PathPoint &p1, return p; } -TrajectoryPoint PolynomialInterpolate(const TrajectoryPoint &tp0, - const TrajectoryPoint &tp1, - const double t) { +TrajectoryPoint SplineInterpolate(const TrajectoryPoint &tp0, + const TrajectoryPoint &tp1, + const double t) { if (std::fabs(tp1.path_point().s() - tp0.path_point().s()) < 1.0e-4) { return tp1; } diff --git a/modules/common/math/polynomial_interpolation.h b/modules/common/math/nonlinear_interpolation.h similarity index 63% rename from modules/common/math/polynomial_interpolation.h rename to modules/common/math/nonlinear_interpolation.h index 7d9091c6c7..cbb115dfae 100644 --- a/modules/common/math/polynomial_interpolation.h +++ b/modules/common/math/nonlinear_interpolation.h @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright 2017 The Apollo Authors. All Rights Reserved. + * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,33 +16,32 @@ /** * @file - * @brief Linear interpolation functions. + * @brief Nonlinear interpolation functions. */ -#ifndef MODULES_COMMON_MATH_LINEAR_INTERPOLATION_H_ -#define MODULES_COMMON_MATH_LINEAR_INTERPOLATION_H_ +#ifndef MODULES_COMMON_MATH_NONLINEAR_INTERPOLATION_H_ +#define MODULES_COMMON_MATH_NONLINEAR_INTERPOLATION_H_ -#include - -#include "modules/common/log.h" #include "modules/common/proto/pnc_point.pb.h" /** * @namespace apollo::common::math * @brief apollo::common::math */ + namespace apollo { namespace common { namespace math { -SLPoint PolynomialInterpolate(const SLPoint &start, const SLPoint &end, - const double weight); +PathPoint SplineInterpolate(const PathPoint &p0, const PathPoint &p1, + const double s); -PathPoint PolynomialInterpolate(const PathPoint &p0, const PathPoint &p1, - const double s); +TrajectoryPoint SplineInterpolate(const TrajectoryPoint &tp0, + const TrajectoryPoint &tp1, + const double t); } // namespace math } // namespace common } // namespace apollo -#endif // MODULES_COMMON_MATH_LINEAR_INTERPOLATION_H_ +#endif // MODULES_COMMON_MATH_NONLINEAR_INTERPOLATION_H_ diff --git a/modules/planning/common/BUILD b/modules/planning/common/BUILD index a604f66371..a9b5f197dc 100644 --- a/modules/planning/common/BUILD +++ b/modules/planning/common/BUILD @@ -137,9 +137,6 @@ cc_library( deps = [ ":planning_gflags", "//modules/common/adapters:adapter_manager", - "//modules/common/math", - "//modules/common/proto:pnc_point_proto", - "//modules/planning/math:hermite_spline", "//modules/planning/proto:planning_proto", "//modules/planning/proto:planning_status_proto", ], diff --git a/modules/planning/common/planning_util.cc b/modules/planning/common/planning_util.cc index 1de5c4e7f5..862217e734 100644 --- a/modules/planning/common/planning_util.cc +++ b/modules/planning/common/planning_util.cc @@ -16,25 +16,13 @@ #include "modules/planning/common/planning_util.h" -#include -#include -#include -#include - #include "modules/common/adapters/adapter_manager.h" -#include "modules/common/math/integral.h" -#include "modules/common/math/linear_interpolation.h" -#include "modules/common/math/math_utils.h" #include "modules/planning/common/planning_gflags.h" -#include "modules/planning/math/hermite_spline.h" namespace apollo { namespace planning { namespace util { -using common::PathPoint; -using common::SpeedPoint; -using common::TrajectoryPoint; using common::adapter::AdapterManager; PlanningStatus *GetPlanningStatus() { diff --git a/modules/planning/math/BUILD b/modules/planning/math/BUILD index 1e5b744564..6ec4aaf46b 100644 --- a/modules/planning/math/BUILD +++ b/modules/planning/math/BUILD @@ -37,14 +37,4 @@ cc_library( ], ) -cc_library( - name = "hermite_spline", - hdrs = [ - "hermite_spline.h", - ], - deps = [ - "//modules/common:log", - ], -) - cpplint() -- GitLab