From 3a6d1197d597ee9166da040549218b2acc0a9377 Mon Sep 17 00:00:00 2001 From: Benedikt Mersch Date: Thu, 16 Jan 2025 15:49:30 +0100 Subject: [PATCH 01/11] Add separate deskewing --- src/mapmos/mapping.py | 2 +- src/mapmos/odometry.py | 29 +++++++------ src/mapmos/paper_pipeline.py | 5 ++- src/mapmos/pipeline.py | 10 ++++- src/mapmos/pybind/CMakeLists.txt | 2 +- src/mapmos/pybind/Deskew.cpp | 65 +++++++++++++++++++++++++++++ src/mapmos/pybind/Deskew.hpp | 33 +++++++++++++++ src/mapmos/pybind/mapmos_pybind.cpp | 10 +++++ 8 files changed, 137 insertions(+), 19 deletions(-) create mode 100644 src/mapmos/pybind/Deskew.cpp create mode 100644 src/mapmos/pybind/Deskew.hpp diff --git a/src/mapmos/mapping.py b/src/mapmos/mapping.py index b92edaf..837577c 100644 --- a/src/mapmos/mapping.py +++ b/src/mapmos/mapping.py @@ -59,7 +59,7 @@ def remove_voxels_far_from_location(self, location: np.ndarray): self._internal_map._remove_far_away_points(location) def update_belief(self, points: np.ndarray, logits: np.ndarray): - self._internal_map._update_belief(mapmos_pybind._Vector3dVector(points), logits) + self._internal_map._update_belief(mapmos_pybind._Vector3dVector(points), logits.ravel()) def get_belief(self, points: np.ndarray): belief = self._internal_map._get_belief(mapmos_pybind._Vector3dVector(points)) diff --git a/src/mapmos/odometry.py b/src/mapmos/odometry.py index b9ecbea..61df476 100644 --- a/src/mapmos/odometry.py +++ b/src/mapmos/odometry.py @@ -20,14 +20,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from typing import Type - import numpy as np from kiss_icp.config import KISSConfig from kiss_icp.kiss_icp import KissICP, get_registration from mapmos.config import DataConfig, OdometryConfig from mapmos.mapping import VoxelHashMap +from mapmos.pybind import mapmos_pybind from mapmos.registration import get_registration @@ -61,13 +60,10 @@ def __init__( def register_points(self, points, timestamps, scan_index): # Apply motion compensation - points = self.compensator.deskew_scan(points, timestamps, self.last_delta) - - # Preprocess the input cloud - points_prep = self.preprocess(points) + points = self.preprocessor.preprocess(points, timestamps, self.last_delta) # Voxelize - source, points_downsample = self.voxelize(points_prep) + source, points_downsample = self.voxelize(points) # Get motion prediction and adaptive_threshold sigma = self.adaptive_threshold.get_threshold() @@ -92,17 +88,20 @@ def register_points(self, points, timestamps, scan_index): self.last_delta = np.linalg.inv(self.last_pose) @ new_pose self.last_pose = new_pose - points_reg = self.transform(points, self.last_pose) - return np.asarray(points_reg) - def get_map_points(self): map_points, map_timestamps = self.local_map.point_cloud_with_timestamps() return map_points.reshape(-1, 3), map_timestamps.reshape(-1, 1) - def transform(self, points, pose): - points_hom = np.hstack((points, np.ones((len(points), 1)))) - points = (pose @ points_hom.T).T[:, :3] - return points - def current_location(self): return self.last_pose[:3, 3] + + def deskew(self, points, timestamps, relative_motion): + return ( + mapmos_pybind._deskew( + frame=mapmos_pybind._Vector3dVector(points), + timestamps=timestamps.ravel(), + relative_motion=relative_motion, + ) + if self.config.data.deskew + else points + ) diff --git a/src/mapmos/paper_pipeline.py b/src/mapmos/paper_pipeline.py index 76841d2..9a78d49 100644 --- a/src/mapmos/paper_pipeline.py +++ b/src/mapmos/paper_pipeline.py @@ -72,9 +72,12 @@ def _run_pipeline(self): for scan_index in pbar: local_scan, timestamps, gt_labels = self._next(scan_index) map_points, map_indices = self.odometry.get_map_points() - scan_points = self.odometry.register_points(local_scan, timestamps, scan_index) + self.odometry.register_points(local_scan, timestamps, scan_index) self.poses[scan_index - self._first] = self.odometry.last_pose + scan_points = self.odometry.deskew(local_scan, timestamps, self.odometry.last_delta) + scan_points = self._transform(scan_points, self.odometry.last_pose) + min_range_mos = self.config.mos.min_range_mos max_range_mos = self.config.mos.max_range_mos scan_mask = self._preprocess(scan_points, min_range_mos, max_range_mos) diff --git a/src/mapmos/pipeline.py b/src/mapmos/pipeline.py index f33a300..2da1eeb 100644 --- a/src/mapmos/pipeline.py +++ b/src/mapmos/pipeline.py @@ -120,15 +120,23 @@ def _preprocess(self, points, min_range, max_range): mask = np.logical_and(mask, ranges >= min_range) return mask + def _transform(self, points, pose): + points_hom = np.hstack((points, np.ones((len(points), 1)))) + points = (pose @ points_hom.T).T[:, :3] + return points + # Private interface ------ def _run_pipeline(self): pbar = trange(self._first, self._last, unit=" frames", dynamic_ncols=True) for scan_index in pbar: local_scan, timestamps, gt_labels = self._next(scan_index) map_points, map_indices = self.odometry.get_map_points() - scan_points = self.odometry.register_points(local_scan, timestamps, scan_index) + self.odometry.register_points(local_scan, timestamps, scan_index) self.poses[scan_index - self._first] = self.odometry.last_pose + scan_points = self.odometry.deskew(local_scan, timestamps, self.odometry.last_delta) + scan_points = self._transform(scan_points, self.odometry.last_pose) + min_range_mos = self.config.mos.min_range_mos max_range_mos = self.config.mos.max_range_mos scan_mask = self._preprocess(scan_points, min_range_mos, max_range_mos) diff --git a/src/mapmos/pybind/CMakeLists.txt b/src/mapmos/pybind/CMakeLists.txt index 91a6020..ae7920e 100644 --- a/src/mapmos/pybind/CMakeLists.txt +++ b/src/mapmos/pybind/CMakeLists.txt @@ -41,7 +41,7 @@ find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) find_package(pybind11 CONFIG REQUIRED) # Python bindings -pybind11_add_module(mapmos_pybind MODULE mapmos_pybind.cpp VoxelHashMap.cpp Registration.cpp) +pybind11_add_module(mapmos_pybind MODULE mapmos_pybind.cpp VoxelHashMap.cpp Registration.cpp Deskew.cpp) target_compile_features(mapmos_pybind PRIVATE cxx_std_17) target_link_libraries(mapmos_pybind PUBLIC Eigen3::Eigen tsl::robin_map TBB::tbb Sophus::Sophus) install(TARGETS mapmos_pybind LIBRARY DESTINATION .) diff --git a/src/mapmos/pybind/Deskew.cpp b/src/mapmos/pybind/Deskew.cpp new file mode 100644 index 0000000..08d02a5 --- /dev/null +++ b/src/mapmos/pybind/Deskew.cpp @@ -0,0 +1,65 @@ +// 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 "Deskew.hpp" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace mapmos { +static const auto tbb_control_settings = tbb::global_control( + tbb::global_control::max_allowed_parallelism, tbb::this_task_arena::max_concurrency()); + +std::vector Deskew(const std::vector &frame, + const std::vector ×tamps, + const Sophus::SE3d &relative_motion) { + const std::vector &deskewed_frame = [&]() { + const auto &omega = relative_motion.log(); + const Sophus::SE3d &inverse_motion = relative_motion.inverse(); + std::vector deskewed_frame(frame.size()); + tbb::parallel_for( + // Index Range + tbb::blocked_range{0, deskewed_frame.size()}, + // Parallel Compute + [&](const tbb::blocked_range &r) { + for (size_t idx = r.begin(); idx < r.end(); ++idx) { + const auto &point = frame.at(idx); + const auto &stamp = timestamps.at(idx); + const auto pose = inverse_motion * Sophus::SE3d::exp(stamp * omega); + deskewed_frame.at(idx) = pose * point; + }; + }); + return deskewed_frame; + }(); + return deskewed_frame; +} +} // namespace mapmos diff --git a/src/mapmos/pybind/Deskew.hpp b/src/mapmos/pybind/Deskew.hpp new file mode 100644 index 0000000..83e1114 --- /dev/null +++ b/src/mapmos/pybind/Deskew.hpp @@ -0,0 +1,33 @@ +// 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. +#pragma once + +#include +#include +#include + +namespace mapmos { +std::vector Deskew(const std::vector &frame, + const std::vector ×tamps, + const Sophus::SE3d &relative_motion); +} // namespace mapmos diff --git a/src/mapmos/pybind/mapmos_pybind.cpp b/src/mapmos/pybind/mapmos_pybind.cpp index 59daf19..74e9634 100644 --- a/src/mapmos/pybind/mapmos_pybind.cpp +++ b/src/mapmos/pybind/mapmos_pybind.cpp @@ -30,6 +30,7 @@ #include #include +#include "Deskew.hpp" #include "Registration.hpp" #include "VoxelHashMap.hpp" #include "stl_vector_eigen.h" @@ -45,6 +46,15 @@ PYBIND11_MODULE(mapmos_pybind, m) { m, "_Vector3dVector", "std::vector", py::py_array_to_vectors_double); + m.def( + "_deskew", + [](const std::vector &points, const std::vector ×tamps, + const Eigen::Matrix4d &relative_motion) { + Sophus::SE3d motion(relative_motion); + return Deskew(points, timestamps, motion); + }, + "frame"_a, "timestamps"_a, "relative_motion"_a); + // Map representation py::class_ internal_map(m, "_VoxelHashMap", "Don't use this"); internal_map From 0c84e60f35f4e1e09a2ea05bf972ba4d8c9955d2 Mon Sep 17 00:00:00 2001 From: Benedikt Mersch Date: Thu, 16 Jan 2025 17:19:29 +0100 Subject: [PATCH 02/11] Fix deskewing --- src/mapmos/odometry.py | 10 ++++++---- src/mapmos/paper_pipeline.py | 4 +++- src/mapmos/pipeline.py | 5 ++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mapmos/odometry.py b/src/mapmos/odometry.py index 61df476..4324fbd 100644 --- a/src/mapmos/odometry.py +++ b/src/mapmos/odometry.py @@ -97,10 +97,12 @@ def current_location(self): def deskew(self, points, timestamps, relative_motion): return ( - mapmos_pybind._deskew( - frame=mapmos_pybind._Vector3dVector(points), - timestamps=timestamps.ravel(), - relative_motion=relative_motion, + np.asarray( + mapmos_pybind._deskew( + frame=mapmos_pybind._Vector3dVector(points), + timestamps=timestamps.ravel(), + relative_motion=relative_motion, + ) ) if self.config.data.deskew else points diff --git a/src/mapmos/paper_pipeline.py b/src/mapmos/paper_pipeline.py index 9a78d49..a4d1317 100644 --- a/src/mapmos/paper_pipeline.py +++ b/src/mapmos/paper_pipeline.py @@ -72,10 +72,12 @@ def _run_pipeline(self): for scan_index in pbar: local_scan, timestamps, gt_labels = self._next(scan_index) map_points, map_indices = self.odometry.get_map_points() + + last_delta = copy.copy(self.odometry.last_delta) self.odometry.register_points(local_scan, timestamps, scan_index) self.poses[scan_index - self._first] = self.odometry.last_pose - scan_points = self.odometry.deskew(local_scan, timestamps, self.odometry.last_delta) + scan_points = self.odometry.deskew(local_scan, timestamps, last_delta) scan_points = self._transform(scan_points, self.odometry.last_pose) min_range_mos = self.config.mos.min_range_mos diff --git a/src/mapmos/pipeline.py b/src/mapmos/pipeline.py index 2da1eeb..19c815b 100644 --- a/src/mapmos/pipeline.py +++ b/src/mapmos/pipeline.py @@ -20,6 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import copy import os import time from collections import deque @@ -131,10 +132,12 @@ def _run_pipeline(self): for scan_index in pbar: local_scan, timestamps, gt_labels = self._next(scan_index) map_points, map_indices = self.odometry.get_map_points() + + last_delta = copy.copy(self.odometry.last_delta) self.odometry.register_points(local_scan, timestamps, scan_index) self.poses[scan_index - self._first] = self.odometry.last_pose - scan_points = self.odometry.deskew(local_scan, timestamps, self.odometry.last_delta) + scan_points = self.odometry.deskew(local_scan, timestamps, last_delta) scan_points = self._transform(scan_points, self.odometry.last_pose) min_range_mos = self.config.mos.min_range_mos From daa72bffffdf453a492d12f20a825dd22a038e5b Mon Sep 17 00:00:00 2001 From: Benedikt Mersch Date: Thu, 16 Jan 2025 17:23:03 +0100 Subject: [PATCH 03/11] Add copy and update dependency --- pyproject.toml | 2 +- src/mapmos/paper_pipeline.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 883c95d..e75ac01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ authors = [ ] license_files = "LICENSE" dependencies = [ - "kiss-icp<=1.1.0", + "kiss-icp>=1.2.0", "diskcache>=5.3.0", "pytorch_lightning>=1.6.4", ] diff --git a/src/mapmos/paper_pipeline.py b/src/mapmos/paper_pipeline.py index a4d1317..6285e1e 100644 --- a/src/mapmos/paper_pipeline.py +++ b/src/mapmos/paper_pipeline.py @@ -20,6 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import copy import time from pathlib import Path from typing import Optional From 1c31fb5efad5995118c6ce1a19255a5c4713169f Mon Sep 17 00:00:00 2001 From: Benedikt Mersch Date: Thu, 16 Jan 2025 17:35:17 +0100 Subject: [PATCH 04/11] Move into odometry --- src/mapmos/odometry.py | 15 ++++++++++++--- src/mapmos/paper_pipeline.py | 7 +------ src/mapmos/pipeline.py | 12 +----------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/mapmos/odometry.py b/src/mapmos/odometry.py index 4324fbd..1fb2cf4 100644 --- a/src/mapmos/odometry.py +++ b/src/mapmos/odometry.py @@ -60,10 +60,10 @@ def __init__( def register_points(self, points, timestamps, scan_index): # Apply motion compensation - points = self.preprocessor.preprocess(points, timestamps, self.last_delta) + points_prep = self.preprocessor.preprocess(points, timestamps, self.last_delta) # Voxelize - source, points_downsample = self.voxelize(points) + source, points_downsample = self.voxelize(points_prep) # Get motion prediction and adaptive_threshold sigma = self.adaptive_threshold.get_threshold() @@ -79,6 +79,8 @@ def register_points(self, points, timestamps, scan_index): kernel=sigma / 3, ) + point_deskewed = self.deskew(points, timestamps, self.last_delta) + # Compute the difference between the prediction and the actual estimate model_deviation = np.linalg.inv(initial_guess) @ new_pose @@ -88,6 +90,8 @@ def register_points(self, points, timestamps, scan_index): self.last_delta = np.linalg.inv(self.last_pose) @ new_pose self.last_pose = new_pose + return self.transform(point_deskewed, self.last_pose) + def get_map_points(self): map_points, map_timestamps = self.local_map.point_cloud_with_timestamps() return map_points.reshape(-1, 3), map_timestamps.reshape(-1, 1) @@ -95,12 +99,17 @@ def get_map_points(self): def current_location(self): return self.last_pose[:3, 3] + def transform(self, points, pose): + points_hom = np.hstack((points, np.ones((len(points), 1)))) + points = (pose @ points_hom.T).T[:, :3] + return points + def deskew(self, points, timestamps, relative_motion): return ( np.asarray( mapmos_pybind._deskew( frame=mapmos_pybind._Vector3dVector(points), - timestamps=timestamps.ravel(), + timestamps=timestamps, relative_motion=relative_motion, ) ) diff --git a/src/mapmos/paper_pipeline.py b/src/mapmos/paper_pipeline.py index 6285e1e..cf31f82 100644 --- a/src/mapmos/paper_pipeline.py +++ b/src/mapmos/paper_pipeline.py @@ -20,7 +20,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import copy import time from pathlib import Path from typing import Optional @@ -74,13 +73,9 @@ def _run_pipeline(self): local_scan, timestamps, gt_labels = self._next(scan_index) map_points, map_indices = self.odometry.get_map_points() - last_delta = copy.copy(self.odometry.last_delta) - self.odometry.register_points(local_scan, timestamps, scan_index) + scan_points = self.odometry.register_points(local_scan, timestamps, scan_index) self.poses[scan_index - self._first] = self.odometry.last_pose - scan_points = self.odometry.deskew(local_scan, timestamps, last_delta) - scan_points = self._transform(scan_points, self.odometry.last_pose) - min_range_mos = self.config.mos.min_range_mos max_range_mos = self.config.mos.max_range_mos scan_mask = self._preprocess(scan_points, min_range_mos, max_range_mos) diff --git a/src/mapmos/pipeline.py b/src/mapmos/pipeline.py index 19c815b..e351a1a 100644 --- a/src/mapmos/pipeline.py +++ b/src/mapmos/pipeline.py @@ -20,7 +20,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import copy import os import time from collections import deque @@ -121,11 +120,6 @@ def _preprocess(self, points, min_range, max_range): mask = np.logical_and(mask, ranges >= min_range) return mask - def _transform(self, points, pose): - points_hom = np.hstack((points, np.ones((len(points), 1)))) - points = (pose @ points_hom.T).T[:, :3] - return points - # Private interface ------ def _run_pipeline(self): pbar = trange(self._first, self._last, unit=" frames", dynamic_ncols=True) @@ -133,13 +127,9 @@ def _run_pipeline(self): local_scan, timestamps, gt_labels = self._next(scan_index) map_points, map_indices = self.odometry.get_map_points() - last_delta = copy.copy(self.odometry.last_delta) - self.odometry.register_points(local_scan, timestamps, scan_index) + scan_points = self.odometry.register_points(local_scan, timestamps, scan_index) self.poses[scan_index - self._first] = self.odometry.last_pose - scan_points = self.odometry.deskew(local_scan, timestamps, last_delta) - scan_points = self._transform(scan_points, self.odometry.last_pose) - min_range_mos = self.config.mos.min_range_mos max_range_mos = self.config.mos.max_range_mos scan_mask = self._preprocess(scan_points, min_range_mos, max_range_mos) From 731ba0cd7248292e5e678dfb345bc0e0c2708aef Mon Sep 17 00:00:00 2001 From: Benedikt Mersch Date: Fri, 17 Jan 2025 10:08:43 +0100 Subject: [PATCH 05/11] Use cache@v4 --- .github/workflows/cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index a3bbfe7..fb64c7c 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -42,7 +42,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.apt/cache key: ${{ runner.os }}-apt-${{ hashFiles('**/ubuntu_dependencies.yml') }} From d903fbfdd6457bb93e9a4715abc7314f7ac040de Mon Sep 17 00:00:00 2001 From: Benedikt Mersch Date: Fri, 17 Jan 2025 10:19:38 +0100 Subject: [PATCH 06/11] Test this --- .github/workflows/python.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 048dbef..98e657f 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -20,5 +20,9 @@ jobs: run: python -m pip install --upgrade pip - name: Build pip package run: python -m pip install --verbose . + - name: Test pybind + run: python3 -c "from mapmos.pybind import mapmos_pybind" + - name: Test pipeline + run: python3 -c "from mapmos.pipeline import pipeline" - name: Test installation run: mapmos_pipeline --help From 61491f065faca3f93f359197f46e87a6eba287f4 Mon Sep 17 00:00:00 2001 From: Benedikt Mersch Date: Fri, 17 Jan 2025 10:39:12 +0100 Subject: [PATCH 07/11] Cosmetics --- src/mapmos/pybind/Deskew.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mapmos/pybind/Deskew.cpp b/src/mapmos/pybind/Deskew.cpp index 08d02a5..0655fac 100644 --- a/src/mapmos/pybind/Deskew.cpp +++ b/src/mapmos/pybind/Deskew.cpp @@ -36,12 +36,13 @@ #include namespace mapmos { -static const auto tbb_control_settings = tbb::global_control( - tbb::global_control::max_allowed_parallelism, tbb::this_task_arena::max_concurrency()); std::vector Deskew(const std::vector &frame, const std::vector ×tamps, const Sophus::SE3d &relative_motion) { + static const auto tbb_control_settings = tbb::global_control( + tbb::global_control::max_allowed_parallelism, tbb::this_task_arena::max_concurrency()); + const std::vector &deskewed_frame = [&]() { const auto &omega = relative_motion.log(); const Sophus::SE3d &inverse_motion = relative_motion.inverse(); @@ -62,4 +63,5 @@ std::vector Deskew(const std::vector &frame, }(); return deskewed_frame; } + } // namespace mapmos From bdce66a8e2ce0a9b609d1a11b62c2656525a2ea5 Mon Sep 17 00:00:00 2001 From: Benedikt Mersch Date: Fri, 17 Jan 2025 10:44:49 +0100 Subject: [PATCH 08/11] Remove again --- .github/workflows/python.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 98e657f..048dbef 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -20,9 +20,5 @@ jobs: run: python -m pip install --upgrade pip - name: Build pip package run: python -m pip install --verbose . - - name: Test pybind - run: python3 -c "from mapmos.pybind import mapmos_pybind" - - name: Test pipeline - run: python3 -c "from mapmos.pipeline import pipeline" - name: Test installation run: mapmos_pipeline --help From 0979f1fe49601676986eeb75fc4a5921ab691f58 Mon Sep 17 00:00:00 2001 From: Benedikt Mersch Date: Fri, 17 Jan 2025 10:56:49 +0100 Subject: [PATCH 09/11] Clean up --- src/mapmos/pybind/Deskew.cpp | 7 ------- src/mapmos/pybind/Deskew.hpp | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mapmos/pybind/Deskew.cpp b/src/mapmos/pybind/Deskew.cpp index 0655fac..3c96b2b 100644 --- a/src/mapmos/pybind/Deskew.cpp +++ b/src/mapmos/pybind/Deskew.cpp @@ -23,11 +23,7 @@ #include "Deskew.hpp" #include -#include -#include -#include #include -#include #include #include @@ -40,9 +36,6 @@ namespace mapmos { std::vector Deskew(const std::vector &frame, const std::vector ×tamps, const Sophus::SE3d &relative_motion) { - static const auto tbb_control_settings = tbb::global_control( - tbb::global_control::max_allowed_parallelism, tbb::this_task_arena::max_concurrency()); - const std::vector &deskewed_frame = [&]() { const auto &omega = relative_motion.log(); const Sophus::SE3d &inverse_motion = relative_motion.inverse(); diff --git a/src/mapmos/pybind/Deskew.hpp b/src/mapmos/pybind/Deskew.hpp index 83e1114..1bfaf33 100644 --- a/src/mapmos/pybind/Deskew.hpp +++ b/src/mapmos/pybind/Deskew.hpp @@ -21,13 +21,20 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #pragma once +#include +#include #include #include #include namespace mapmos { + +static const auto tbb_control_settings = tbb::global_control( + tbb::global_control::max_allowed_parallelism, tbb::this_task_arena::max_concurrency()); + std::vector Deskew(const std::vector &frame, const std::vector ×tamps, const Sophus::SE3d &relative_motion); + } // namespace mapmos From ad6e4752326a781c041ca26df3690e32a8a6110a Mon Sep 17 00:00:00 2001 From: Benedikt Mersch Date: Fri, 17 Jan 2025 11:00:16 +0100 Subject: [PATCH 10/11] Move back here --- src/mapmos/pybind/Deskew.cpp | 3 +++ src/mapmos/pybind/Deskew.hpp | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mapmos/pybind/Deskew.cpp b/src/mapmos/pybind/Deskew.cpp index 3c96b2b..436be59 100644 --- a/src/mapmos/pybind/Deskew.cpp +++ b/src/mapmos/pybind/Deskew.cpp @@ -36,6 +36,9 @@ namespace mapmos { std::vector Deskew(const std::vector &frame, const std::vector ×tamps, const Sophus::SE3d &relative_motion) { + static const auto tbb_control_settings = tbb::global_control( + tbb::global_control::max_allowed_parallelism, tbb::this_task_arena::max_concurrency()); + const std::vector &deskewed_frame = [&]() { const auto &omega = relative_motion.log(); const Sophus::SE3d &inverse_motion = relative_motion.inverse(); diff --git a/src/mapmos/pybind/Deskew.hpp b/src/mapmos/pybind/Deskew.hpp index 1bfaf33..c05bd71 100644 --- a/src/mapmos/pybind/Deskew.hpp +++ b/src/mapmos/pybind/Deskew.hpp @@ -30,9 +30,6 @@ namespace mapmos { -static const auto tbb_control_settings = tbb::global_control( - tbb::global_control::max_allowed_parallelism, tbb::this_task_arena::max_concurrency()); - std::vector Deskew(const std::vector &frame, const std::vector ×tamps, const Sophus::SE3d &relative_motion); From b14ba897a277132e8ecd696a046d6803bf61f65a Mon Sep 17 00:00:00 2001 From: Benedikt Mersch Date: Fri, 17 Jan 2025 11:06:10 +0100 Subject: [PATCH 11/11] Just use the default --- src/mapmos/pybind/Deskew.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mapmos/pybind/Deskew.cpp b/src/mapmos/pybind/Deskew.cpp index 436be59..3c96b2b 100644 --- a/src/mapmos/pybind/Deskew.cpp +++ b/src/mapmos/pybind/Deskew.cpp @@ -36,9 +36,6 @@ namespace mapmos { std::vector Deskew(const std::vector &frame, const std::vector ×tamps, const Sophus::SE3d &relative_motion) { - static const auto tbb_control_settings = tbb::global_control( - tbb::global_control::max_allowed_parallelism, tbb::this_task_arena::max_concurrency()); - const std::vector &deskewed_frame = [&]() { const auto &omega = relative_motion.log(); const Sophus::SE3d &inverse_motion = relative_motion.inverse();