Apollo 10.0
自动驾驶开放平台
track_data.h
浏览该文件的文档.
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#pragma once
17
18#include <deque>
19#include <map>
20#include <memory>
21#include <utility>
22
24
25namespace apollo {
26namespace perception {
27namespace lidar {
28
29enum class MotionState {
30 STATIC = 0,
32 TRUSTED_MOVE = 2,
33};
34
35class TrackData {
36 public:
37 TrackData();
38 TrackData(TrackedObjectPtr obj, int track_id);
39 virtual ~TrackData();
45 std::pair<double, TrackedObjectPtr> GetLatestObject() {
46 if (history_objects_.size() != 0) {
47 return *history_objects_.rbegin();
48 }
49 return std::pair<double, TrackedObjectPtr>(0.0, TrackedObjectPtr(nullptr));
50 }
56 std::pair<double, TrackedObjectConstPtr> GetLatestObject() const {
57 if (history_objects_.size() != 0) {
58 return *history_objects_.rbegin();
59 }
60 return std::pair<double, TrackedObjectPtr>(0.0, TrackedObjectPtr(nullptr));
61 }
67 std::pair<double, TrackedObjectPtr> GetOldestObject() {
68 if (history_objects_.size() != 0) {
69 return *history_objects_.begin();
70 }
71 return std::pair<double, TrackedObjectPtr>(0.0, TrackedObjectPtr(nullptr));
72 }
78 std::pair<double, TrackedObjectConstPtr> GetOldestObject() const {
79 if (history_objects_.size() != 0) {
80 return *history_objects_.begin();
81 }
82 return std::pair<double, TrackedObjectPtr>(0.0, TrackedObjectPtr(nullptr));
83 }
84
94 std::pair<double, TrackedObjectPtr> GetHistoryObject(int idx);
95
102 std::pair<double, TrackedObjectConstPtr> GetHistoryObject(int idx) const;
103
104 std::map<double, TrackedObjectPtr> GetHistoryObjects() const {
105 return history_objects_;
106 }
107
112 virtual void Reset();
120 virtual void Reset(TrackedObjectPtr obj, double time, int track_id);
127 virtual void PushTrackedObjectToTrack(TrackedObjectPtr obj, double time);
128
129 int track_id_ = -1;
130 int age_ = 0;
133 static const int kMaxHistorySize;
134 std::map<double, TrackedObjectPtr> history_objects_;
136 // motion state related
137 // used for judge object is static or not
141 // if currenet frame is evaluated as in motion (implemented in post_process),
142 // then the next pub_remain_frames should not be set as static,
143 // in order to improve sensibility from static to motion
145 // if currenet frame is evaluated as static (implemented in post_process),
146 // this flag is used to determine check velocity consistency or not,
147 // in order to keep velocity consistency when measurement is unstable
149 // the next two deques are used to calculate motion score
150 std::deque<double> history_norm_variance_;
151 std::deque<double> history_theta_variance_;
152};
153
154typedef std::shared_ptr<TrackData> TrackDataPtr;
155typedef std::shared_ptr<const TrackData> TrackDataConstPtr;
156
157} // namespace lidar
158} // namespace perception
159} // namespace apollo
std::pair< double, TrackedObjectPtr > GetOldestObject()
Get oldest object
Definition track_data.h:67
std::pair< double, TrackedObjectPtr > GetHistoryObject(int idx)
Get histroy object
Definition track_data.cc:30
std::pair< double, TrackedObjectConstPtr > GetOldestObject() const
Get oldest object
Definition track_data.h:78
std::map< double, TrackedObjectPtr > GetHistoryObjects() const
Definition track_data.h:104
std::map< double, TrackedObjectPtr > history_objects_
Definition track_data.h:134
std::pair< double, TrackedObjectPtr > GetLatestObject()
Get latest object
Definition track_data.h:45
virtual void PushTrackedObjectToTrack(TrackedObjectPtr obj, double time)
Push tracked object to track
std::deque< double > history_norm_variance_
Definition track_data.h:150
std::pair< double, TrackedObjectConstPtr > GetLatestObject() const
Get latest object
Definition track_data.h:56
std::deque< double > history_theta_variance_
Definition track_data.h:151
std::shared_ptr< const TrackData > TrackDataConstPtr
Definition track_data.h:155
std::shared_ptr< TrackData > TrackDataPtr
Definition track_data.h:154
std::shared_ptr< TrackedObject > TrackedObjectPtr
class register implement
Definition arena_queue.h:37