Apollo 11.0
自动驾驶开放平台
information_filter.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
18namespace apollo {
19namespace perception {
20namespace fusion {
21
23 : BaseFilter("InformationFilter"), last_observation_init_(false) {}
24
25bool InformationFilter::Init(const Eigen::VectorXd &global_states,
26 const Eigen::MatrixXd &global_uncertainty) {
27 if (global_uncertainty.rows() != global_uncertainty.cols()) {
28 return false;
29 }
30
31 states_num_ = static_cast<int>(global_uncertainty.rows());
32
33 if (states_num_ <= 0) {
34 return false;
35 }
36
37 if (states_num_ != global_states.rows()) {
38 return false;
39 }
40
41 global_states_ = global_states;
42 global_uncertainty_ = global_uncertainty;
44
47
48 cur_observation_.setZero(states_num_, 1);
50
53
54 c_matrix_.setIdentity(states_num_, states_num_);
56
57 init_ = true;
58 return true;
59}
60
62 const Eigen::VectorXd &last_observation,
63 const Eigen::MatrixXd &last_observation_uncertainty,
64 const Eigen::MatrixXd &last_to_cur_transform_matrix,
65 const Eigen::MatrixXd &last_to_cur_env_uncertainty) {
66 if (!init_) {
67 return false;
68 }
69 if (last_observation.rows() != states_num_) {
70 return false;
71 }
72 if (last_observation_uncertainty.rows() != states_num_) {
73 return false;
74 }
75 if (last_observation_uncertainty.cols() != states_num_) {
76 return false;
77 }
78 if (last_to_cur_transform_matrix.rows() != states_num_) {
79 return false;
80 }
81 if (last_to_cur_transform_matrix.cols() != states_num_) {
82 return false;
83 }
84 if (last_to_cur_env_uncertainty.rows() != states_num_) {
85 return false;
86 }
87 if (last_to_cur_env_uncertainty.cols() != states_num_) {
88 return false;
89 }
90
91 last_observation_ = last_observation;
92 last_observation_uncertainty_ = last_observation_uncertainty;
93 last_to_cur_transform_matrix_ = last_to_cur_transform_matrix;
94 last_to_cur_env_uncertainty_ = last_to_cur_env_uncertainty;
96 return true;
97}
98
99bool InformationFilter::Predict(const Eigen::MatrixXd &transform_matrix,
100 const Eigen::MatrixXd &env_uncertainty) {
101 if (!init_) {
102 return false;
103 }
104 if (transform_matrix.rows() != states_num_) {
105 return false;
106 }
107 if (transform_matrix.cols() != states_num_) {
108 return false;
109 }
110 if (env_uncertainty.rows() != states_num_) {
111 return false;
112 }
113 if (env_uncertainty.cols() != states_num_) {
114 return false;
115 }
116 transform_matrix_ = transform_matrix;
117 env_uncertainty_ = env_uncertainty;
122 return true;
123}
124
126 const Eigen::VectorXd &cur_observation,
127 const Eigen::MatrixXd &cur_observation_uncertainty) {
128 if (!init_) {
129 return false;
130 }
131 if (cur_observation.rows() != states_num_) {
132 return false;
133 }
134 if (cur_observation_uncertainty.rows() != states_num_) {
135 return false;
136 }
137 if (cur_observation_uncertainty.cols() != states_num_) {
138 return false;
139 }
140 cur_observation_ = cur_observation;
141 cur_observation_uncertainty_ = cur_observation_uncertainty;
142 // global_uncertainty now stores information matrix
144 // tmp_states_ is information vector
146 // cur_observation_uncertainty_ is now the inverse of covariance matrix
149 // propate to current time
155 last_observation_uncertainty_ = // transform to measurement space
157 global_uncertainty_ = // update information matrix
160 c_matrix_.transpose() * last_observation_uncertainty_.inverse() *
161 c_matrix_);
162 tmp_states_ += // update information vector
165 c_matrix_.transpose() * last_observation_uncertainty_.inverse() *
167 } else {
170 tmp_states_ +=
172 }
173
176 return true;
177}
179 const Eigen::MatrixXd &control_matrix) {
180 if (!init_) {
181 return false;
182 }
183 if (control_matrix.rows() != states_num_ ||
184 control_matrix.cols() != states_num_) {
185 return false;
186 }
187 c_matrix_ = control_matrix;
188 return true;
189}
190
191} // namespace fusion
192} // namespace perception
193} // namespace apollo
bool SetControlMatrix(const Eigen::MatrixXd &control_matrix)
bool SetLastObservation(const Eigen::VectorXd &last_observation, const Eigen::MatrixXd &last_observation_uncertainty, const Eigen::MatrixXd &last_to_cur_transform_matrix, const Eigen::MatrixXd &last_to_cur_env_uncertainty)
bool Init(const Eigen::VectorXd &global_states, const Eigen::MatrixXd &global_uncertainty)
bool Predict(const Eigen::MatrixXd &transform_matrix, const Eigen::MatrixXd &env_uncertainty_matrix)
bool Correct(const Eigen::VectorXd &current_observation, const Eigen::MatrixXd &current_observation_uncertainty)
class register implement
Definition arena_queue.h:37