Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing boost::mt19937 with std::mt19937 #3994

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions filters/include/pcl/filters/impl/voxel_grid_covariance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#include <Eigen/Dense>
#include <Eigen/Cholesky>

#include <random>

//////////////////////////////////////////////////////////////////////////////////////////
template<typename PointT> void
pcl::VoxelGridCovariance<PointT>::applyFilter (PointCloud &output)
Expand Down Expand Up @@ -411,9 +413,8 @@ pcl::VoxelGridCovariance<PointT>::getDisplayCloud (pcl::PointCloud<PointXYZ>& ce
cell_cloud.clear ();

int pnt_per_cell = 1000;
boost::mt19937 rng;
boost::normal_distribution<> nd (0.0, leaf_size_.head (3).norm ());
boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > var_nor (rng, nd);
std::mt19937 rng {std::random_device{}()};
std::normal_distribution<double> nd {0.0, leaf_size_.head (3).norm ()};

Eigen::LLT<Eigen::Matrix3d> llt_of_cov;
Eigen::Matrix3d cholesky_decomp;
Expand All @@ -435,7 +436,7 @@ pcl::VoxelGridCovariance<PointT>::getDisplayCloud (pcl::PointCloud<PointXYZ>& ce
// Random points generated by sampling the normal distribution given by voxel mean and covariance matrix
for (int i = 0; i < pnt_per_cell; i++)
{
rand_point = Eigen::Vector3d (var_nor (), var_nor (), var_nor ());
rand_point = Eigen::Vector3d (nd (rng), nd (rng), nd (rng));
dist_point = cell_mean + cholesky_decomp * rand_point;
cell_cloud.push_back (PointXYZ (static_cast<float> (dist_point (0)), static_cast<float> (dist_point (1)), static_cast<float> (dist_point (2))));
}
Expand Down
23 changes: 8 additions & 15 deletions sample_consensus/include/pcl/sample_consensus/sac.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

#include <ctime>
#include <memory>
#include <random>
#include <set>

namespace pcl
Expand Down Expand Up @@ -79,13 +80,9 @@ namespace pcl
, threshold_ (std::numeric_limits<double>::max ())
, max_iterations_ (1000)
, threads_ (-1)
, rng_ (new boost::uniform_01<boost::mt19937> (rng_alg_))
, rng_alg_ (random ? std::random_device{}() : 12345u)
, rng_ (new std::uniform_real_distribution<> {})
{
// Create a random number generator object
if (random)
rng_->base ().seed (static_cast<unsigned> (std::time (nullptr)));
else
rng_->base ().seed (12345u);
};

/** \brief Constructor for base SAC.
Expand All @@ -102,13 +99,9 @@ namespace pcl
, threshold_ (threshold)
, max_iterations_ (1000)
, threads_ (-1)
, rng_ (new boost::uniform_01<boost::mt19937> (rng_alg_))
, rng_alg_ (random ? std::random_device{}() : 12345u)
, rng_ (new std::uniform_real_distribution<> {})
{
// Create a random number generator object
if (random)
rng_->base ().seed (static_cast<unsigned> (std::time (nullptr)));
else
rng_->base ().seed (12345u);
};

/** \brief Set the Sample Consensus model to use.
Expand Down Expand Up @@ -342,16 +335,16 @@ namespace pcl
int threads_;

/** \brief Boost-based random number generator algorithm. */
boost::mt19937 rng_alg_;
std::mt19937 rng_alg_;

/** \brief Boost-based random number generator distribution. */
std::shared_ptr<boost::uniform_01<boost::mt19937> > rng_;
std::shared_ptr<std::uniform_real_distribution<> > rng_;

/** \brief Boost-based random number generator. */
inline double
rnd ()
{
return ((*rng_) ());
return ((*rng_) (rng_alg_));
}
};
}