test/kernel.cpp
/**
 * @brief Compares two sets of points one-on-one and does some statistics
 *
 * @param points_posttransform Transformed point cloud
 * @param points_pretransform Original point cloud
 */
@brief Compares two sets of points one-on-one and does some statistics
@param points_posttransform Transformed point cloud
@param points_pretransform Original point cloud
@brief Compares two sets of points one - on - one and does some statistics @param points_posttransform Transformed point cloud @param points_pretransform Original point cloud
float check_computed_transform(const ScanPoints_t& points_posttransform, ScanPoints_t& points_pretransform, bool print = true)
{
    float minimum = std::numeric_limits<float>::infinity();
    float maximum = -std::numeric_limits<float>::infinity();
    float average = 0;
    float average_x = 0;
    float average_y = 0;
    float average_z = 0;
    std::vector<float> dists(points_pretransform.size());
    for (size_t i = 0; i < points_pretransform.size(); i++)
    {
        Eigen::Vector3i sub = points_pretransform[i] - points_posttransform[i];
        auto norm = sub.cast<float>().norm();
        if (norm < minimum)
        {
            minimum = norm;
        }
        if (norm > maximum)
        {
            maximum = norm;
        }
        average += norm;
        average_x += std::abs(sub.x());
        average_y += std::abs(sub.y());
        average_z += std::abs(sub.z());
        dists[i] = norm;
    }
    std::sort(dists.begin(), dists.end());
    average /= points_pretransform.size();
    average_x /= points_pretransform.size();
    average_y /= points_pretransform.size();
    average_z /= points_pretransform.size();
    if (print)
    {
        std::cout << std::fixed << std::setprecision(2)
                  << "minimum distance: " << minimum << "\n"
                  << "maximum distance: " << maximum << "\n"
                  << "average distance: " << average
                  << ",  (" << (int)average_x << ", " << (int)average_y << ", " << (int)average_z << ")\n"
                  << "median  distance: " << dists[dists.size() / 2 + 1] << std::endl;
    }
    CHECK(average < MAX_OFFSET);
    return average;
}
float check_computed_transform ( const ScanPoints_t & points_posttransform , ScanPoints_t & points_pretransform , bool print = true ) { float minimum = std :: numeric_limits < float > :: infinity ( ) ; float maximum = - std :: numeric_limits < float > :: infinity ( ) ; float average = 0 ; float average_x = 0 ; float average_y = 0 ; float average_z = 0 ; std :: vector < float > dists ( points_pretransform . size ( ) ) ; for ( size_t i = 0 ; i < points_pretransform . size ( ) ; i ++ ) { Eigen :: Vector3i sub = points_pretransform [ i ] - points_posttransform [ i ] ; auto norm = sub . cast < float > ( ) . norm ( ) ; if ( norm < minimum ) { minimum = norm ; } if ( norm > maximum ) { maximum = norm ; } average += norm ; average_x += std :: abs ( sub . x ( ) ) ; average_y += std :: abs ( sub . y ( ) ) ; average_z += std :: abs ( sub . z ( ) ) ; dists [ i ] = norm ; } std :: sort ( dists . begin ( ) , dists . end ( ) ) ; average /= points_pretransform . size ( ) ; average_x /= points_pretransform . size ( ) ; average_y /= points_pretransform . size ( ) ; average_z /= points_pretransform . size ( ) ; if ( print ) { std :: cout << std :: fixed << std :: setprecision ( 2 ) << " " << minimum << " \n " << " " << maximum << " \n " << " " << average << " " << ( int ) average_x << " " << ( int ) average_y << " " << ( int ) average_z << " \n " << " " << dists [ dists . size ( ) / 2 + 1 ] << std :: endl ; } CHECK ( average < MAX_OFFSET ) ; return average ; }
@brief Compares two sets of points one-on-one and does some statistics
 @param points_posttransform Transformed point cloud
 @param points_pretransform Original point cloud
@brief Compares two sets of points one - on - one and does some statistics @param points_posttransform Transformed point cloud @param points_pretransform Original point cloud