Apollo 11.0
自动驾驶开放平台
trajectory_evaluator.h
浏览该文件的文档.
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 <functional>
24#include <memory>
25#include <queue>
26#include <utility>
27#include <vector>
28
29#include "modules/planning/planning_base/proto/lattice_structure.pb.h"
30#include "modules/planning/planning_base/proto/planning_config.pb.h"
31
34
35namespace apollo {
36namespace planning {
37
39 // normal use
40 typedef std::pair<
41 std::pair<std::shared_ptr<Curve1d>, std::shared_ptr<Curve1d>>, double>
42 PairCost;
43
44 // auto tuning
45 typedef std::pair<
46 std::pair<std::shared_ptr<Curve1d>, std::shared_ptr<Curve1d>>,
47 std::pair<std::vector<double>, double>>
48 PairCostWithComponents;
49
50 public:
52 const std::array<double, 3>& init_s,
53 const PlanningTarget& planning_target,
54 const std::vector<std::shared_ptr<Curve1d>>& lon_trajectories,
55 const std::vector<std::shared_ptr<Curve1d>>& lat_trajectories,
56 std::shared_ptr<PathTimeGraph> path_time_graph,
57 std::shared_ptr<std::vector<apollo::common::PathPoint>> reference_line);
58
59 virtual ~TrajectoryEvaluator() = default;
60
61 bool has_more_trajectory_pairs() const;
62
63 size_t num_of_trajectory_pairs() const;
64
65 std::pair<std::shared_ptr<Curve1d>, std::shared_ptr<Curve1d>>
67
68 double top_trajectory_pair_cost() const;
69
70 std::vector<double> top_trajectory_pair_component_cost() const;
71
72 private:
73 double Evaluate(const PlanningTarget& planning_target,
74 const std::shared_ptr<Curve1d>& lon_trajectory,
75 const std::shared_ptr<Curve1d>& lat_trajectory,
76 std::vector<double>* cost_components = nullptr) const;
77
78 double LatOffsetCost(const std::shared_ptr<Curve1d>& lat_trajectory,
79 const std::vector<double>& s_values) const;
80
81 double LatComfortCost(const std::shared_ptr<Curve1d>& lon_trajectory,
82 const std::shared_ptr<Curve1d>& lat_trajectory) const;
83
84 double LonComfortCost(const std::shared_ptr<Curve1d>& lon_trajectory) const;
85
86 double LonCollisionCost(const std::shared_ptr<Curve1d>& lon_trajectory) const;
87
88 double LonObjectiveCost(const std::shared_ptr<Curve1d>& lon_trajectory,
89 const PlanningTarget& planning_target,
90 const std::vector<double>& ref_s_dot) const;
91
92 double CentripetalAccelerationCost(
93 const std::shared_ptr<Curve1d>& lon_trajectory) const;
94
95 std::vector<double> ComputeLongitudinalGuideVelocity(
96 const PlanningTarget& planning_target) const;
97
98 bool InterpolateDenseStPoints(
99 const std::vector<apollo::common::SpeedPoint>& st_points, double t,
100 double* traj_s) const;
101
102 struct CostComparator
103 : public std::binary_function<const PairCost&, const PairCost&, bool> {
104 bool operator()(const PairCost& left, const PairCost& right) const {
105 return left.second > right.second;
106 }
107 };
108
109 std::priority_queue<PairCost, std::vector<PairCost>, CostComparator>
110 cost_queue_;
111
112 std::shared_ptr<PathTimeGraph> path_time_graph_;
113
114 std::shared_ptr<std::vector<apollo::common::PathPoint>> reference_line_;
115
116 std::vector<std::vector<std::pair<double, double>>> path_time_intervals_;
117
118 std::array<double, 3> init_s_;
119
120 std::vector<double> reference_s_dot_;
121};
122
123} // namespace planning
124} // namespace apollo
std::vector< double > top_trajectory_pair_component_cost() const
std::pair< std::shared_ptr< Curve1d >, std::shared_ptr< Curve1d > > next_top_trajectory_pair()
Planning module main class.
class register implement
Definition arena_queue.h:37