Apollo 11.0
自动驾驶开放平台
autotuning_speed_mlp_model.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 *****************************************************************************/
17
19
20namespace apollo {
21namespace planning {
22
26namespace {
27constexpr double kMaxFollow = 100.0;
28constexpr double kMaxOvertake = 100.0;
29constexpr double kMaxStop = 60.0;
30constexpr double kMaxNudge = 60.0;
31constexpr double kMaxNudgeLateralDistance = 10.0;
32constexpr double kMaxSidePassDistance = 100.0;
33} // namespace
34
40
42 const autotuning::TrajectoryFeature& trajectory_feature) const {
43 return 0.0;
44}
45
47 const autotuning::TrajectoryPointwiseFeature& point_feature) const {
48 return 0.0;
49}
50
51void AutotuningSpeedMLPModel::FlattenFeatures(
52 const autotuning::TrajectoryFeature& feature,
53 Eigen::MatrixXd* const flat_feature) const {
54 int row_count = feature.point_feature_size();
55 int col_count = 21;
56 flat_feature->resize(row_count, col_count);
57
58 for (int i = 0; i < row_count; ++i) {
59 FlattenFeatures(feature.point_feature(i).speed_input_feature(), i,
60 flat_feature);
61 }
62}
63
64void AutotuningSpeedMLPModel::FlattenFeatures(
65 const autotuning::SpeedPointwiseFeature& speed_point_feature, const int row,
66 Eigen::MatrixXd* const flat_feature) const {
67 double v = speed_point_feature.v();
68 double acc = speed_point_feature.acc();
69 double jerk = speed_point_feature.jerk();
70 double speed_limit = speed_point_feature.speed_limit();
71
72 double lateral_acc = speed_point_feature.lateral_acc();
73 // has collision , collision = 1, else 0
74 double collision = 0.0;
75 // obstacle feature, looping to find among all obstacle
76 double follow_distance = kMaxFollow;
77 double follow_v_rel = 0.0;
78 double overtake_distance = kMaxOvertake;
79 double overtake_v_rel = 0.0;
80 double stop_distance = kMaxStop;
81 double stop_v_rel = 0.0;
82 double virtual_distance = kMaxStop;
83 double virtual_v_rel = 0.0;
84 double nudge_distance = kMaxNudge;
85 double nudge_v_rel = 0.0;
86 double nudge_lateral_distance = kMaxNudgeLateralDistance;
87 double sidepass_front_v_rel = 0.0;
88 double sidepass_front_distance = kMaxSidePassDistance;
89 double sidepass_rear_v_rel = 0.0;
90 double sidepass_rear_distance = kMaxSidePassDistance;
91
92 // looping obstacles to find the value minimize the distance
93 for (int i = 0; i < speed_point_feature.follow_obs_feature_size(); ++i) {
94 const auto& follow_obs_feature = speed_point_feature.follow_obs_feature(i);
95 if (follow_distance > follow_obs_feature.longitudinal_distance()) {
96 follow_distance = follow_obs_feature.longitudinal_distance();
97 follow_v_rel = follow_obs_feature.relative_v();
98 }
99 }
100 // looping obstacles to find the value minimize the distance
101 for (int i = 0; i < speed_point_feature.overtake_obs_feature_size(); ++i) {
102 const auto& overtake_obs_feature =
103 speed_point_feature.overtake_obs_feature(i);
104 if (overtake_distance > overtake_obs_feature.longitudinal_distance()) {
105 overtake_distance = overtake_obs_feature.longitudinal_distance();
106 overtake_v_rel = overtake_obs_feature.relative_v();
107 }
108 }
109 // looping obstacles to find the value minimize the distance
110 for (int i = 0; i < speed_point_feature.stop_obs_feature_size(); ++i) {
111 const auto& stop_obs_feature = speed_point_feature.stop_obs_feature(i);
112 if (stop_distance > stop_obs_feature.longitudinal_distance()) {
113 stop_distance = stop_obs_feature.longitudinal_distance();
114 stop_v_rel = stop_obs_feature.relative_v();
115 }
116 }
117 // looping obstacles to find the value minimize the distance
118 for (int i = 0; i < speed_point_feature.virtual_obs_feature_size(); ++i) {
119 const auto& virtual_obs_feature =
120 speed_point_feature.virtual_obs_feature(i);
121 if (virtual_distance > virtual_obs_feature.longitudinal_distance()) {
122 virtual_distance = virtual_obs_feature.longitudinal_distance();
123 virtual_v_rel = virtual_obs_feature.relative_v();
124 }
125 }
126 // looping obstacles to find the value minimize the distance
127 for (int i = 0; i < speed_point_feature.nudge_obs_feature_size(); ++i) {
128 const auto& nudge_obs_feature = speed_point_feature.nudge_obs_feature(i);
129 if (nudge_distance > nudge_obs_feature.longitudinal_distance()) {
130 nudge_distance = nudge_obs_feature.longitudinal_distance();
131 nudge_v_rel = nudge_obs_feature.relative_v();
132 nudge_lateral_distance = nudge_obs_feature.lateral_distance();
133 }
134 }
135 // looping obstacles to find the value minimize the distance
136 for (int i = 0; i < speed_point_feature.sidepass_front_obs_feature_size();
137 ++i) {
138 const auto& sidepass_front_obs_feature =
139 speed_point_feature.sidepass_front_obs_feature(i);
140 if (sidepass_front_distance >
141 sidepass_front_obs_feature.longitudinal_distance()) {
142 sidepass_front_distance =
143 sidepass_front_obs_feature.longitudinal_distance();
144 sidepass_front_v_rel = sidepass_front_obs_feature.relative_v();
145 }
146 }
147 // looping obstacles to find the value minimize the distance
148 for (int i = 0; i < speed_point_feature.sidepass_rear_obs_feature_size();
149 ++i) {
150 const auto& sidepass_rear_obs_feature =
151 speed_point_feature.sidepass_rear_obs_feature(i);
152 if (sidepass_rear_distance >
153 sidepass_rear_obs_feature.longitudinal_distance()) {
154 sidepass_rear_distance =
155 sidepass_rear_obs_feature.longitudinal_distance();
156 sidepass_rear_v_rel = sidepass_rear_obs_feature.relative_v();
157 }
158 }
159
160 (*flat_feature)(row, 0) = v;
161 (*flat_feature)(row, 1) = speed_limit;
162 (*flat_feature)(row, 2) = acc;
163 (*flat_feature)(row, 3) = jerk;
164 (*flat_feature)(row, 4) = lateral_acc;
165 (*flat_feature)(row, 5) = collision;
166 (*flat_feature)(row, 6) = follow_distance;
167 (*flat_feature)(row, 7) = follow_v_rel;
168 (*flat_feature)(row, 8) = overtake_distance;
169 (*flat_feature)(row, 9) = overtake_v_rel;
170 (*flat_feature)(row, 10) = nudge_distance;
171 (*flat_feature)(row, 11) = nudge_v_rel;
172 (*flat_feature)(row, 12) = nudge_lateral_distance;
173 (*flat_feature)(row, 13) = stop_distance;
174 (*flat_feature)(row, 14) = stop_v_rel;
175 (*flat_feature)(row, 15) = virtual_distance;
176 (*flat_feature)(row, 16) = virtual_v_rel;
177 (*flat_feature)(row, 17) = sidepass_front_distance;
178 (*flat_feature)(row, 18) = sidepass_front_v_rel;
179 (*flat_feature)(row, 19) = sidepass_rear_distance;
180 (*flat_feature)(row, 20) = sidepass_rear_v_rel;
181}
182
183} // namespace planning
184} // namespace apollo
A general class to denote the return status of an API call.
Definition status.h:43
static Status OK()
generate a success status.
Definition status.h:60
std::unique_ptr< AutotuningMLPModel > mlp_model_
: stored autotuning mlp model
std::unique_ptr< AutotuningFeatureBuilder > feature_builder_
: build the mlp cost functional for speed profile based on trajectory raw feature
double Evaluate(const autotuning::TrajectoryFeature &trajectory_feature) const override
: evaluate by trajectory
common::Status SetParams() override
set mlp model as well as feature builder
Planning module main class.
class register implement
Definition arena_queue.h:37