facontidavide / Bonxai

Fast, hierarchical, sparse Voxel Grid
Mozilla Public License 2.0
643 stars 53 forks source link

template bug fix in updateFreeCells for insertPointCloud #11

Closed engcang closed 12 months ago

engcang commented 12 months ago

Hi @facontidavide.

Super thank you for sharing awesome work. This is way much faster than OctoMap and I love this! I am using the ProbabilisticMap and found minor template bug when calling insertPointCloud as below.

#include "probabilistic_map.hpp"
using namespace std;

shared_ptr<Bonxai::ProbabilisticMap> m_bnx = nullptr;
m_bnx = make_shared<Bonxai::ProbabilisticMap>(vox_res_);

vector<Bonxai::Point3D> temp_bpts_;
// somehow get the data to insert
m_bnx->insertPointCloud(temp_bpts_, Bonxai::Point3D(x, y, z), max_range);

Former updateFreeCells function only gets the Eigen::Vector3f as input and hence error occurs during compiling with the code block above. Adding template <typename PointT> and changing the input type as PointT solve the issue.

facontidavide commented 12 months ago

check the commits I did few hours ago, should work

facontidavide commented 12 months ago

also, your PR is removing the datafiles

engcang commented 12 months ago

I think I cloned and tested the code block with the latest commit of yours and it does not work. Maybe I found the typo here:

template <typename PointT>
inline void ProbabilisticMap::insertPointCloud(const std::vector<PointT>& points,
                                               const PointT& origin,
                                               double max_range)
{
  const auto from = ConvertTo<Eigen::Vector3f>(origin);
  const double max_range_sqr = max_range * max_range;
  for (const auto& point : points)
  {
    const auto to = ConvertTo<Eigen::Vector3f>(point);
    addPoint(from, to, max_range, max_range_sqr);
  }
  //updateFreeCells(origin); //TYPO
  updateFreeCells(from);
}

I didn't know the data files were stored with lfs, sorry. I didn't remove them but they are still there as non-lfs files.

facontidavide commented 12 months ago

where is the typo?

engcang commented 12 months ago

updateFreeCells(origin) should be updateFreeCells(from)

facontidavide commented 12 months ago

thanks. Anyway, i think I found the issue, working on it

facontidavide commented 12 months ago

Problem solved. Thanks a lot!!!!