From ba993946e9985e27ea7c7fc94ae6fa9915cb4b35 Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 12:35:36 +0200 Subject: [PATCH 01/14] Refactored project structure, added pyproject.toml in preparation for pypi publishing --- mad-icp/apps/mad-icp.py | 161 --------------- mad-icp/src/odometry/CMakeLists.txt | 18 -- mad-icp/src/odometry/pybind/pypeline.cpp | 50 ----- {mad-icp => mad_icp}/.clang-format | 0 {mad-icp => mad_icp}/CMakeLists.txt | 10 +- mad_icp/__init__.py | 0 mad_icp/apps/__init__.py | 0 .../apps/cpp_runners/CMakeLists.txt | 0 .../apps/cpp_runners/bin_runner.cpp | 0 .../cpp_runners/cpp_utils/parse_cmd_line.h | 0 mad_icp/apps/mad_icp.py | 185 ++++++++++++++++++ .../apps/utils/kitti_reader.py | 0 .../apps/utils/point_cloud2.py | 0 {mad-icp => mad_icp}/apps/utils/ros_reader.py | 19 +- {mad-icp => mad_icp}/apps/utils/utils.py | 0 {mad-icp => mad_icp}/apps/utils/visualizer.py | 0 .../configurations/datasets/hilti_2021.cfg | 0 .../configurations/datasets/kitti.cfg | 0 .../configurations/datasets/mulran.cfg | 0 .../datasets/newer_college_os0.cfg | 0 .../datasets/newer_college_os1.cfg | 0 .../configurations/datasets/vbr_os0.cfg | 0 .../configurations/datasets/vbr_os1.cfg | 0 .../configurations/params.cfg | 0 {mad-icp => mad_icp}/requirements.txt | 0 {mad-icp => mad_icp}/src/CMakeLists.txt | 2 +- mad_icp/src/odometry/CMakeLists.txt | 11 ++ {mad-icp => mad_icp}/src/odometry/mad_icp.cpp | 0 {mad-icp => mad_icp}/src/odometry/mad_icp.h | 0 .../src/odometry/pipeline.cpp | 0 {mad-icp => mad_icp}/src/odometry/pipeline.h | 0 .../src/odometry/vel_estimator.cpp | 0 .../src/odometry/vel_estimator.h | 0 mad_icp/src/pybind/CMakeLists.txt | 7 + .../src}/pybind/eigen_stl_bindings.h | 0 mad_icp/src/pybind/pypeline.cpp | 47 +++++ {mad-icp => mad_icp}/src/tools/CMakeLists.txt | 2 +- {mad-icp => mad_icp}/src/tools/constants.h | 0 {mad-icp => mad_icp}/src/tools/frame.h | 0 {mad-icp => mad_icp}/src/tools/lie_algebra.h | 0 {mad-icp => mad_icp}/src/tools/mad_tree.cpp | 0 {mad-icp => mad_icp}/src/tools/mad_tree.h | 0 {mad-icp => mad_icp}/src/tools/utils.h | 0 pyproject.toml | 46 +++++ 44 files changed, 316 insertions(+), 242 deletions(-) delete mode 100755 mad-icp/apps/mad-icp.py delete mode 100755 mad-icp/src/odometry/CMakeLists.txt delete mode 100755 mad-icp/src/odometry/pybind/pypeline.cpp rename {mad-icp => mad_icp}/.clang-format (100%) rename {mad-icp => mad_icp}/CMakeLists.txt (75%) create mode 100644 mad_icp/__init__.py create mode 100644 mad_icp/apps/__init__.py rename {mad-icp => mad_icp}/apps/cpp_runners/CMakeLists.txt (100%) rename {mad-icp => mad_icp}/apps/cpp_runners/bin_runner.cpp (100%) rename {mad-icp => mad_icp}/apps/cpp_runners/cpp_utils/parse_cmd_line.h (100%) create mode 100755 mad_icp/apps/mad_icp.py rename {mad-icp => mad_icp}/apps/utils/kitti_reader.py (100%) rename {mad-icp => mad_icp}/apps/utils/point_cloud2.py (100%) rename {mad-icp => mad_icp}/apps/utils/ros_reader.py (85%) rename {mad-icp => mad_icp}/apps/utils/utils.py (100%) rename {mad-icp => mad_icp}/apps/utils/visualizer.py (100%) rename {mad-icp => mad_icp}/configurations/datasets/hilti_2021.cfg (100%) rename {mad-icp => mad_icp}/configurations/datasets/kitti.cfg (100%) rename {mad-icp => mad_icp}/configurations/datasets/mulran.cfg (100%) rename {mad-icp => mad_icp}/configurations/datasets/newer_college_os0.cfg (100%) rename {mad-icp => mad_icp}/configurations/datasets/newer_college_os1.cfg (100%) rename {mad-icp => mad_icp}/configurations/datasets/vbr_os0.cfg (100%) rename {mad-icp => mad_icp}/configurations/datasets/vbr_os1.cfg (100%) rename {mad-icp => mad_icp}/configurations/params.cfg (100%) rename {mad-icp => mad_icp}/requirements.txt (100%) rename {mad-icp => mad_icp}/src/CMakeLists.txt (67%) create mode 100755 mad_icp/src/odometry/CMakeLists.txt rename {mad-icp => mad_icp}/src/odometry/mad_icp.cpp (100%) rename {mad-icp => mad_icp}/src/odometry/mad_icp.h (100%) rename {mad-icp => mad_icp}/src/odometry/pipeline.cpp (100%) rename {mad-icp => mad_icp}/src/odometry/pipeline.h (100%) rename {mad-icp => mad_icp}/src/odometry/vel_estimator.cpp (100%) rename {mad-icp => mad_icp}/src/odometry/vel_estimator.h (100%) create mode 100644 mad_icp/src/pybind/CMakeLists.txt rename {mad-icp/src/odometry => mad_icp/src}/pybind/eigen_stl_bindings.h (100%) create mode 100755 mad_icp/src/pybind/pypeline.cpp rename {mad-icp => mad_icp}/src/tools/CMakeLists.txt (77%) rename {mad-icp => mad_icp}/src/tools/constants.h (100%) rename {mad-icp => mad_icp}/src/tools/frame.h (100%) rename {mad-icp => mad_icp}/src/tools/lie_algebra.h (100%) rename {mad-icp => mad_icp}/src/tools/mad_tree.cpp (100%) rename {mad-icp => mad_icp}/src/tools/mad_tree.h (100%) rename {mad-icp => mad_icp}/src/tools/utils.h (100%) create mode 100644 pyproject.toml diff --git a/mad-icp/apps/mad-icp.py b/mad-icp/apps/mad-icp.py deleted file mode 100755 index 8a55eff..0000000 --- a/mad-icp/apps/mad-icp.py +++ /dev/null @@ -1,161 +0,0 @@ -# Copyright 2024 R(obots) V(ision) and P(erception) group -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -from pathlib import Path -import typer -from typing_extensions import Annotated -from rich.progress import track -from rich.console import Console -from enum import Enum -import os, sys, yaml -import numpy as np -from datetime import datetime -from utils.utils import write_transformed_pose -from utils.ros_reader import Ros1Reader -from utils.kitti_reader import KittiReader -from utils.visualizer import Visualizer - -sys.path.append("../build/src/odometry/") -# binded odometry -from pypeline import Pipeline, VectorEigen3d - - -console = Console() - -class InputDataInterface(str, Enum): - kitti = "kitti", - ros1 = "ros1", - # Can insert additional conversion formats - -InputDataInterface_lut = { - InputDataInterface.kitti: KittiReader, - InputDataInterface.ros1: Ros1Reader -} - -def main(data_path: Annotated[ - Path, typer.Option(help="path containing one or more rosbags (folder path)", show_default=False)], - estimate_path: Annotated[ - Path, typer.Option(help="trajectory estimate output path (folder path)", show_default=False)], - dataset_config: Annotated[ - Path, typer.Option(help="dataset configuration file", show_default=False)], - mad_icp_config: Annotated[ - Path, typer.Option(help="parameters for mad icp", show_default=True)] = "../configurations/params.cfg", - num_cores: Annotated[ - int, typer.Option(help="how many threads to use for icp (suggest maximum num)", show_default=True)] = 4, - num_keyframes: Annotated[ - int, typer.Option(help="max number of kf kept in the local map (suggest as num threads)", show_default=True)] = 4, - realtime: Annotated[ - bool, typer.Option(help="if true anytime realtime", show_default=True)] = False, - noviz: Annotated[ - bool, typer.Option(help="if true visualizer on", show_default=True)] = False) -> None: - - if not data_path.is_dir() or not estimate_path.is_dir() or not dataset_config.is_file(): - console.print("[red] Input dir or file not correct") - sys.exit(-1) - - visualizer = None - if not noviz: - visualizer = Visualizer() - - reader_type = InputDataInterface.kitti - if len(list(data_path.glob("*.bag"))) != 0: - console.print("[yellow] The dataset is in rosbag format") - reader_type = InputDataInterface.ros1 - else: - console.print("[yellow] The dataset is in kitti format") - - console.print("[green] Parsing dataset configuration file") - data_config_file = open(dataset_config, 'r') - data_cf = yaml.safe_load(data_config_file) - min_range = data_cf["min_range"] - max_range = data_cf["max_range"] - sensor_hz = data_cf["sensor_hz"] - deskew = data_cf["deskew"] - topic = None - if reader_type == InputDataInterface.ros1 : - topic = data_cf["rosbag_topic"] - lidar_to_base = np.array(data_cf["lidar_to_base"]) - - console.print("[green] Parsing mad-icp configuration file") - mad_icp_config_file = open(mad_icp_config, 'r') - mad_icp_cf = yaml.safe_load(mad_icp_config_file) - b_max = mad_icp_cf["b_max"] - b_min = mad_icp_cf["b_min"] - b_ratio = mad_icp_cf["b_ratio"] - p_th = mad_icp_cf["p_th"] - rho_ker = mad_icp_cf["rho_ker"] - n = mad_icp_cf["n"] - - # check some params for machine - if(realtime and num_keyframes > num_cores): - console.print("[red] If you chose realtime option, we suggest to chose a num_cores at least >= than the num_keyframes") - sys.exit(-1) - - console.print("[green] Setting up pipeline for odometry estimation") - pipeline = Pipeline(sensor_hz, deskew, b_max, rho_ker, p_th, b_min, b_ratio, num_keyframes, num_cores, realtime) - - estimate_file_name = estimate_path / "estimate.txt" - estimate_file = open(estimate_file_name, 'w') - - with InputDataInterface_lut[reader_type](data_path, min_range, max_range, topic=topic, sensor_hz=sensor_hz) as reader: - t_start = datetime.now() - for ts, points in track(reader, description="processing..."): - - print("Loading frame #", pipeline.currentID()) - - points = VectorEigen3d(points) - t_end = datetime.now() - t_delta = t_end - t_start - print("Time for reading points [ms]: ", t_delta.total_seconds() * 1000) - - t_start = datetime.now() - pipeline.compute(ts, points) - t_end = datetime.now() - t_delta = t_end - t_start - print("Time for odometry estimation [ms]: ", t_delta.total_seconds() * 1000) - - lidar_to_world = pipeline.currentPose() - write_transformed_pose(estimate_file, lidar_to_world, lidar_to_base) - - if not noviz: - t_start = datetime.now() - if pipeline.isMapUpdated(): - visualizer.update(pipeline.currentLeaves(), pipeline.modelLeaves(), lidar_to_world, pipeline.keyframePose()) - else: - visualizer.update(pipeline.currentLeaves(), None, lidar_to_world, None) - t_end = datetime.now() - t_delta = t_end - t_start - print("Time for visualization [ms]:", t_delta.total_seconds() * 1000, "\n") - - t_start = datetime.now() - - estimate_file.close() - - -if __name__ == '__main__': - typer.run(main) \ No newline at end of file diff --git a/mad-icp/src/odometry/CMakeLists.txt b/mad-icp/src/odometry/CMakeLists.txt deleted file mode 100755 index fe88177..0000000 --- a/mad-icp/src/odometry/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -add_library(odometry SHARED - vel_estimator.cpp - pipeline.cpp - mad_icp.cpp -) - -target_link_libraries(odometry - tools -) - -target_compile_features(odometry PUBLIC) - -pybind11_add_module(pypeline pybind/pypeline.cpp) -target_link_libraries(pypeline PUBLIC - odometry - tools -) - diff --git a/mad-icp/src/odometry/pybind/pypeline.cpp b/mad-icp/src/odometry/pybind/pypeline.cpp deleted file mode 100755 index ad235c2..0000000 --- a/mad-icp/src/odometry/pybind/pypeline.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// pybind11 -#include -#include -#include -#include -#include -#include -#include -#include - -// std stuff -#include -#include -#include - -#include "../pipeline.h" -#include "eigen_stl_bindings.h" - -PYBIND11_MAKE_OPAQUE(std::vector); - -namespace py11 = pybind11; -using namespace py11::literals; - -PYBIND11_MODULE(pypeline, m) { - auto vector3dvector = pybind_eigen_vector_of_vector( - m, "VectorEigen3d", "std::vector", py11::py_array_to_vectors_double); - - auto pipeline = py11::class_(m, "Pipeline") - .def(py11::init(), - py11::arg("sensor_hz"), - py11::arg("deskew"), - py11::arg("b_max"), - py11::arg("rho_ker"), - py11::arg("p_th"), - py11::arg("b_min"), - py11::arg("b_ratio"), - py11::arg("num_keyframes"), - py11::arg("num_threads"), - py11::arg("realtime")) - .def("currentPose", &Pipeline::currentPose) - .def("trajectory", &Pipeline::trajectory) - .def("keyframePose", &Pipeline::keyframePose) - .def("isInitialized", &Pipeline::isInitialized) - .def("isMapUpdated", &Pipeline::isMapUpdated) - .def("currentID", &Pipeline::currentID) - .def("keyframeID", &Pipeline::keyframeID) - .def("modelLeaves", &Pipeline::modelLeaves) - .def("currentLeaves", &Pipeline::currentLeaves) - .def("compute", &Pipeline::compute); -} diff --git a/mad-icp/.clang-format b/mad_icp/.clang-format similarity index 100% rename from mad-icp/.clang-format rename to mad_icp/.clang-format diff --git a/mad-icp/CMakeLists.txt b/mad_icp/CMakeLists.txt similarity index 75% rename from mad-icp/CMakeLists.txt rename to mad_icp/CMakeLists.txt index 425d137..16df2f6 100755 --- a/mad-icp/CMakeLists.txt +++ b/mad_icp/CMakeLists.txt @@ -1,6 +1,7 @@ +# TODO: Change version to at least 3.11 and include FetchContent for Eigen cmake_minimum_required(VERSION 3.8 FATAL_ERROR) -project(mad-icp LANGUAGES CXX) +project(mad_icp LANGUAGES CXX) set(CMAKE_BUILD_TYPE Release) set(CMAKE_CXX_STANDARD 17) @@ -10,12 +11,14 @@ set(CMAKE_CXX_FLAGS -Werror) # if need to compile C++ apps, when executing CMake run `cmake -DCOMPILE_CPP_APPS=ON ..` option(COMPILE_CPP_APPS "Set to ON to compile C++ applications" OFF) -# Eigen +# Eigen +# TODO: Detect if Eigen exists in system, oterwhise, download it through FetchContent find_package(Eigen3 3.3 REQUIRED NO_MODULE) -# OpenMP +# OpenMP find_package(OpenMP REQUIRED) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Python bindings find_package(pybind11 REQUIRED) @@ -27,5 +30,6 @@ include_directories( ) add_subdirectory(src) + # TODO only if one wants to build cpp runners add_subdirectory(apps/cpp_runners) \ No newline at end of file diff --git a/mad_icp/__init__.py b/mad_icp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mad_icp/apps/__init__.py b/mad_icp/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mad-icp/apps/cpp_runners/CMakeLists.txt b/mad_icp/apps/cpp_runners/CMakeLists.txt similarity index 100% rename from mad-icp/apps/cpp_runners/CMakeLists.txt rename to mad_icp/apps/cpp_runners/CMakeLists.txt diff --git a/mad-icp/apps/cpp_runners/bin_runner.cpp b/mad_icp/apps/cpp_runners/bin_runner.cpp similarity index 100% rename from mad-icp/apps/cpp_runners/bin_runner.cpp rename to mad_icp/apps/cpp_runners/bin_runner.cpp diff --git a/mad-icp/apps/cpp_runners/cpp_utils/parse_cmd_line.h b/mad_icp/apps/cpp_runners/cpp_utils/parse_cmd_line.h similarity index 100% rename from mad-icp/apps/cpp_runners/cpp_utils/parse_cmd_line.h rename to mad_icp/apps/cpp_runners/cpp_utils/parse_cmd_line.h diff --git a/mad_icp/apps/mad_icp.py b/mad_icp/apps/mad_icp.py new file mode 100755 index 0000000..d4e46ed --- /dev/null +++ b/mad_icp/apps/mad_icp.py @@ -0,0 +1,185 @@ +# Copyright 2024 R(obots) V(ision) and P(erception) group +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +from pathlib import Path +import typer +from typing_extensions import Annotated +from rich.progress import track +from rich.console import Console +from enum import Enum +import os +import sys +import yaml +import numpy as np +from datetime import datetime +from mad_icp.apps.utils.utils import write_transformed_pose +from mad_icp.apps.utils.ros_reader import Ros1Reader +from mad_icp.apps.utils.kitti_reader import KittiReader +from mad_icp.apps.utils.visualizer import Visualizer +# binded Odometry +from mad_icp.src.pybind.pypeline import Pipeline, VectorEigen3d + + +console = Console() + + +class InputDataInterface(str, Enum): + kitti = "kitti", + ros1 = "ros1", + # Can insert additional conversion formats + + +InputDataInterface_lut = { + InputDataInterface.kitti: KittiReader, + InputDataInterface.ros1: Ros1Reader +} + + +def main(data_path: Annotated[ + Path, typer.Option(help="path containing one or more rosbags (folder path)", show_default=False)], + estimate_path: Annotated[ + Path, typer.Option(help="trajectory estimate output path (folder path)", show_default=False)], + dataset_config: Annotated[ + Path, typer.Option(help="dataset configuration file", show_default=False)], + mad_icp_config: Annotated[ + Path, typer.Option(help="parameters for mad icp", show_default=True)] = "../configurations/params.cfg", + num_cores: Annotated[ + int, typer.Option(help="how many threads to use for icp (suggest maximum num)", show_default=True)] = 4, + num_keyframes: Annotated[ + int, typer.Option(help="max number of kf kept in the local map (suggest as num threads)", show_default=True)] = 4, + realtime: Annotated[ + bool, typer.Option(help="if true anytime realtime", show_default=True)] = False, + noviz: Annotated[ + bool, typer.Option(help="if true visualizer on", show_default=True)] = False) -> None: + + if not data_path.exists(): + console.print(f"[red] {data_path} does not exist!") + sys.exit(-1) + if not estimate_path.is_dir(): + console.print( + f"[yellow] Output directory {estimate_path} does not exist. Creating new directory") + estimate_path.mkdir(parents=True, exist_ok=True) + + if not dataset_config.is_file(): + console.print( + f"[red] Dataset config file {dataset_config} does not exist!") + sys.exit(-1) + + visualizer = None + if not noviz: + visualizer = Visualizer() + + reader_type = InputDataInterface.kitti + if len(list(data_path.glob("*.bag"))) != 0: + console.print("[yellow] The dataset is in rosbag format") + reader_type = InputDataInterface.ros1 + else: + console.print("[yellow] The dataset is in kitti format") + + console.print("[green] Parsing dataset configuration file") + data_config_file = open(dataset_config, 'r') + data_cf = yaml.safe_load(data_config_file) + min_range = data_cf["min_range"] + max_range = data_cf["max_range"] + sensor_hz = data_cf["sensor_hz"] + deskew = data_cf["deskew"] + topic = None + if reader_type == InputDataInterface.ros1: + topic = data_cf["rosbag_topic"] + lidar_to_base = np.array(data_cf["lidar_to_base"]) + + console.print("[green] Parsing mad-icp configuration file") + mad_icp_config_file = open(mad_icp_config, 'r') + mad_icp_cf = yaml.safe_load(mad_icp_config_file) + b_max = mad_icp_cf["b_max"] + b_min = mad_icp_cf["b_min"] + b_ratio = mad_icp_cf["b_ratio"] + p_th = mad_icp_cf["p_th"] + rho_ker = mad_icp_cf["rho_ker"] + n = mad_icp_cf["n"] + + # check some params for machine + if (realtime and num_keyframes > num_cores): + console.print( + "[red] If you chose realtime option, we suggest to chose a num_cores at least >= than the num_keyframes") + sys.exit(-1) + + console.print("[green] Setting up pipeline for odometry estimation") + pipeline = Pipeline(sensor_hz, deskew, b_max, rho_ker, + p_th, b_min, b_ratio, num_keyframes, num_cores, realtime) + + estimate_file_name = estimate_path / "estimate.txt" + estimate_file = open(estimate_file_name, 'w') + + with InputDataInterface_lut[reader_type](data_path, min_range, max_range, topic=topic, sensor_hz=sensor_hz) as reader: + t_start = datetime.now() + for ts, points in track(reader, description="processing..."): + + print("Loading frame #", pipeline.currentID()) + + points = VectorEigen3d(points) + t_end = datetime.now() + t_delta = t_end - t_start + print("Time for reading points [ms]: ", + t_delta.total_seconds() * 1000) + + t_start = datetime.now() + pipeline.compute(ts, points) + t_end = datetime.now() + t_delta = t_end - t_start + print( + "Time for odometry estimation [ms]: ", t_delta.total_seconds() * 1000) + + lidar_to_world = pipeline.currentPose() + write_transformed_pose( + estimate_file, lidar_to_world, lidar_to_base) + + if not noviz: + t_start = datetime.now() + if pipeline.isMapUpdated(): + visualizer.update(pipeline.currentLeaves(), pipeline.modelLeaves( + ), lidar_to_world, pipeline.keyframePose()) + else: + visualizer.update(pipeline.currentLeaves(), + None, lidar_to_world, None) + t_end = datetime.now() + t_delta = t_end - t_start + print("Time for visualization [ms]:", + t_delta.total_seconds() * 1000, "\n") + + t_start = datetime.now() + + estimate_file.close() + + +def run(): + typer.run(main) + + +if __name__ == '__main__': + run() diff --git a/mad-icp/apps/utils/kitti_reader.py b/mad_icp/apps/utils/kitti_reader.py similarity index 100% rename from mad-icp/apps/utils/kitti_reader.py rename to mad_icp/apps/utils/kitti_reader.py diff --git a/mad-icp/apps/utils/point_cloud2.py b/mad_icp/apps/utils/point_cloud2.py similarity index 100% rename from mad-icp/apps/utils/point_cloud2.py rename to mad_icp/apps/utils/point_cloud2.py diff --git a/mad-icp/apps/utils/ros_reader.py b/mad_icp/apps/utils/ros_reader.py similarity index 85% rename from mad-icp/apps/utils/ros_reader.py rename to mad_icp/apps/utils/ros_reader.py index 3de8154..e71bb21 100644 --- a/mad-icp/apps/utils/ros_reader.py +++ b/mad_icp/apps/utils/ros_reader.py @@ -31,12 +31,13 @@ from pathlib import Path from typing import Tuple import natsort -from utils.point_cloud2 import read_point_cloud +from mad_icp.apps.utils.point_cloud2 import read_point_cloud import numpy as np + class Ros1Reader: - def __init__(self, data_dir: Path, min_range = 0, - max_range = 200, *args, **kwargs): + def __init__(self, data_dir: Path, min_range=0, + max_range=200, *args, **kwargs): """ :param data_dir: Directory containing rosbags or path to a rosbag file :param topics: Topic to read @@ -53,11 +54,12 @@ def __init__(self, data_dir: Path, min_range = 0, sys.exit(-1) if data_dir.is_file(): - #self.sequence_id = os.path.basename(data_dir).split(".")[0] + # self.sequence_id = os.path.basename(data_dir).split(".")[0] self.bag = AnyReader([data_dir]) else: - #self.sequence_id = os.path.basename(data_dir[0]).split(".")[0] - self.bag = AnyReader(natsort.natsorted([bag for bag in list(data_dir.glob("*.bag"))])) + # self.sequence_id = os.path.basename(data_dir[0]).split(".")[0] + self.bag = AnyReader(natsort.natsorted( + [bag for bag in list(data_dir.glob("*.bag"))])) print("Reading multiple .bag files in directory:") print("\n".join([path.name for path in self.bag.paths])) @@ -90,5 +92,6 @@ def __getitem__(self, item) -> Tuple[float, Tuple[np.ndarray, np.ndarray]]: connection, timestamp, rawdata = next(self.msgs) msg = self.bag.deserialize(rawdata, connection.msgtype) cloud_stamp = msg.header.stamp.sec + msg.header.stamp.nanosec * 1e-9 - points, _ = read_point_cloud(msg, min_range=self.min_range, max_range=self.max_range) - return timestamp, points \ No newline at end of file + points, _ = read_point_cloud( + msg, min_range=self.min_range, max_range=self.max_range) + return timestamp, points diff --git a/mad-icp/apps/utils/utils.py b/mad_icp/apps/utils/utils.py similarity index 100% rename from mad-icp/apps/utils/utils.py rename to mad_icp/apps/utils/utils.py diff --git a/mad-icp/apps/utils/visualizer.py b/mad_icp/apps/utils/visualizer.py similarity index 100% rename from mad-icp/apps/utils/visualizer.py rename to mad_icp/apps/utils/visualizer.py diff --git a/mad-icp/configurations/datasets/hilti_2021.cfg b/mad_icp/configurations/datasets/hilti_2021.cfg similarity index 100% rename from mad-icp/configurations/datasets/hilti_2021.cfg rename to mad_icp/configurations/datasets/hilti_2021.cfg diff --git a/mad-icp/configurations/datasets/kitti.cfg b/mad_icp/configurations/datasets/kitti.cfg similarity index 100% rename from mad-icp/configurations/datasets/kitti.cfg rename to mad_icp/configurations/datasets/kitti.cfg diff --git a/mad-icp/configurations/datasets/mulran.cfg b/mad_icp/configurations/datasets/mulran.cfg similarity index 100% rename from mad-icp/configurations/datasets/mulran.cfg rename to mad_icp/configurations/datasets/mulran.cfg diff --git a/mad-icp/configurations/datasets/newer_college_os0.cfg b/mad_icp/configurations/datasets/newer_college_os0.cfg similarity index 100% rename from mad-icp/configurations/datasets/newer_college_os0.cfg rename to mad_icp/configurations/datasets/newer_college_os0.cfg diff --git a/mad-icp/configurations/datasets/newer_college_os1.cfg b/mad_icp/configurations/datasets/newer_college_os1.cfg similarity index 100% rename from mad-icp/configurations/datasets/newer_college_os1.cfg rename to mad_icp/configurations/datasets/newer_college_os1.cfg diff --git a/mad-icp/configurations/datasets/vbr_os0.cfg b/mad_icp/configurations/datasets/vbr_os0.cfg similarity index 100% rename from mad-icp/configurations/datasets/vbr_os0.cfg rename to mad_icp/configurations/datasets/vbr_os0.cfg diff --git a/mad-icp/configurations/datasets/vbr_os1.cfg b/mad_icp/configurations/datasets/vbr_os1.cfg similarity index 100% rename from mad-icp/configurations/datasets/vbr_os1.cfg rename to mad_icp/configurations/datasets/vbr_os1.cfg diff --git a/mad-icp/configurations/params.cfg b/mad_icp/configurations/params.cfg similarity index 100% rename from mad-icp/configurations/params.cfg rename to mad_icp/configurations/params.cfg diff --git a/mad-icp/requirements.txt b/mad_icp/requirements.txt similarity index 100% rename from mad-icp/requirements.txt rename to mad_icp/requirements.txt diff --git a/mad-icp/src/CMakeLists.txt b/mad_icp/src/CMakeLists.txt similarity index 67% rename from mad-icp/src/CMakeLists.txt rename to mad_icp/src/CMakeLists.txt index 50cbd4e..91a5fd1 100755 --- a/mad-icp/src/CMakeLists.txt +++ b/mad_icp/src/CMakeLists.txt @@ -1,3 +1,3 @@ add_subdirectory(tools) add_subdirectory(odometry) - +add_subdirectory(pybind) diff --git a/mad_icp/src/odometry/CMakeLists.txt b/mad_icp/src/odometry/CMakeLists.txt new file mode 100755 index 0000000..0959f68 --- /dev/null +++ b/mad_icp/src/odometry/CMakeLists.txt @@ -0,0 +1,11 @@ +add_library(odometry STATIC + vel_estimator.cpp + pipeline.cpp + mad_icp.cpp +) + +target_link_libraries(odometry + tools +) + +target_compile_features(odometry PUBLIC) \ No newline at end of file diff --git a/mad-icp/src/odometry/mad_icp.cpp b/mad_icp/src/odometry/mad_icp.cpp similarity index 100% rename from mad-icp/src/odometry/mad_icp.cpp rename to mad_icp/src/odometry/mad_icp.cpp diff --git a/mad-icp/src/odometry/mad_icp.h b/mad_icp/src/odometry/mad_icp.h similarity index 100% rename from mad-icp/src/odometry/mad_icp.h rename to mad_icp/src/odometry/mad_icp.h diff --git a/mad-icp/src/odometry/pipeline.cpp b/mad_icp/src/odometry/pipeline.cpp similarity index 100% rename from mad-icp/src/odometry/pipeline.cpp rename to mad_icp/src/odometry/pipeline.cpp diff --git a/mad-icp/src/odometry/pipeline.h b/mad_icp/src/odometry/pipeline.h similarity index 100% rename from mad-icp/src/odometry/pipeline.h rename to mad_icp/src/odometry/pipeline.h diff --git a/mad-icp/src/odometry/vel_estimator.cpp b/mad_icp/src/odometry/vel_estimator.cpp similarity index 100% rename from mad-icp/src/odometry/vel_estimator.cpp rename to mad_icp/src/odometry/vel_estimator.cpp diff --git a/mad-icp/src/odometry/vel_estimator.h b/mad_icp/src/odometry/vel_estimator.h similarity index 100% rename from mad-icp/src/odometry/vel_estimator.h rename to mad_icp/src/odometry/vel_estimator.h diff --git a/mad_icp/src/pybind/CMakeLists.txt b/mad_icp/src/pybind/CMakeLists.txt new file mode 100644 index 0000000..5e92b23 --- /dev/null +++ b/mad_icp/src/pybind/CMakeLists.txt @@ -0,0 +1,7 @@ +pybind11_add_module(pypeline MODULE pypeline.cpp) +target_link_libraries(pypeline PRIVATE + odometry + tools +) + +install(TARGETS pypeline DESTINATION .) \ No newline at end of file diff --git a/mad-icp/src/odometry/pybind/eigen_stl_bindings.h b/mad_icp/src/pybind/eigen_stl_bindings.h similarity index 100% rename from mad-icp/src/odometry/pybind/eigen_stl_bindings.h rename to mad_icp/src/pybind/eigen_stl_bindings.h diff --git a/mad_icp/src/pybind/pypeline.cpp b/mad_icp/src/pybind/pypeline.cpp new file mode 100755 index 0000000..bdbac5f --- /dev/null +++ b/mad_icp/src/pybind/pypeline.cpp @@ -0,0 +1,47 @@ +// pybind11 +#include +#include +#include +#include +#include +#include +#include +#include + +// std stuff +#include +#include +#include + +#include "eigen_stl_bindings.h" +#include "odometry/pipeline.h" + +PYBIND11_MAKE_OPAQUE(std::vector); + +namespace py11 = pybind11; +using namespace py11::literals; + +PYBIND11_MODULE(pypeline, m) { + auto vector3dvector = pybind_eigen_vector_of_vector( + m, "VectorEigen3d", "std::vector", + py11::py_array_to_vectors_double); + + auto pipeline = + py11::class_(m, "Pipeline") + .def(py11::init(), + py11::arg("sensor_hz"), py11::arg("deskew"), py11::arg("b_max"), + py11::arg("rho_ker"), py11::arg("p_th"), py11::arg("b_min"), + py11::arg("b_ratio"), py11::arg("num_keyframes"), + py11::arg("num_threads"), py11::arg("realtime")) + .def("currentPose", &Pipeline::currentPose) + .def("trajectory", &Pipeline::trajectory) + .def("keyframePose", &Pipeline::keyframePose) + .def("isInitialized", &Pipeline::isInitialized) + .def("isMapUpdated", &Pipeline::isMapUpdated) + .def("currentID", &Pipeline::currentID) + .def("keyframeID", &Pipeline::keyframeID) + .def("modelLeaves", &Pipeline::modelLeaves) + .def("currentLeaves", &Pipeline::currentLeaves) + .def("compute", &Pipeline::compute); +} diff --git a/mad-icp/src/tools/CMakeLists.txt b/mad_icp/src/tools/CMakeLists.txt similarity index 77% rename from mad-icp/src/tools/CMakeLists.txt rename to mad_icp/src/tools/CMakeLists.txt index dd7f8ad..35fe733 100755 --- a/mad-icp/src/tools/CMakeLists.txt +++ b/mad_icp/src/tools/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(tools SHARED +add_library(tools STATIC mad_tree.cpp ) diff --git a/mad-icp/src/tools/constants.h b/mad_icp/src/tools/constants.h similarity index 100% rename from mad-icp/src/tools/constants.h rename to mad_icp/src/tools/constants.h diff --git a/mad-icp/src/tools/frame.h b/mad_icp/src/tools/frame.h similarity index 100% rename from mad-icp/src/tools/frame.h rename to mad_icp/src/tools/frame.h diff --git a/mad-icp/src/tools/lie_algebra.h b/mad_icp/src/tools/lie_algebra.h similarity index 100% rename from mad-icp/src/tools/lie_algebra.h rename to mad_icp/src/tools/lie_algebra.h diff --git a/mad-icp/src/tools/mad_tree.cpp b/mad_icp/src/tools/mad_tree.cpp similarity index 100% rename from mad-icp/src/tools/mad_tree.cpp rename to mad_icp/src/tools/mad_tree.cpp diff --git a/mad-icp/src/tools/mad_tree.h b/mad_icp/src/tools/mad_tree.h similarity index 100% rename from mad-icp/src/tools/mad_tree.h rename to mad_icp/src/tools/mad_tree.h diff --git a/mad-icp/src/tools/utils.h b/mad_icp/src/tools/utils.h similarity index 100% rename from mad-icp/src/tools/utils.h rename to mad_icp/src/tools/utils.h diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..aed1f8f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,46 @@ +[build-system] +requires = ["scikit-build-core", "pybind11"] +build-backend = "scikit_build_core.build" + +[project] +name = "mad-icp" +version = "0.0.1" +description = "It Is All About Matching Data -- Robust and Informed LiDAR Odometry" +readme = "README.md" +authors = [ + { name = "Simone Ferrari", email = "s.ferrari@diag.uniroma1.it" }, + { name = "Luca Di Giammarino", email = "digiammarino@diag.uniroma1.it" }, + { name = "Leonardo Brizi", email = "brizi@diag.uniroma1.it" }, + { name = "Emanuele Giacomini", email = "giacomini@diag.uniroma1.it" }, +] +keywords = ["TODO"] +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: BSD License", + "Operating System :: Unix", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", +] +dependencies = [ + "PyYAML", + "numpy", + "rosbags", + "open3d>=0.13.0", + "matplotlib", + "typer[all]>=0.10.0", + "natsort", + "rich", +] + +[project.scripts] +mad_icp = "mad_icp.apps.mad_icp:run" + +[project.urls] +Homepage = "https://github.com/rvp-group/mad-icp" + +[tool.scikit-build] +build-dir = "build/{wheel_tag}" +cmake.source-dir = "mad_icp/" +cmake.verbose = false +cmake.minimum-version = "3.8" +wheel.install-dir = "mad_icp/src/pybind" From d08a6362fe60dffa492e7ecf035a16fdcf0c52c7 Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 12:49:52 +0200 Subject: [PATCH 02/14] Added base LiDAR keyword --- pyproject.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index aed1f8f..30719b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,11 @@ authors = [ { name = "Leonardo Brizi", email = "brizi@diag.uniroma1.it" }, { name = "Emanuele Giacomini", email = "giacomini@diag.uniroma1.it" }, ] -keywords = ["TODO"] +keywords = [ +"LiDAR", +"TODO" +] + classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: BSD License", From 33a6f709d2ece3fa43daf6f1a738c60aad938f58 Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 12:52:30 +0200 Subject: [PATCH 03/14] added workflow action --- .github/workflows/pythonbuild_devel.yml | 2402 +++++++++++++++++++++++ 1 file changed, 2402 insertions(+) create mode 100644 .github/workflows/pythonbuild_devel.yml diff --git a/.github/workflows/pythonbuild_devel.yml b/.github/workflows/pythonbuild_devel.yml new file mode 100644 index 0000000..68c8db2 --- /dev/null +++ b/.github/workflows/pythonbuild_devel.yml @@ -0,0 +1,2402 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + mad-icp/.github/workflows/pythonbuild_devel.yml at main · rvp-group/mad-icp · GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ Skip to content + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+ + + + + + +
+ + + + + + + + + +
+
+
+ + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + / + + mad-icp + + + Public +
+ + +
+ +
+ + +
+
+ +
+
+ + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + +

