Apollo  6.0
Open source self driving car software
sequence_predictor.h
Go to the documentation of this file.
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 
22 #pragma once
23 
24 #include <string>
25 #include <utility>
26 #include <vector>
27 
28 #include "gtest/gtest.h"
29 
31 
32 namespace apollo {
33 namespace prediction {
34 
35 class SequencePredictor : public Predictor {
36  public:
37  enum class LaneChangeType {
38  LEFT,
39  RIGHT,
40  STRAIGHT,
41  ONTO_LANE,
42  INVALID,
43  };
44 
45  public:
49  SequencePredictor() = default;
50 
54  virtual ~SequencePredictor() = default;
55 
63  bool Predict(const ADCTrajectoryContainer* adc_trajectory_container,
64  Obstacle* obstacle,
65  ObstaclesContainer* obstacles_container) override;
66 
67  FRIEND_TEST(SequencePredictorTest, General);
68 
69  protected:
70  bool GetLongitudinalPolynomial(const Obstacle& obstacle,
71  const LaneSequence& lane_sequence,
72  const std::pair<double, double>& lon_end_state,
73  std::array<double, 5>* coefficients);
74 
75  bool GetLateralPolynomial(const Obstacle& obstacle,
76  const LaneSequence& lane_sequence,
77  const double time_to_end_state,
78  std::array<double, 4>* coefficients);
88  const Feature& feature, const std::string& lane_id,
89  const Obstacle* ego_vehicle_ptr,
90  const ADCTrajectoryContainer* adc_trajectory_container,
91  std::vector<bool>* enable_lane_sequence);
92 
99  LaneChangeType GetLaneChangeType(const std::string& lane_id,
100  const LaneSequence& lane_sequence);
101 
110  const LaneSequence& lane_sequence, const Obstacle* ego_vehicle_ptr,
111  const ADCTrajectoryContainer* adc_trajectory_container);
112 
123  const Obstacle& obstacle, const LaneSequence& lane_sequence,
124  const double total_time, const double period, const double acceleration,
125  std::vector<apollo::common::TrajectoryPoint>* points);
126 
133  double GetLaneSequenceCurvatureByS(const LaneSequence& lane_sequence,
134  const double s);
135 
139  void Clear();
140 
146  std::string ToString(const LaneSequence& sequence);
147 
148  private:
157  bool LaneSequenceWithMaxProb(const LaneChangeType& type,
158  const double probability, const double max_prob);
159 
168  bool LaneChangeWithMaxProb(const LaneChangeType& type,
169  const double probability, const double max_prob);
170 };
171 
172 } // namespace prediction
173 } // namespace apollo
Define the predictor base class.
void Clear()
Clear private members.
std::string ToString(const LaneSequence &sequence)
Convert a lane sequence to string.
Prediction obstacle.
Definition: obstacle.h:52
Definition: obstacles_container.h:39
LaneChangeType
Definition: sequence_predictor.h:37
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: sequence_predictor.h:35
FRIEND_TEST(SequencePredictorTest, General)
virtual ~SequencePredictor()=default
Destructor.
LaneChangeType GetLaneChangeType(const std::string &lane_id, const LaneSequence &lane_sequence)
Get lane change type.
SequencePredictor()=default
Constructor.
bool GetLongitudinalPolynomial(const Obstacle &obstacle, const LaneSequence &lane_sequence, const std::pair< double, double > &lon_end_state, std::array< double, 5 > *coefficients)
Definition: predictor.h:38
void DrawConstantAccelerationTrajectory(const Obstacle &obstacle, const LaneSequence &lane_sequence, const double total_time, const double period, const double acceleration, std::vector< apollo::common::TrajectoryPoint > *points)
Draw constant acceleration trajectory points.
double GetLaneSequenceCurvatureByS(const LaneSequence &lane_sequence, const double s)
Get lane sequence curvature by s.
bool Predict(const ADCTrajectoryContainer *adc_trajectory_container, Obstacle *obstacle, ObstaclesContainer *obstacles_container) override
Make prediction.
void FilterLaneSequences(const Feature &feature, const std::string &lane_id, const Obstacle *ego_vehicle_ptr, const ADCTrajectoryContainer *adc_trajectory_container, std::vector< bool > *enable_lane_sequence)
Filter lane sequences.
double GetLaneChangeDistanceWithADC(const LaneSequence &lane_sequence, const Obstacle *ego_vehicle_ptr, const ADCTrajectoryContainer *adc_trajectory_container)
Get lane change distance with ADC.
bool GetLateralPolynomial(const Obstacle &obstacle, const LaneSequence &lane_sequence, const double time_to_end_state, std::array< double, 4 > *coefficients)
Definition: adc_trajectory_container.h:37