Skip to content

Commit

Permalink
Remove kitti scan correction from core library
Browse files Browse the repository at this point in the history
Put it in python bindings, that is the only place where is actually used
  • Loading branch information
nachovizzo committed Jul 20, 2024
1 parent a9f527d commit 8951c5d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
13 changes: 0 additions & 13 deletions cpp/kiss_icp/core/Preprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
// SOFTWARE.
#include "Preprocessing.hpp"

#include <tbb/parallel_for.h>
#include <tsl/robin_map.h>

#include <Eigen/Core>
#include <Eigen/Geometry>
#include <algorithm>
#include <cmath>
#include <vector>

#include "VoxelUtils.hpp"
Expand Down Expand Up @@ -63,15 +61,4 @@ std::vector<Eigen::Vector3d> Preprocess(const std::vector<Eigen::Vector3d> &fram
return inliers;
}

std::vector<Eigen::Vector3d> CorrectKITTIScan(const std::vector<Eigen::Vector3d> &frame) {
constexpr double VERTICAL_ANGLE_OFFSET = (0.205 * M_PI) / 180.0;
std::vector<Eigen::Vector3d> corrected_frame(frame.size());
tbb::parallel_for(size_t(0), frame.size(), [&](size_t i) {
const auto &pt = frame[i];
const Eigen::Vector3d rotationVector = pt.cross(Eigen::Vector3d(0., 0., 1.));
corrected_frame[i] =
Eigen::AngleAxisd(VERTICAL_ANGLE_OFFSET, rotationVector.normalized()) * pt;
});
return corrected_frame;
}
} // namespace kiss_icp
5 changes: 0 additions & 5 deletions cpp/kiss_icp/core/Preprocessing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ std::vector<Eigen::Vector3d> Preprocess(const std::vector<Eigen::Vector3d> &fram
double max_range,
double min_range);

/// This function only applies for the KITTI dataset, and should NOT be used by any other dataset,
/// the original idea and part of the implementation is taking from CT-ICP(Although IMLS-SLAM
/// Originally introduced the calibration factor)
std::vector<Eigen::Vector3d> CorrectKITTIScan(const std::vector<Eigen::Vector3d> &frame);

/// Voxelize point cloud keeping the original coordinates
std::vector<Eigen::Vector3d> VoxelDownsample(const std::vector<Eigen::Vector3d> &frame,
double voxel_size);
Expand Down
18 changes: 17 additions & 1 deletion python/kiss_icp/pybind/kiss_icp_pybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <pybind11/stl_bind.h>

#include <Eigen/Core>
#include <algorithm>
#include <cmath>
#include <memory>
#include <vector>

Expand Down Expand Up @@ -118,7 +120,21 @@ PYBIND11_MODULE(kiss_icp_pybind, m) {
// prerpocessing modules
m.def("_voxel_down_sample", &VoxelDownsample, "frame"_a, "voxel_size"_a);
m.def("_preprocess", &Preprocess, "frame"_a, "max_range"_a, "min_range"_a);
m.def("_correct_kitti_scan", &CorrectKITTIScan, "frame"_a);
/// This function only applies for the KITTI dataset, and should NOT be used by any other
/// dataset, the original idea and part of the implementation is taking from CT-ICP(Although
/// IMLS-SLAM Originally introduced the calibration factor)
m.def(
"_correct_kitti_scan",
[](const std::vector<Eigen::Vector3d> &frame) {
constexpr double VERTICAL_ANGLE_OFFSET = (0.205 * M_PI) / 180.0;
std::vector<Eigen::Vector3d> frame_ = frame;
std::transform(frame_.cbegin(), frame_.cend(), frame_.begin(), [&](const auto pt) {
const Eigen::Vector3d rotationVector = pt.cross(Eigen::Vector3d(0., 0., 1.));
return Eigen::AngleAxisd(VERTICAL_ANGLE_OFFSET, rotationVector.normalized()) * pt;
});
return frame_;
},
"frame"_a);

// Metrics
m.def("_kitti_seq_error", &metrics::SeqError, "gt_poses"_a, "results_poses"_a);
Expand Down

0 comments on commit 8951c5d

Please sign in to comment.