Latest commit

 

History

History
23 lines (22 loc) · 532 Bytes

pythonbuild_devel.yml

File metadata and controls

23 lines (22 loc) · 532 Bytes
+
+ + + + +
+ +
+ +
+
+ +
+ +
+

Footer

+ + + + +
+
+ + + + + © 2024 GitHub, Inc. + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + From 27ac54a78985e9868020289e16b182a3b89c6231 Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 12:53:10 +0200 Subject: [PATCH 04/14] added workflow action --- .github/workflows/pythonbuild_devel.yml | 2425 +---------------------- 1 file changed, 23 insertions(+), 2402 deletions(-) diff --git a/.github/workflows/pythonbuild_devel.yml b/.github/workflows/pythonbuild_devel.yml index 68c8db2..fe3087e 100644 --- a/.github/workflows/pythonbuild_devel.yml +++ b/.github/workflows/pythonbuild_devel.yml @@ -1,2402 +1,23 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - mad-icp/.github/workflows/pythonbuild_devel.yml at main · rvp-group/mad-icp · GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- Skip to content - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - -
- -
- - - - - - - - -
- - - - - - -
- - - - - - - - - -
-
-
- - - - - - - - - - - - -
- -
- -
- -
- - - - / - - mad-icp - - - Public -
- - -
- -
- - -
-
- -
-
- - - - -
- - - - - - -
- - - - - - - - - - - - - - - - -

