提交 81ae48db 编写于 作者: Y YajiaZhang 提交者: Jiangtao Hu

common: fixed a couple of problems due to code migration

上级 ba9a80c7
......@@ -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",
......
/******************************************************************************
* 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 <array>
#include <utility>
......@@ -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<T, N>::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_
/******************************************************************************
* 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 <cmath>
#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;
}
......
/******************************************************************************
* 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 <cmath>
#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_
......@@ -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",
],
......
......@@ -16,25 +16,13 @@
#include "modules/planning/common/planning_util.h"
#include <array>
#include <cmath>
#include <memory>
#include <utility>
#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() {
......
......@@ -37,14 +37,4 @@ cc_library(
],
)
cc_library(
name = "hermite_spline",
hdrs = [
"hermite_spline.h",
],
deps = [
"//modules/common:log",
],
)
cpplint()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册