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