Apollo 11.0
自动驾驶开放平台
trajectory1d_generator.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 <memory>
24#include <utility>
25#include <vector>
26
27#include "modules/planning/planning_base/proto/lattice_structure.pb.h"
28
36
37namespace apollo {
38namespace planning {
39
41 public:
43 const std::array<double, 3>& lon_init_state,
44 const std::array<double, 3>& lat_init_state,
45 std::shared_ptr<PathTimeGraph> ptr_path_time_graph,
46 std::shared_ptr<PredictionQuerier> ptr_prediction_querier);
47
48 virtual ~Trajectory1dGenerator() = default;
49
51 const PlanningTarget& planning_target,
52 std::vector<std::shared_ptr<Curve1d>>* ptr_lon_trajectory_bundle,
53 std::vector<std::shared_ptr<Curve1d>>* ptr_lat_trajectory_bundle);
54
56 std::vector<std::shared_ptr<Curve1d>>* ptr_lat_trajectory_bundle) const;
57
58 private:
59 void GenerateSpeedProfilesForCruising(
60 const double target_speed,
61 std::vector<std::shared_ptr<Curve1d>>* ptr_lon_trajectory_bundle) const;
62
63 void GenerateSpeedProfilesForStopping(
64 const double stop_point,
65 std::vector<std::shared_ptr<Curve1d>>* ptr_lon_trajectory_bundle) const;
66
67 void GenerateSpeedProfilesForPathTimeObstacles(
68 std::vector<std::shared_ptr<Curve1d>>* ptr_lon_trajectory_bundle) const;
69
70 void GenerateLongitudinalTrajectoryBundle(
71 const PlanningTarget& planning_target,
72 std::vector<std::shared_ptr<Curve1d>>* ptr_lon_trajectory_bundle) const;
73
74 template <size_t N>
75 void GenerateTrajectory1DBundle(
76 const std::array<double, 3>& init_state,
77 const std::vector<std::pair<std::array<double, 3>, double>>&
78 end_conditions,
79 std::vector<std::shared_ptr<Curve1d>>* ptr_trajectory_bundle) const;
80
81 private:
82 std::array<double, 3> init_lon_state_;
83
84 std::array<double, 3> init_lat_state_;
85
86 EndConditionSampler end_condition_sampler_;
87
88 std::shared_ptr<PathTimeGraph> ptr_path_time_graph_;
89};
90
91template <>
92inline void Trajectory1dGenerator::GenerateTrajectory1DBundle<4>(
93 const std::array<double, 3>& init_state,
94 const std::vector<std::pair<std::array<double, 3>, double>>& end_conditions,
95 std::vector<std::shared_ptr<Curve1d>>* ptr_trajectory_bundle) const {
96 CHECK_NOTNULL(ptr_trajectory_bundle);
97 ACHECK(!end_conditions.empty());
98
99 ptr_trajectory_bundle->reserve(ptr_trajectory_bundle->size() +
100 end_conditions.size());
101 for (const auto& end_condition : end_conditions) {
102 auto ptr_trajectory1d = std::make_shared<LatticeTrajectory1d>(
103 std::shared_ptr<Curve1d>(new QuarticPolynomialCurve1d(
104 init_state, {end_condition.first[1], end_condition.first[2]},
105 end_condition.second)));
106
107 ptr_trajectory1d->set_target_velocity(end_condition.first[1]);
108 ptr_trajectory1d->set_target_time(end_condition.second);
109 ptr_trajectory_bundle->push_back(ptr_trajectory1d);
110 }
111}
112
113template <>
114inline void Trajectory1dGenerator::GenerateTrajectory1DBundle<5>(
115 const std::array<double, 3>& init_state,
116 const std::vector<std::pair<std::array<double, 3>, double>>& end_conditions,
117 std::vector<std::shared_ptr<Curve1d>>* ptr_trajectory_bundle) const {
118 CHECK_NOTNULL(ptr_trajectory_bundle);
119 ACHECK(!end_conditions.empty());
120
121 ptr_trajectory_bundle->reserve(ptr_trajectory_bundle->size() +
122 end_conditions.size());
123 for (const auto& end_condition : end_conditions) {
124 auto ptr_trajectory1d = std::make_shared<LatticeTrajectory1d>(
125 std::shared_ptr<Curve1d>(new QuinticPolynomialCurve1d(
126 init_state, end_condition.first, end_condition.second)));
127
128 ptr_trajectory1d->set_target_position(end_condition.first[0]);
129 ptr_trajectory1d->set_target_velocity(end_condition.first[1]);
130 ptr_trajectory1d->set_target_time(end_condition.second);
131 ptr_trajectory_bundle->push_back(ptr_trajectory1d);
132 }
133}
134
135} // namespace planning
136} // namespace apollo
void GenerateLateralTrajectoryBundle(std::vector< std::shared_ptr< Curve1d > > *ptr_lat_trajectory_bundle) const
void GenerateTrajectoryBundles(const PlanningTarget &planning_target, std::vector< std::shared_ptr< Curve1d > > *ptr_lon_trajectory_bundle, std::vector< std::shared_ptr< Curve1d > > *ptr_lat_trajectory_bundle)
Planning module main class.
#define ACHECK(cond)
Definition log.h:80
class register implement
Definition arena_queue.h:37