Apollo 11.0
自动驾驶开放平台
trajectory_analyzer_extend.cc
浏览该文件的文档.
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
18
19#include <algorithm>
20#include <cmath>
21#include <utility>
22
23#include "Eigen/Core"
24
25#include "cyber/common/log.h"
30
33
34namespace apollo {
35namespace control {
36
38 const TrajectoryPoint &ref_point,
39 const double &relative_station) const {
40 std::vector<std::pair<const common::TrajectoryPoint, double>> relative_trajectory_point;
41 relative_trajectory_point.push_back(std::make_pair(ref_point, relative_station));
42 auto func_comp
43 = [](const TrajectoryPoint &point,
44 const std::vector<std::pair<const common::TrajectoryPoint, double>> &relative_trajectory_point) {
45 return point.path_point().s()
46 < relative_trajectory_point[0].first.path_point().s() + relative_trajectory_point[0].second;
47 };
48
49 auto it_low = std::lower_bound(
50 trajectory_points_.begin(), trajectory_points_.end(), relative_trajectory_point, func_comp);
51
52 if (it_low == trajectory_points_.begin()) {
53 return trajectory_points_.front();
54 }
55
56 if (it_low == trajectory_points_.end()) {
57 return trajectory_points_.back();
58 }
59
60 if (FLAGS_query_forward_station_point_only) {
61 return *it_low;
62 } else {
63 auto it_lower = it_low - 1;
64 if (it_low->path_point().s() - ref_point.path_point().s()
65 < ref_point.path_point().s() - it_lower->path_point().s()) {
66 return *it_low;
67 }
68 return *it_lower;
69 }
70}
71
72} // namespace control
73} // namespace apollo
common::TrajectoryPoint QueryNearestPointByRelativeStation(const common::TrajectoryPoint &ref_point, const double &relative_station) const
query a point of trajectory that its s distance for reference trajectory point is closest to the give...
std::vector< common::TrajectoryPoint > trajectory_points_
Math-related util functions.
Linear interpolation functions.
class register implement
Definition arena_queue.h:37
Search-related functions.