|
11 | 11 |
|
12 | 12 | #include <mrpt/bayes/CParticleFilterCapable.h>
|
13 | 13 | #include <mrpt/bayes/CParticleFilterData.h>
|
| 14 | +#include <mrpt/config.h> |
14 | 15 | #include <mrpt/math/data_utils.h> // averageLogLikelihood()
|
15 | 16 | #include <mrpt/math/distributions.h> // chi2inv
|
16 | 17 | #include <mrpt/obs/CActionCollection.h>
|
|
21 | 22 | #include <mrpt/slam/TKLDParams.h>
|
22 | 23 |
|
23 | 24 | #include <cmath>
|
| 25 | +#include <set> |
| 26 | + |
| 27 | +#if MRPT_HAS_TBB |
| 28 | +#include <tbb/tbb.h> |
| 29 | +#endif |
24 | 30 |
|
25 | 31 | /** \file PF_implementations.h
|
26 | 32 | * This file contains the implementations of the template members declared in
|
@@ -334,17 +340,31 @@ void PF_implementation<PARTICLE_TYPE, MYSELF, STORAGE>::PF_SLAM_implementation_p
|
334 | 340 | // UPDATE STAGE
|
335 | 341 | // ----------------------------------------------------------------------
|
336 | 342 | // Compute all the likelihood values & update particles weight:
|
| 343 | +#if MRPT_HAS_TBB |
| 344 | + tbb::parallel_for( |
| 345 | + tbb::blocked_range<size_t>(0, M), |
| 346 | + [&](const tbb::blocked_range<size_t>& r) |
| 347 | + { |
| 348 | + for (size_t i = r.begin(); i != r.end(); ++i) |
| 349 | + { |
| 350 | +#else |
337 | 351 | for (size_t i = 0; i < M; i++)
|
338 | 352 | {
|
339 |
| - bool pose_is_valid; |
340 |
| - const mrpt::math::TPose3D partPose = |
341 |
| - getLastPose(i, pose_is_valid); // Take the particle data: |
342 |
| - auto partPose2 = mrpt::poses::CPose3D(partPose); |
343 |
| - const double obs_log_lik = |
344 |
| - PF_SLAM_computeObservationLikelihoodForParticle(PF_options, i, *sf, partPose2); |
345 |
| - ASSERT_(!std::isnan(obs_log_lik) && std::isfinite(obs_log_lik)); |
346 |
| - me->m_particles[i].log_w += obs_log_lik * PF_options.powFactor; |
| 353 | +#endif |
| 354 | + bool pose_is_valid; |
| 355 | + const mrpt::math::TPose3D partPose = |
| 356 | + getLastPose(i, pose_is_valid); // Take the particle data: |
| 357 | + auto partPose2 = mrpt::poses::CPose3D(partPose); |
| 358 | + const double obs_log_lik = |
| 359 | + PF_SLAM_computeObservationLikelihoodForParticle(PF_options, i, *sf, partPose2); |
| 360 | + ASSERT_(!std::isnan(obs_log_lik) && std::isfinite(obs_log_lik)); |
| 361 | + me->m_particles[i].log_w += obs_log_lik * PF_options.powFactor; |
| 362 | +#if MRPT_HAS_TBB |
| 363 | + } // for each particle "i" |
| 364 | + }); |
| 365 | +#else |
347 | 366 | } // for each particle "i"
|
| 367 | +#endif |
348 | 368 |
|
349 | 369 | // Normalization of weights is done outside of this method
|
350 | 370 | // automatically.
|
|
0 commit comments