Latest commit

 

History

History
23 lines (22 loc) · 532 Bytes

pythonbuild_devel.yml

File metadata and controls

23 lines (22 loc) · 532 Bytes
-
- - - - -
- -
- -
-
- -
- -
-

Footer

- - - - -
-
- - - - - © 2024 GitHub, Inc. - -
- - -
-
- - - - - - - - - - - - - - - - - - - -
- -
-
- - - +name: pypy_devel API Build +on: + push: + branches: ["pypi_devel"] + pull_request: + branches: [] + +jobs: + python_package: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04] + steps: + - uses: actions/checkout@v3 + - name: Set up Python3 + uses: actions/setup-python@v3 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + - name: Build pip package + run: | + python -m pip install --verbose . From 65b5652b7257ea80b8779d347e2ed3cb27ec8f42 Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 12:54:15 +0200 Subject: [PATCH 05/14] Fixed version requirement for open3d --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 30719b0..9165f5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "PyYAML", "numpy", "rosbags", - "open3d>=0.13.0", + "open3d", "matplotlib", "typer[all]>=0.10.0", "natsort", From 5e3a55406939461fdc13d5a4c096e82ad2b7e1bb Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 12:57:15 +0200 Subject: [PATCH 06/14] Fixed other issues for pyproject.toml --- pyproject.toml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9165f5d..9493c6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,10 +13,8 @@ authors = [ { name = "Leonardo Brizi", email = "brizi@diag.uniroma1.it" }, { name = "Emanuele Giacomini", email = "giacomini@diag.uniroma1.it" }, ] -keywords = [ -"LiDAR", -"TODO" -] +keywords = ["LiDAR", "TODO"] +requires-python = ">=3.8" classifiers = [ "Programming Language :: Python :: 3", @@ -46,5 +44,5 @@ Homepage = "https://github.com/rvp-group/mad-icp" build-dir = "build/{wheel_tag}" cmake.source-dir = "mad_icp/" cmake.verbose = false -cmake.minimum-version = "3.8" +cmake.version = ">=3.8" wheel.install-dir = "mad_icp/src/pybind" From 64b4a7ef02814e210d42d102dc1bb054d17f6447 Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 13:07:26 +0200 Subject: [PATCH 07/14] Changed python version for GitHub action --- .github/workflows/pythonbuild_devel.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonbuild_devel.yml b/.github/workflows/pythonbuild_devel.yml index fe3087e..f056556 100644 --- a/.github/workflows/pythonbuild_devel.yml +++ b/.github/workflows/pythonbuild_devel.yml @@ -12,9 +12,11 @@ jobs: matrix: os: [ubuntu-20.04, ubuntu-22.04] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python3 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 + with: + python-version: "3.11" - name: Install dependencies run: | python -m pip install --upgrade pip From 228d23aa082c3752037b111f1fc6204ed690cee8 Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 13:18:16 +0200 Subject: [PATCH 08/14] Added FetchContent option for Eigen --- mad_icp/CMakeLists.txt | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/mad_icp/CMakeLists.txt b/mad_icp/CMakeLists.txt index 16df2f6..1d35ebc 100755 --- a/mad_icp/CMakeLists.txt +++ b/mad_icp/CMakeLists.txt @@ -13,7 +13,34 @@ option(COMPILE_CPP_APPS "Set to ON to compile C++ applications" OFF) # Eigen # TODO: Detect if Eigen exists in system, oterwhise, download it through FetchContent -find_package(Eigen3 3.3 REQUIRED NO_MODULE) +find_package(Eigen3 3.3 NO_MODULE) + +if(not Eigen3_FOUND) + message(CHECK_START "Fetching Eigen3") + list(APPEND CMAKE_MESSAGE_INDENT " ") + + include(FetchContent) + FetchContent_Declare( + Eigen + GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git + GIT_TAG master + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE) + + # note: To disable eigen tests, + # you should put this code in a add_subdirectory to avoid to change + # BUILD_TESTING for your own project too since variables are directory + # scoped + set(BUILD_TESTING OFF) + set(EIGEN_BUILD_TESTING OFF) + set(EIGEN_MPL2_ONLY ON) + set(EIGEN_BUILD_PKGCONFIG OFF) + set(EIGEN_BUILD_DOC OFF) + FetchContent_MakeAvailable(Eigen) + + list(POP_BACK CMAKE_MESSAGE_INDENT) + message(CHECK_PASS "fetched") +endif() # OpenMP find_package(OpenMP REQUIRED) From 074da5207475f4f5a1cf0ef7304502725f532834 Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 13:19:50 +0200 Subject: [PATCH 09/14] Added FetchContent option for Eigen --- mad_icp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mad_icp/CMakeLists.txt b/mad_icp/CMakeLists.txt index 1d35ebc..48c470d 100755 --- a/mad_icp/CMakeLists.txt +++ b/mad_icp/CMakeLists.txt @@ -15,7 +15,7 @@ option(COMPILE_CPP_APPS "Set to ON to compile C++ applications" OFF) # TODO: Detect if Eigen exists in system, oterwhise, download it through FetchContent find_package(Eigen3 3.3 NO_MODULE) -if(not Eigen3_FOUND) +if(NOT DEFINED Eigen3_FOUND) message(CHECK_START "Fetching Eigen3") list(APPEND CMAKE_MESSAGE_INDENT " ") From 815b5d50191fe89602011a221651dea7ca67f1cf Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 13:43:42 +0200 Subject: [PATCH 10/14] Updated Eigen dependencies --- mad_icp/CMakeLists.txt | 28 ++++++++++------------------ mad_icp/src/odometry/CMakeLists.txt | 2 +- mad_icp/src/pybind/CMakeLists.txt | 1 + mad_icp/src/tools/CMakeLists.txt | 3 +-- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/mad_icp/CMakeLists.txt b/mad_icp/CMakeLists.txt index 48c470d..2fe2c52 100755 --- a/mad_icp/CMakeLists.txt +++ b/mad_icp/CMakeLists.txt @@ -13,8 +13,7 @@ option(COMPILE_CPP_APPS "Set to ON to compile C++ applications" OFF) # Eigen # TODO: Detect if Eigen exists in system, oterwhise, download it through FetchContent -find_package(Eigen3 3.3 NO_MODULE) - +# find_package(Eigen3 3.3 NO_MODULE) if(NOT DEFINED Eigen3_FOUND) message(CHECK_START "Fetching Eigen3") list(APPEND CMAKE_MESSAGE_INDENT " ") @@ -22,21 +21,13 @@ if(NOT DEFINED Eigen3_FOUND) include(FetchContent) FetchContent_Declare( Eigen - GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git - GIT_TAG master - GIT_SHALLOW TRUE - GIT_PROGRESS TRUE) - - # note: To disable eigen tests, - # you should put this code in a add_subdirectory to avoid to change - # BUILD_TESTING for your own project too since variables are directory - # scoped - set(BUILD_TESTING OFF) - set(EIGEN_BUILD_TESTING OFF) - set(EIGEN_MPL2_ONLY ON) - set(EIGEN_BUILD_PKGCONFIG OFF) - set(EIGEN_BUILD_DOC OFF) - FetchContent_MakeAvailable(Eigen) + URL https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz) + FetchContent_GetProperties(Eigen) + + if(NOT eigen_POPULATED) + FetchContent_Populate(Eigen) + add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR} EXCLUDE_FROM_ALL) + endif() list(POP_BACK CMAKE_MESSAGE_INDENT) message(CHECK_PASS "fetched") @@ -52,7 +43,8 @@ find_package(pybind11 REQUIRED) include_directories( ${PROJECT_SOURCE_DIR}/src - ${EIGEN3_INCLUDE_DIR} + + # ${EIGEN3_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} ) diff --git a/mad_icp/src/odometry/CMakeLists.txt b/mad_icp/src/odometry/CMakeLists.txt index 0959f68..9083530 100755 --- a/mad_icp/src/odometry/CMakeLists.txt +++ b/mad_icp/src/odometry/CMakeLists.txt @@ -6,6 +6,6 @@ add_library(odometry STATIC target_link_libraries(odometry tools + Eigen3::Eigen ) - target_compile_features(odometry PUBLIC) \ No newline at end of file diff --git a/mad_icp/src/pybind/CMakeLists.txt b/mad_icp/src/pybind/CMakeLists.txt index 5e92b23..8a7ac6f 100644 --- a/mad_icp/src/pybind/CMakeLists.txt +++ b/mad_icp/src/pybind/CMakeLists.txt @@ -1,5 +1,6 @@ pybind11_add_module(pypeline MODULE pypeline.cpp) target_link_libraries(pypeline PRIVATE + Eigen3::Eigen odometry tools ) diff --git a/mad_icp/src/tools/CMakeLists.txt b/mad_icp/src/tools/CMakeLists.txt index 35fe733..5342c94 100755 --- a/mad_icp/src/tools/CMakeLists.txt +++ b/mad_icp/src/tools/CMakeLists.txt @@ -1,6 +1,5 @@ add_library(tools STATIC mad_tree.cpp ) - -target_link_libraries(tools) +target_link_libraries(tools PUBLIC Eigen3::Eigen) target_compile_features(tools PUBLIC) \ No newline at end of file From 02c703d40f83f9330383889c31e98e21f507d067 Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 13:47:21 +0200 Subject: [PATCH 11/14] Changed CMAKE option for cpp apps --- mad_icp/apps/cpp_runners/CMakeLists.txt | 3 ++- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mad_icp/apps/cpp_runners/CMakeLists.txt b/mad_icp/apps/cpp_runners/CMakeLists.txt index fb5e888..cf792d3 100644 --- a/mad_icp/apps/cpp_runners/CMakeLists.txt +++ b/mad_icp/apps/cpp_runners/CMakeLists.txt @@ -1,4 +1,5 @@ -if(DEFINED COMPILE_CPP_APPS) +if(COMPILE_CPP_APPS) + message("Compiling CPP Apps") add_executable(bin_runner bin_runner.cpp) target_link_libraries(bin_runner odometry diff --git a/pyproject.toml b/pyproject.toml index 9493c6c..a470106 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "rosbags", "open3d", "matplotlib", - "typer[all]>=0.10.0", + "typer>=0.10.0", "natsort", "rich", ] From d9b84eac0b875086b322dea6e866ea937b8f2aa7 Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 16:47:36 +0200 Subject: [PATCH 12/14] Added default build and publish actions --- .github/workflows/pypi_publish.yml | 38 ++++++++++++++++++++++++++++++ .github/workflows/pythonbuild.yml | 25 ++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/pypi_publish.yml create mode 100644 .github/workflows/pythonbuild.yml diff --git a/.github/workflows/pypi_publish.yml b/.github/workflows/pypi_publish.yml new file mode 100644 index 0000000..234e1d1 --- /dev/null +++ b/.github/workflows/pypi_publish.yml @@ -0,0 +1,38 @@ +name: Publish to PyPI.org +on: + release: + types: [published] + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build sdist + run: pipx run build --sdist ${{github.workspace}}/python/ + - name: Move sdist to dist + run: mkdir -p dist && mv ${{github.workspace}}/python/dist/*.tar.gz dist/ + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz + + pypi: + if: github.event_name == 'release' + needs: build_sdist + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} diff --git a/.github/workflows/pythonbuild.yml b/.github/workflows/pythonbuild.yml new file mode 100644 index 0000000..0814787 --- /dev/null +++ b/.github/workflows/pythonbuild.yml @@ -0,0 +1,25 @@ +name: Python API Build +on: + push: + branches: ["main"] + pull_request: + branches: [] + +jobs: + python_package: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04] + steps: + - uses: actions/checkout@v4 + - name: Set up Python3 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + - name: Build pip package + run: | + python -m pip install . From 4ad66e85083d2b1b74b707f33428b5aaef99b58f Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 16:50:57 +0200 Subject: [PATCH 13/14] Updated publisher --- .github/workflows/pypi_publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi_publish.yml b/.github/workflows/pypi_publish.yml index 234e1d1..416fc3a 100644 --- a/.github/workflows/pypi_publish.yml +++ b/.github/workflows/pypi_publish.yml @@ -14,9 +14,9 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build sdist - run: pipx run build --sdist ${{github.workspace}}/python/ + run: pipx run build --sdist ${{github.workspace}} - name: Move sdist to dist - run: mkdir -p dist && mv ${{github.workspace}}/python/dist/*.tar.gz dist/ + run: mkdir -p dist && mv ${{github.workspace}}/dist/*.tar.gz dist/ - uses: actions/upload-artifact@v3 with: From 407ae9b0749bbb826ad9a097d666dd5a1e239668 Mon Sep 17 00:00:00 2001 From: Emanuele Giacomini Date: Mon, 10 Jun 2024 16:54:09 +0200 Subject: [PATCH 14/14] Updated publisher --- .github/workflows/pypi_publish.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/pypi_publish.yml b/.github/workflows/pypi_publish.yml index 416fc3a..7b19a7b 100644 --- a/.github/workflows/pypi_publish.yml +++ b/.github/workflows/pypi_publish.yml @@ -15,9 +15,6 @@ jobs: - uses: actions/checkout@v3 - name: Build sdist run: pipx run build --sdist ${{github.workspace}} - - name: Move sdist to dist - run: mkdir -p dist && mv ${{github.workspace}}/dist/*.tar.gz dist/ - - uses: actions/upload-artifact@v3 with: path: dist/*.tar.gz