Apollo  6.0
Open source self driving car software
history.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2019 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 <list>
24 #include <string>
25 #include <unordered_map>
26 #include <vector>
27 
28 #include "cyber/common/macros.h"
29 #include "modules/planning/proto/planning.pb.h"
30 
31 namespace apollo {
32 namespace planning {
33 
35  public:
36  HistoryObjectDecision() = default;
37 
38  void Init(const ObjectDecision& object_decisions);
39  void Init(const std::string& id,
40  const std::vector<ObjectDecisionType>& object_decisions);
41 
42  const std::string& id() const { return id_; }
43  std::vector<const ObjectDecisionType*> GetObjectDecision() const;
44 
45  private:
46  std::string id_;
47  std::vector<ObjectDecisionType> object_decision_;
48 };
49 
50 class HistoryFrame {
51  public:
52  HistoryFrame() = default;
53 
54  void Init(const ADCTrajectory& adc_trajactory);
55 
56  int seq_num() const { return seq_num_; }
57 
58  std::vector<const HistoryObjectDecision*> GetObjectDecisions() const;
59  std::vector<const HistoryObjectDecision*> GetStopObjectDecisions() const;
60 
61  const HistoryObjectDecision* GetObjectDecisionsById(
62  const std::string& id) const;
63 
64  private:
65  int seq_num_;
66  ADCTrajectory adc_trajactory_;
67  std::unordered_map<std::string, HistoryObjectDecision> object_decisions_map_;
68  std::vector<HistoryObjectDecision> object_decisions_;
69 };
70 
72  public:
73  HistoryObjectStatus() = default;
74 
75  void Init(const std::string& id, const ObjectStatus& object_status);
76 
77  const std::string& id() const { return id_; }
78  const ObjectStatus GetObjectStatus() const { return object_status_; }
79 
80  private:
81  std::string id_;
82  ObjectStatus object_status_;
83 };
84 
86  public:
87  HistoryStatus() = default;
88 
89  void SetObjectStatus(const std::string& id,
90  const ObjectStatus& object_status);
91 
92  bool GetObjectStatus(const std::string& id,
93  ObjectStatus* const object_status);
94 
95  private:
96  std::unordered_map<std::string, ObjectStatus> object_id_to_status_;
97 };
98 
99 class History {
100  public:
101  History() = default;
102  const HistoryFrame* GetLastFrame() const;
103  int Add(const ADCTrajectory& adc_trajectory_pb);
104  void Clear();
105  size_t Size() const;
106  HistoryStatus* mutable_history_status() { return &history_status_; }
107 
108  private:
109  std::list<HistoryFrame> history_frames_;
110  HistoryStatus history_status_;
111 };
112 
113 } // namespace planning
114 } // namespace apollo
Definition: history.h:99
const ObjectStatus GetObjectStatus() const
Definition: history.h:78
HistoryStatus * mutable_history_status()
Definition: history.h:106
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
std::vector< const ObjectDecisionType * > GetObjectDecision() const
const std::string & id() const
Definition: history.h:77
void Init(const ObjectDecision &object_decisions)
Planning module main class. It processes GPS and IMU as input, to generate planning info...
int seq_num() const
Definition: history.h:56
Definition: history.h:85
Definition: history.h:50
const std::string & id() const
Definition: history.h:42