MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / getMahalanobisDistance

Method getMahalanobisDistance

tracking/src/track3d.cpp:328–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326}
327
328double
329Track3D::getMahalanobisDistance(double x, double y, double z, const ros::Time& when)
330{
331 int difference = int(round((when - last_time_predicted_).toSec() / period_));
332 // std::cout << "time difference from last detection: " << difference << std::endl;
333 int index;
334 if(difference <= 0)
335 {
336 index = (MAX_SIZE + last_time_predicted_index_ + difference) % MAX_SIZE;
337 }
338 else
339 {
340 for(int i = 0; i < difference; i++)
341 {
342 tmp_filter_->predict();
343 last_time_predicted_index_ = (last_time_predicted_index_ + 1) % MAX_SIZE;
344 if (velocity_in_motion_term_)
345 tmp_filter_->getMahalanobisParameters(mahalanobis_map6d_[last_time_predicted_index_]);
346 else
347 tmp_filter_->getMahalanobisParameters(mahalanobis_map3d_[last_time_predicted_index_]);
348 tmp_filter_->update();
349 }
350 last_time_predicted_ = when;
351 index = last_time_predicted_index_;
352 }
353
354 if (velocity_in_motion_term_)
355 {
356 ros::Duration d(1.0);
357 ros::Duration d2(2.0);
358
359 double t = std::max(first_time_detected_.toSec(), (when - d).toSec());
360 t = std::min(t, last_time_detected_.toSec());
361 t = std::max(t, (last_time_predicted_ - d2).toSec());
362 double dt = t - last_time_predicted_.toSec();
363
364 difference = int(round(dt / period_));
365 int vIndex = (MAX_SIZE + last_time_predicted_index_ + difference) % MAX_SIZE;
366
367 // std::cout << "dt: " << dt << std::endl;
368 // std::cout << "vIndex: " << vIndex << std::endl;
369
370 double vx, vy, vz;
371 if(difference != 0)
372 {
373 vx = - (x - mahalanobis_map6d_[vIndex].x) / dt;
374 vy = - (y - mahalanobis_map6d_[vIndex].y) / dt;
375 vz = - (z - mahalanobis_map6d_[vIndex].z) / dt;
376 }
377 else
378 {
379 vx = mahalanobis_map6d_[vIndex].x;
380 vy = mahalanobis_map6d_[vIndex].y;
381 vz = mahalanobis_map6d_[vIndex].z;
382 }
383
384 // std::cout << "vx: " << vx << ", vy: " << vy<< std::endl;
385

Callers

nothing calls this directly

Calls 3

predictMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected