diff --git a/python/kiss_icp/pybind/kiss_icp_pybind.cpp b/python/kiss_icp/pybind/kiss_icp_pybind.cpp index abeca733..bb86c403 100644 --- a/python/kiss_icp/pybind/kiss_icp_pybind.cpp +++ b/python/kiss_icp/pybind/kiss_icp_pybind.cpp @@ -27,6 +27,8 @@ #include #include +#include +#include #include #include @@ -36,7 +38,6 @@ #include "kiss_icp/core/Threshold.hpp" #include "kiss_icp/core/VoxelHashMap.hpp" #include "kiss_icp/metrics/Metrics.hpp" -#include "kitti.hpp" #include "stl_vector_eigen.h" namespace py = pybind11; @@ -119,7 +120,22 @@ 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 &frame) { + constexpr double VERTICAL_ANGLE_OFFSET = (0.205 * M_PI) / 180.0; + std::vector 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); diff --git a/python/kiss_icp/pybind/kitti.hpp b/python/kiss_icp/pybind/kitti.hpp deleted file mode 100644 index 891794b7..00000000 --- a/python/kiss_icp/pybind/kitti.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// MIT License -// -// Copyright (c) 2022 Ignacio Vizzo, Tiziano Guadagnino, Benedikt Mersch, Cyrill -// Stachniss. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include - -#include -#include -#include - -namespace kiss_icp { - -/// 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 CorrectKITTIScan(const std::vector &frame); -std::vector CorrectKITTIScan(const std::vector &frame) { - constexpr double VERTICAL_ANGLE_OFFSET = (0.205 * M_PI) / 180.0; - std::vector 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