Apollo 10.0
自动驾驶开放平台
interpolation_1d.h
浏览该文件的文档.
1/* Copyright 2017 The Apollo Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations 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
25namespace apollo {
26namespace control {
27
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
double Interpolate(double x) const
bool Init(const DataType &xy)
std::vector< std::pair< double, double > > DataType
class register implement
Definition arena_queue.h:37