Apollo  6.0
Open source self driving car software
interpolation_2d.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
21 #pragma once
22 
23 #include <map>
24 #include <memory>
25 #include <tuple>
26 #include <utility>
27 #include <vector>
28 
33 namespace apollo {
34 namespace control {
41  public:
42  typedef std::vector<std::tuple<double, double, double>> DataType;
43  typedef std::pair<double, double> KeyType;
44 
45  Interpolation2D() = default;
46 
52  bool Init(const DataType &xyz);
53 
59  double Interpolate(const KeyType &xy) const;
60 
61  private:
62  double InterpolateYz(const std::map<double, double> &yz_table,
63  double y) const;
64 
65  double InterpolateValue(const double value_before, const double dist_before,
66  const double value_after,
67  const double dist_after) const;
68 
69  std::map<double, std::map<double, double>> xyz_;
70 };
71 
72 } // namespace control
73 } // namespace apollo
double Interpolate(const KeyType &xy) const
linear interpolate from 2D key (double, double) to one double value.
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool Init(const DataType &xyz)
initialize Interpolation2D internal table
linear interpolation from key (double, double) to one double value.
Definition: interpolation_2d.h:40
std::vector< std::tuple< double, double, double > > DataType
Definition: interpolation_2d.h:42
std::pair< double, double > KeyType
Definition: interpolation_2d.h:43