Apollo
10.0
自动驾驶开放平台
interpolation_1d.h
浏览该文件的文档.
1
/* Copyright 2017 The Apollo Authors. All Rights Reserved.
2
3
Licensed under the Apache License, Version 2.0 (the "License");
4
you may not use this file except in compliance with the License.
5
You may obtain a copy of the License at
6
7
http://www.apache.org/licenses/LICENSE-2.0
8
9
Unless required by applicable law or agreed to in writing, software
10
distributed under the License is distributed on an "AS IS" BASIS,
11
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
See the License for the specific language governing permissions and
13
limitations under the License.
14
==============================================================================*/
15
16
#pragma once
17
18
#include <memory>
19
#include <utility>
20
#include <vector>
21
22
#include "Eigen/Core"
23
#include "unsupported/Eigen/Splines"
24
25
namespace
apollo
{
26
namespace
control {
27
28
class
Interpolation1D
{
29
public
:
30
typedef
std::vector<std::pair<double, double>>
DataType
;
31
32
Interpolation1D
() =
default
;
33
34
// Return true if init is ok.
35
bool
Init
(
const
DataType
& xy);
36
37
// Only interpolate x between [x_min, x_max]
38
// For x out of range, start or end y value is returned.
39
double
Interpolate
(
double
x)
const
;
40
41
private
:
42
// Helpers to scale X values down to [0, 1]
43
double
ScaledValue(
double
x)
const
;
44
45
Eigen::RowVectorXd ScaledValues(Eigen::VectorXd
const
& x_vec)
const
;
46
47
double
x_min_ = 0.0;
48
double
x_max_ = 0.0;
49
double
y_start_ = 0.0;
50
double
y_end_ = 0.0;
51
52
// Spline of one-dimensional "points."
53
std::unique_ptr<Eigen::Spline<double, 1>> spline_;
54
};
55
56
}
// namespace control
57
}
// namespace apollo
apollo::control::Interpolation1D
Definition
interpolation_1d.h:28
apollo::control::Interpolation1D::Interpolate
double Interpolate(double x) const
Definition
interpolation_1d.cc:55
apollo::control::Interpolation1D::Interpolation1D
Interpolation1D()=default
apollo::control::Interpolation1D::Init
bool Init(const DataType &xy)
Definition
interpolation_1d.cc:27
apollo::control::Interpolation1D::DataType
std::vector< std::pair< double, double > > DataType
Definition
interpolation_1d.h:30
apollo
class register implement
Definition
arena_queue.h:37
modules
control
control_component
controller_task_base
common
interpolation_1d.h