hdl_localization icon indicating copy to clipboard operation
hdl_localization copied to clipboard

Can I recognized if localization is failed?

Open zang09 opened this issue 4 years ago • 8 comments

Thank you for sharing your work, koide.

I wonder that is there any way to get error value between align points and map??

I mean, I want to get some message if localization is fail or not.

zang09 avatar Oct 13 '20 05:10 zang09

This package doesn't output the alignment error between the input cloud and the map, and you may need to implement some code by yourself. I think one good way is to compute inlier_fraction between cloud and map like the RANSAC pose estimator does.

https://github.com/PointCloudLibrary/pcl/blob/3906e52ee7ae4f817aef2f9e4aa6091634f12ed5/registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp#L227

koide3 avatar Oct 13 '20 09:10 koide3

thank you! I will try it.

zang09 avatar Oct 13 '20 10:10 zang09

Hi @zang09,

Have you made some progress. I also have the same issue. Would you mind giving some instruction on it? Thanks a lot.

yutouwd avatar Jan 12 '21 15:01 yutouwd

@yutouwd

You can get score by add code like this:

double score;
auto aligned = pose_estimator->correct(filtered, score);

after pose_estimator->predict()

zang09 avatar Jan 13 '21 03:01 zang09

Hi @zang09 ,

Thanks for your kindly reply. But the pose_estimator -> correct() function only has one argument. In pose_estimator.hpp:

  /**
   * @brief correct
   * @param cloud   input cloud
   * @return cloud aligned to the globalmap
   */
  pcl::PointCloud<PointT>::Ptr correct(const pcl::PointCloud<PointT>::ConstPtr& cloud) {

yutouwd avatar Jan 13 '21 07:01 yutouwd

You can consider trying pub_status branch in which some information on the scan matching result (convergence, matching_error, inlier_fraction) are published to /status topic.

https://github.com/koide3/hdl_localization/blob/pub_status/msg/ScanMatchingStatus.msg

koide3 avatar Jan 13 '21 08:01 koide3

@yutouwd

In my case, I added new argument. But I think pub_status branch that @koide3 mention is the better option!

    pcl::PointCloud<PointT>::Ptr correct(const pcl::PointCloud<PointT>::ConstPtr& cloud, double &fitnessScore) {
    .
    .
    .
    pcl::PointCloud<PointT>::Ptr aligned(new pcl::PointCloud<PointT>());
    registration->setInputSource(cloud);
    registration->align(*aligned, init_guess);

    fitnessScore = registration->getFitnessScore();
    .
    .
    .
    }

zang09 avatar Jan 13 '21 08:01 zang09

@koide3 @zang09

Thank you guys so much. I try the pub_status branch and it works well. By the way, how much percentage of inlier would be considered as a successful localization? Is 90% a suitable threshold?

yutouwd avatar Jan 14 '21 08:01 yutouwd