Skip to content

Commit

Permalink
Nacho/remove kitti from core library (#369)
Browse files Browse the repository at this point in the history
* Remove kitti scan correction from core library

Put it in python bindings, that is the only place where is actually used

* Fix merge conflict
  • Loading branch information
nachovizzo authored Jul 24, 2024
1 parent 1c28d17 commit b43166f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 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 All @@ -45,15 +43,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
6 changes: 0 additions & 6 deletions cpp/kiss_icp/core/Preprocessing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,4 @@ namespace kiss_icp {
std::vector<Eigen::Vector3d> Preprocess(const std::vector<Eigen::Vector3d> &frame,
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);

} // namespace kiss_icp
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 b43166f

Please sign in to comment.