Apollo 11.0
自动驾驶开放平台
backup_trajectory_generator.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
20
21namespace apollo {
22namespace planning {
23
25using State = std::array<double, 3>;
26
28 const State& init_s, const State& init_d, const double init_relative_time,
29 const std::shared_ptr<CollisionChecker>& ptr_collision_checker,
30 const Trajectory1dGenerator* trajectory1d_generator)
31 : init_relative_time_(init_relative_time),
32 ptr_collision_checker_(ptr_collision_checker),
33 ptr_trajectory1d_generator_(trajectory1d_generator) {
34 GenerateTrajectory1dPairs(init_s, init_d);
35}
36
37void BackupTrajectoryGenerator::GenerateTrajectory1dPairs(const State& init_s,
38 const State& init_d) {
39 std::vector<std::shared_ptr<Curve1d>> lon_trajectories;
40 std::array<double, 5> dds_condidates = {-0.1, -1.0, -2.0, -3.0, -4.0};
41 for (const auto dds : dds_condidates) {
42 lon_trajectories.emplace_back(
43 new ConstantDecelerationTrajectory1d(init_s[0], init_s[1], dds));
44 }
45
46 std::vector<std::shared_ptr<Curve1d>> lat_trajectories;
47 ptr_trajectory1d_generator_->GenerateLateralTrajectoryBundle(
48 &lat_trajectories);
49
50 for (auto& lon : lon_trajectories) {
51 for (auto& lat : lat_trajectories) {
52 trajectory_pair_pqueue_.emplace(lon, lat);
53 }
54 }
55}
56
58 const std::vector<PathPoint>& discretized_ref_points) {
59 while (trajectory_pair_pqueue_.size() > 1) {
60 auto top_pair = trajectory_pair_pqueue_.top();
61 trajectory_pair_pqueue_.pop();
62 DiscretizedTrajectory trajectory =
63 TrajectoryCombiner::Combine(discretized_ref_points, *top_pair.first,
64 *top_pair.second, init_relative_time_);
65 if (!ptr_collision_checker_->InCollision(trajectory)) {
66 return trajectory;
67 }
68 }
69 auto top_pair = trajectory_pair_pqueue_.top();
70 return TrajectoryCombiner::Combine(discretized_ref_points, *top_pair.first,
71 *top_pair.second, init_relative_time_);
72}
73
74} // namespace planning
75} // namespace apollo
BackupTrajectoryGenerator(const std::array< double, 3 > &init_s, const std::array< double, 3 > &init_d, const double init_relative_time, const std::shared_ptr< CollisionChecker > &ptr_collision_checker, const Trajectory1dGenerator *trajectory1d_generator)
DiscretizedTrajectory GenerateTrajectory(const std::vector< common::PathPoint > &discretized_ref_points)
void GenerateLateralTrajectoryBundle(std::vector< std::shared_ptr< Curve1d > > *ptr_lat_trajectory_bundle) const
static DiscretizedTrajectory Combine(const std::vector< common::PathPoint > &reference_line, const Curve1d &lon_trajectory, const Curve1d &lat_trajectory, const double init_relative_time)
Planning module main class.
std::array< double, 3 > State
class register implement
Definition arena_queue.h:37