| 140 | } |
| 141 | |
| 142 | void |
| 143 | Track::update( |
| 144 | double x, |
| 145 | double y, |
| 146 | double z, |
| 147 | double height, |
| 148 | double distance, |
| 149 | double data_assocation_score, |
| 150 | double confidence, |
| 151 | double min_confidence, |
| 152 | double min_confidence_detections, |
| 153 | open_ptrack::detection::DetectionSource* detection_source, |
| 154 | bool first_update) |
| 155 | { |
| 156 | //Update Kalman filter |
| 157 | int difference; |
| 158 | double vx, vy; |
| 159 | if (velocity_in_motion_term_) |
| 160 | { |
| 161 | ros::Duration d(1.0); |
| 162 | ros::Duration d2(2.0); |
| 163 | |
| 164 | double t = std::max(first_time_detected_.toSec(), (detection_source->getTime() - d).toSec()); |
| 165 | // std::cout << "t1: " << t << std::endl; |
| 166 | t = std::min(t, last_time_detected_.toSec()); |
| 167 | // std::cout << "t2: " << t << std::endl; |
| 168 | t = std::max(t, (detection_source->getTime() - d2).toSec()); |
| 169 | // std::cout << "t3: " << t << std::endl; |
| 170 | double dt = t - last_time_predicted_.toSec(); |
| 171 | // std::cout << "dt: " << dt << std::endl; |
| 172 | difference = int(round(dt / period_)); |
| 173 | // std::cout << "period: " << period_ << std::endl; |
| 174 | // std::cout << "difference: " << difference << std::endl; |
| 175 | int vIndex = (MAX_SIZE + last_time_predicted_index_ + difference) % MAX_SIZE; |
| 176 | // std::cout << vIndex << std::endl; |
| 177 | |
| 178 | // difference = int(round(dt / period_)); |
| 179 | // int vIndex = (MAX_SIZE + last_time_predicted_index_ + difference) % MAX_SIZE; |
| 180 | |
| 181 | if(difference != 0) |
| 182 | { |
| 183 | vx = - (x - mahalanobis_map4d_[vIndex].x) / dt; |
| 184 | vy = - (y - mahalanobis_map4d_[vIndex].y) / dt; |
| 185 | } |
| 186 | else |
| 187 | { |
| 188 | vx = mahalanobis_map4d_[vIndex].x; |
| 189 | vy = mahalanobis_map4d_[vIndex].x; |
| 190 | } |
| 191 | // std::cout << "Mahalanobis: " << mahalanobis_map4d_[vIndex].x << "," << mahalanobis_map4d_[vIndex].y << std::endl; |
| 192 | } |
| 193 | |
| 194 | // Update Kalman filter from the last time the track was visible: |
| 195 | int framesLost = int(round((detection_source->getTime() - last_time_detected_).toSec() / period_)) - 1; |
| 196 | |
| 197 | for(int i = 0; i < framesLost; i++) |
| 198 | { |
| 199 | filter_->predict(); |
no test coverage detected