Apollo 10.0
自动驾驶开放平台
validation_checker.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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
21
22namespace apollo {
23namespace prediction {
24
25using common::TrajectoryPoint;
26
28 const LaneSequence& lane_sequence, const double speed) {
29 double centripetal_acc_cost_sum = 0.0;
30 double centripetal_acc_cost_sqr_sum = 0.0;
31 for (int i = 0; i < lane_sequence.path_point_size(); ++i) {
32 const auto& path_point = lane_sequence.path_point(i);
33 double centripetal_acc = speed * speed * std::fabs(path_point.kappa());
34 double centripetal_acc_cost =
35 centripetal_acc / FLAGS_centripedal_acc_threshold;
36 centripetal_acc_cost_sum += centripetal_acc_cost;
37 centripetal_acc_cost_sqr_sum += centripetal_acc_cost * centripetal_acc_cost;
38 }
39 double mean_cost = centripetal_acc_cost_sqr_sum /
40 (centripetal_acc_cost_sum + FLAGS_double_precision);
41 return std::exp(-FLAGS_centripetal_acc_coeff * mean_cost);
42}
43
45 const std::vector<TrajectoryPoint>& trajectory_points) {
46 for (size_t i = 0; i + 1 < trajectory_points.size(); ++i) {
47 const auto& p0 = trajectory_points[i];
48 const auto& p1 = trajectory_points[i + 1];
49 double time_diff = std::abs(p1.relative_time() - p0.relative_time());
50 if (time_diff < FLAGS_double_precision) {
51 continue;
52 }
53
54 double theta_diff = std::abs(common::math::NormalizeAngle(
55 p1.path_point().theta() - p0.path_point().theta()));
56 double v = (p0.v() + p1.v()) * 0.5;
57 double angular_a = v * theta_diff / time_diff;
58 if (angular_a > FLAGS_centripedal_acc_threshold) {
59 return false;
60 }
61 }
62 return true;
63}
64
66 const TrajectoryPoint& trajectory_point) {
67 return trajectory_point.has_path_point() &&
68 (!std::isnan(trajectory_point.path_point().x())) &&
69 (!std::isnan(trajectory_point.path_point().y())) &&
70 (!std::isnan(trajectory_point.path_point().theta())) &&
71 (!std::isnan(trajectory_point.v())) &&
72 (!std::isnan(trajectory_point.a())) &&
73 (!std::isnan(trajectory_point.relative_time()));
74}
75
76} // namespace prediction
77} // namespace apollo
static bool ValidCentripetalAcceleration(const std::vector< common::TrajectoryPoint > &discretized_trajectory)
Check the validity of trajectory's centripetal acceleration
static double ProbabilityByCentripetalAcceleration(const LaneSequence &lane_sequence, const double speed)
Compute the probability by centripetal acceleration
static bool ValidTrajectoryPoint(const common::TrajectoryPoint &trajectory_point)
Check if a trajectory point is valid
Math-related util functions.
double NormalizeAngle(const double angle)
Normalize angle to [-PI, PI).
Definition math_utils.cc:53
class register implement
Definition arena_queue.h:37
repeated apollo::common::PathPoint path_point