Apollo 11.0
自动驾驶开放平台
track.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
17#pragma once
18
19#include <map>
20#include <memory>
21#include <string>
22
23#include "cyber/common/macros.h"
25
26namespace apollo {
27namespace perception {
28namespace fusion {
29
30typedef std::map<std::string, SensorObjectPtr> SensorId2ObjectMap;
31
32class Track {
33 public:
34 Track();
35 virtual ~Track() = default;
36
42 inline static void SetMaxLidarInvisiblePeriod(double period) {
43 s_max_lidar_invisible_period_ = period;
44 }
45
51 inline static void SetMaxRadarInvisiblePeriod(double period) {
52 s_max_radar_invisible_period_ = period;
53 }
54
60 inline static void SetMaxCameraInvisiblePeriod(double period) {
61 s_max_camera_invisible_period_ = period;
62 }
63
72 bool Initialize(SensorObjectPtr obj, bool is_background = false);
73
74 void Reset();
75
82 SensorObjectConstPtr GetSensorObject(const std::string& sensor_id) const;
83
90
97
104
111
118
124 inline const SensorId2ObjectMap& GetLidarObjects() const {
125 return lidar_objects_;
126 }
127
134
140 inline const SensorId2ObjectMap& GetRadarObjects() const {
141 return radar_objects_;
142 }
143
150
156 inline const SensorId2ObjectMap& GetCameraObjects() const {
157 return camera_objects_;
158 }
159
165 inline int GetTrackId() const {
166 return fused_object_->GetBaseObject()->track_id;
167 }
168
174 inline double GetTrackingPeriod() const { return tracking_period_; }
175
181 inline size_t GetTrackedTimes() const { return tracked_times_; }
182
187 inline void AddTrackedTimes() { ++tracked_times_; }
188
194 inline double GetExistenceProb() const { return existence_prob_; }
195
201 inline void SetExistenceProb(double prob) { existence_prob_ = prob; }
202
208 inline double GetToicProb() const { return toic_prob_; }
209
215 inline void SetToicProb(double prob) { toic_prob_ = prob; }
216
223 inline bool IsBackground() const { return is_background_; }
224
231 inline bool IsAlive() const { return is_alive_; }
232
240 bool IsVisible(const std::string& sensor_id) const;
241
248 bool IsLidarVisible() const;
249
256 bool IsRadarVisible() const;
257
264 bool IsCameraVisible() const;
265
271 static size_t GenerateNewTrackId();
272
279
286 void UpdateWithoutSensorObject(const std::string& sensor_id,
287 double measurement_timestamp);
288
294 std::string DebugString() const;
295
296 protected:
302 void UpdateSupplementState(const SensorObjectPtr& src_object = nullptr);
303
309 void UpdateUnfusedState(const SensorObjectPtr& src_object);
310
318 const SensorId2ObjectMap& objects) const;
319
327 const SensorObjectPtr& obj);
328
338 const std::string& sensor_id,
339 double measurement_timestamp,
340 double max_invisible_period);
341
351 const std::string& sensor_id,
352 double measurement_timestamp,
353 double max_invisible_period);
354
361
368 void UpdateWithoutSensorObjectForBackground(const std::string& sensor_id,
369 double measurement_timestamp);
370
371 protected:
375
377 double tracking_period_ = 0.0;
378 double existence_prob_ = 0.0;
379 double toic_prob_ = 0.0;
380
381 bool is_background_ = false;
382 bool is_alive_ = true;
383
384 size_t tracked_times_ = 0;
385
386 private:
387 // FRIEND_TEST(TrackTest, test);
388
389 static size_t s_track_idx_;
390 static double s_max_lidar_invisible_period_;
391 static double s_max_radar_invisible_period_;
392 static double s_max_camera_invisible_period_;
393
395};
396
397typedef std::shared_ptr<Track> TrackPtr;
398typedef std::shared_ptr<const Track> TrackConstPtr;
399
400} // namespace fusion
401} // namespace perception
402} // namespace apollo
const SensorId2ObjectMap & GetLidarObjects() const
Get the lidar objects object
Definition track.h:124
double GetToicProb() const
Get the Toic Prob object
Definition track.h:208
bool IsCameraVisible() const
Is camera visible
Definition track.cc:272
static size_t GenerateNewTrackId()
Generate new track id
Definition track.cc:98
bool IsAlive() const
Is tracking lost
Definition track.h:231
void UpdateUnfusedState(const SensorObjectPtr &src_object)
update no fusion state
Definition track.cc:236
static void SetMaxRadarInvisiblePeriod(double period)
Set the max radar invisible period
Definition track.h:51
FusedObjectPtr GetFusedObject()
Get the fused object object
Definition track.h:110
static void SetMaxCameraInvisiblePeriod(double period)
Set the max camera invisible period
Definition track.h:60
static void SetMaxLidarInvisiblePeriod(double period)
Set the max lidar invisible period
Definition track.h:42
void AddTrackedTimes()
Add the tracked times
Definition track.h:187
void UpdateWithSensorObjectForBackground(const SensorObjectPtr &obj)
Definition track.cc:281
int GetTrackId() const
Get the track id
Definition track.h:165
double GetTrackingPeriod() const
Get the tracking period
Definition track.h:174
bool IsVisible(const std::string &sensor_id) const
Is visible
Definition track.cc:249
bool IsBackground() const
Is background
Definition track.h:223
SensorObjectConstPtr GetSensorObject(const std::string &sensor_id) const
Get the sensor object object
Definition track.cc:55
const SensorId2ObjectMap & GetRadarObjects() const
Get the radar objects object
Definition track.h:140
void UpdateSensorObjectWithoutMeasurement(SensorId2ObjectMap *objects, const std::string &sensor_id, double measurement_timestamp, double max_invisible_period)
Definition track.cc:172
std::string DebugString() const
Debug information
Definition track.cc:294
bool IsRadarVisible() const
Is radar visible
Definition track.cc:263
void SetToicProb(double prob)
Set the Toic Prob object
Definition track.h:215
SensorId2ObjectMap radar_objects_
Definition track.h:373
void SetExistenceProb(double prob)
Set the Existence Prob object
Definition track.h:201
bool Initialize(SensorObjectPtr obj, bool is_background=false)
Initialize
Definition track.cc:31
size_t GetTrackedTimes() const
Get the tracked times
Definition track.h:181
SensorObjectConstPtr GetLatestRadarObject() const
Get the latest radar object object
Definition track.cc:79
void UpdateSupplementState(const SensorObjectPtr &src_object=nullptr)
Update supplement state
Definition track.cc:212
SensorId2ObjectMap & GetRadarObjects()
Get the radar objects object
Definition track.h:133
const SensorId2ObjectMap & GetCameraObjects() const
Get the camera objects object
Definition track.h:156
void UpdateSensorObject(SensorId2ObjectMap *objects, const SensorObjectPtr &obj)
Definition track.cc:108
SensorObjectConstPtr GetLatestSensorObject(const SensorId2ObjectMap &objects) const
Get the Latest Sensor Object object
Definition track.cc:87
SensorId2ObjectMap & GetLidarObjects()
Get the lidar objects object
Definition track.h:117
void UpdateSensorObjectWithMeasurement(SensorId2ObjectMap *objects, const std::string &sensor_id, double measurement_timestamp, double max_invisible_period)
Definition track.cc:193
bool IsLidarVisible() const
Is lidar visible
Definition track.cc:254
double GetExistenceProb() const
Get the Existence Prob object
Definition track.h:194
void UpdateWithSensorObject(const SensorObjectPtr &obj)
Update by SensorObject
Definition track.cc:119
SensorId2ObjectMap lidar_objects_
Definition track.h:372
void UpdateWithoutSensorObject(const std::string &sensor_id, double measurement_timestamp)
Update without SensorObject
Definition track.cc:155
SensorId2ObjectMap & GetCameraObjects()
Get the camera objects object
Definition track.h:149
SensorObjectConstPtr GetLatestCameraObject() const
Get the latest camera object object
Definition track.cc:83
SensorObjectConstPtr GetLatestLidarObject() const
Get the latest lidar object object
Definition track.cc:75
void UpdateWithoutSensorObjectForBackground(const std::string &sensor_id, double measurement_timestamp)
Definition track.cc:291
SensorId2ObjectMap camera_objects_
Definition track.h:374
#define DISALLOW_COPY_AND_ASSIGN(classname)
Definition macros.h:48
std::shared_ptr< const SensorObject > SensorObjectConstPtr
std::shared_ptr< SensorObject > SensorObjectPtr
std::shared_ptr< const Track > TrackConstPtr
Definition track.h:398
std::shared_ptr< Track > TrackPtr
Definition track.h:397
std::shared_ptr< FusedObject > FusedObjectPtr
std::map< std::string, SensorObjectPtr > SensorId2ObjectMap
Definition track.h:30
class register implement
Definition arena_queue.h:37