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