Apollo 11.0
自动驾驶开放平台
dp_st_cost.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 <string>
24#include <unordered_map>
25#include <utility>
26#include <vector>
27
28#include "modules/common_msgs/basic_msgs/pnc_point.pb.h"
29#include "modules/planning/planning_base/proto/st_drivable_boundary.pb.h"
30#include "modules/planning/tasks/path_time_heuristic/proto/path_time_heuristic.pb.h"
35
36namespace apollo {
37namespace planning {
38
39class DpStCost {
40 public:
41 DpStCost(const DpStSpeedOptimizerConfig& config, const double total_t,
42 const double total_s, const std::vector<const Obstacle*>& obstacles,
43 const STDrivableBoundary& st_drivable_boundary,
44 const common::TrajectoryPoint& init_point);
45
46 double GetObstacleCost(const StGraphPoint& point);
47
48 double GetSpatialPotentialCost(const StGraphPoint& point);
49
50 double GetReferenceCost(const STPoint& point,
51 const STPoint& reference_point) const;
52
53 double GetSpeedCost(const STPoint& first, const STPoint& second,
54 const double speed_limit,
55 const double cruise_speed) const;
56
57 double GetAccelCostByTwoPoints(const double pre_speed, const STPoint& first,
58 const STPoint& second);
59 double GetAccelCostByThreePoints(const STPoint& first, const STPoint& second,
60 const STPoint& third);
61
62 double GetJerkCostByTwoPoints(const double pre_speed, const double pre_acc,
63 const STPoint& pre_point,
64 const STPoint& curr_point);
65 double GetJerkCostByThreePoints(const double first_speed,
66 const STPoint& first_point,
67 const STPoint& second_point,
68 const STPoint& third_point);
69
70 double GetJerkCostByFourPoints(const STPoint& first, const STPoint& second,
71 const STPoint& third, const STPoint& fourth);
72
73 private:
74 double GetAccelCost(const double accel);
75 double JerkCost(const double jerk);
76
77 void AddToKeepClearRange(const std::vector<const Obstacle*>& obstacles);
78 static void SortAndMergeRange(
79 std::vector<std::pair<double, double>>* keep_clear_range_);
80 bool InKeepClearRange(double s) const;
81
82 const DpStSpeedOptimizerConfig& config_;
83 const std::vector<const Obstacle*>& obstacles_;
84
85 STDrivableBoundary st_drivable_boundary_;
86
87 const common::TrajectoryPoint& init_point_;
88
89 double unit_t_ = 0.0;
90 double total_s_ = 0.0;
91
92 std::unordered_map<std::string, int> boundary_map_;
93 std::vector<std::vector<std::pair<double, double>>> boundary_cost_;
94
95 std::vector<std::pair<double, double>> keep_clear_range_;
96
97 std::array<double, 200> accel_cost_;
98 std::array<double, 400> jerk_cost_;
99};
100
101} // namespace planning
102} // namespace apollo
double GetSpatialPotentialCost(const StGraphPoint &point)
double GetAccelCostByTwoPoints(const double pre_speed, const STPoint &first, const STPoint &second)
double GetJerkCostByThreePoints(const double first_speed, const STPoint &first_point, const STPoint &second_point, const STPoint &third_point)
double GetJerkCostByTwoPoints(const double pre_speed, const double pre_acc, const STPoint &pre_point, const STPoint &curr_point)
double GetReferenceCost(const STPoint &point, const STPoint &reference_point) const
double GetSpeedCost(const STPoint &first, const STPoint &second, const double speed_limit, const double cruise_speed) const
double GetJerkCostByFourPoints(const STPoint &first, const STPoint &second, const STPoint &third, const STPoint &fourth)
double GetAccelCostByThreePoints(const STPoint &first, const STPoint &second, const STPoint &third)
double GetObstacleCost(const StGraphPoint &point)
Planning module main class.
class register implement
Definition arena_queue.h:37