Apollo 11.0
自动驾驶开放平台
radar_track.cc
浏览该文件的文档.
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 *****************************************************************************/
17
19
20namespace apollo {
21namespace perception {
22namespace radar {
23
24// Static member variable
25int RadarTrack::s_current_idx_ = 0;
26int RadarTrack::s_tracked_times_threshold_ = 3;
27bool RadarTrack::s_use_filter_ = false;
28std::string RadarTrack::s_chosen_filter_ = // NOLINT
29 "AdaptiveKalmanFilter";
30
31RadarTrack::RadarTrack(const base::ObjectPtr& obs, const double timestamp) {
32 s_current_idx_ %= MAX_RADAR_IDX;
33 obs_id_ = s_current_idx_++;
34 obs_radar_ = base::ObjectPool::Instance().Get();
35 *obs_radar_ = *obs;
36 obs_ = base::ObjectPool::Instance().Get();
37 *obs_ = *obs;
38 timestamp_ = timestamp;
39 tracked_times_ = 1;
40 tracking_time_ = 0.0;
41 is_dead_ = false;
42
43 // Or use register class instead.
44 filter_.reset(new AdaptiveKalmanFilter);
45 filter_->Init(*obs);
46}
47
49 const double timestamp) {
50 *obs_radar_ = *obs_radar;
51 *obs_ = *obs_radar;
52 double time_diff = timestamp - timestamp_;
53 if (s_use_filter_) {
54 Eigen::VectorXd state;
55 state = filter_->UpdateWithObject(*obs_radar_, time_diff);
56 obs_->center(0) = static_cast<float>(state(0));
57 obs_->center(1) = static_cast<float>(state(1));
58 obs_->velocity(0) = static_cast<float>(state(2));
59 obs_->velocity(1) = static_cast<float>(state(3));
60 Eigen::Matrix4d covariance_matrix = filter_->GetCovarianceMatrix();
61 obs_->center_uncertainty(0) = static_cast<float>(covariance_matrix(0, 0));
62 obs_->center_uncertainty(1) = static_cast<float>(covariance_matrix(1, 1));
63 obs_->velocity_uncertainty(0) = static_cast<float>(covariance_matrix(2, 2));
64 obs_->velocity_uncertainty(1) = static_cast<float>(covariance_matrix(3, 3));
65 }
66 tracking_time_ += time_diff;
67 timestamp_ = timestamp;
68 ++tracked_times_;
69}
70
72 obs_radar_ = nullptr;
73 obs_ = nullptr;
74}
75
77
79
80int RadarTrack::GetObsId() const { return obs_id_; }
81
82double RadarTrack::GetTimestamp() { return timestamp_; }
83
84double RadarTrack::GetTrackingTime() { return tracking_time_; }
85} // namespace radar
86} // namespace perception
87} // namespace apollo
void SetObsRadarNullptr()
Set the Obs Radar Nullptr object
RadarTrack(const base::ObjectPtr &obs, const double timestamp)
Construct a new Radar Track object
double GetTimestamp()
Get the Timestamp object
base::ObjectPtr GetObs()
Get the Obs object
int GetObsId() const
Get the Obs Id object
double GetTrackingTime()
Get the Tracking Time object
base::ObjectPtr GetObsRadar()
Get the Obs Radar object
void UpdataObsRadar(const base::ObjectPtr &obs_radar, const double timestamp)
update the object after association with a radar obervation
std::shared_ptr< Object > ObjectPtr
Definition object.h:127
const int MAX_RADAR_IDX
Definition types.h:23
class register implement
Definition arena_queue.h:37