Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions cpp/pybind/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
pybind11_add_module(pybind metrics.cpp)
pybind11_add_module(pybind
map_metrics_pybind.cpp
config.cpp
map_tree.cpp
metrics.cpp
utils/cloud_utils.cpp)

find_package(Eigen3 3.4 REQUIRED)

# TODO: remove?
target_link_libraries(pybind PRIVATE ${cilantro_LIBRARIES})
target_include_directories(pybind PRIVATE "${CMAKE_BINARY_DIR}/external/cilantro/cilantro/include")

target_link_libraries(pybind PRIVATE Eigen3::Eigen)
target_link_libraries(pybind PUBLIC map_metrics)
32 changes: 32 additions & 0 deletions cpp/pybind/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2022, Arthur Saliou, Anastasiia Kornilova
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// Created on: May 20, 2022
// Author: Arthur Saliou
// arthur.salio@gmail.com
//
#include "config.h"

#include "map_metrics/config.h"

namespace map_metrics {
void pybindConfig(py::module& m) {
py::module_ m_config = m.def_submodule("config", "Predefined config class");

py::class_<Config>(m_config, "Config")
.def(py::init<int, double, int, int>(), py::arg("min_knn") = 5, py::arg("knn_rad") = 1.0, py::arg("max_nn") = 30,
py::arg("min_clust_size") = 5);
}
} // namespace map_metrics
29 changes: 29 additions & 0 deletions cpp/pybind/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2022, Arthur Saliou, Anastasiia Kornilova
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// Created on: May 20, 2022
// Author: Arthur Saliou
// arthur.salio@gmail.com
//
#ifndef MAP_METRICS_PYBIND_CONFIG_H
#define MAP_METRICS_PYBIND_CONFIG_H
#include <pybind11/pybind11.h>

namespace py = pybind11;

namespace map_metrics {
void pybindConfig(py::module& m);
}
#endif // MAP_METRICS_PYBIND_CONFIG_H
36 changes: 36 additions & 0 deletions cpp/pybind/map_metrics_pybind.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2022, Arthur Saliou, Anastasiia Kornilova
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// Created on: May 20, 2022
// Author: Arthur Saliou
// arthur.salio@gmail.com
//
#include "pybind11/pybind11.h"

#include "config.h"
#include "map_tree.h"
#include "metrics.h"
#include "utils/cloud_utils.h"

namespace map_metrics {
PYBIND11_MODULE(pybind, m) {
m.doc() = "Pybind metrics module";

pybindConfig(m);
pybindMapTree(m);
pybindCloudUtils(m);
pybindMetrics(m);
}
} // namespace map_metrics
33 changes: 33 additions & 0 deletions cpp/pybind/map_tree.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2022, Arthur Saliou, Anastasiia Kornilova
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// Created on: May 20, 2022
// Author: Arthur Saliou
// arthur.salio@gmail.com
//
#include "map_tree.h"

#include <pybind11/eigen.h>

#include "map_metrics/map_tree.h"

namespace map_metrics {
void pybindMapTree(py::module& m) {
py::module m_map_tree = m.def_submodule("map_tree", "Map Tree class");

py::class_<MapTree>(m_map_tree, "MapTree")
.def(py::init<Eigen::Matrix3Xd, double>(), py::arg("points"), py::arg("knn_rad"));
}
} // namespace map_metrics
29 changes: 29 additions & 0 deletions cpp/pybind/map_tree.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2022, Arthur Saliou, Anastasiia Kornilova
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// Created on: May 20, 2022
// Author: Arthur Saliou
// arthur.salio@gmail.com
//
#ifndef MAP_METRICS_PYBIND_MAP_TREE_H
#define MAP_METRICS_PYBIND_MAP_TREE_H
#include <pybind11/pybind11.h>

namespace py = pybind11;

namespace map_metrics{
void pybindMapTree(py::module& m);
}
#endif // MAP_METRICS_PYBIND_MAP_TREE_H
57 changes: 10 additions & 47 deletions cpp/pybind/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,54 +17,17 @@
// Author: Arthur Saliou
// arthur.salio@gmail.com
//
#include <vector>
#include <Eigen/Core>
#include "metrics.h"

#include <pybind11/pybind11.h>
#include <pybind11/eigen.h>
#include <pybind11/stl.h>
#include <map_metrics/metrics.h>

#include <metrics.h>
#include <orth_extract.h>
#include <config.h>
namespace map_metrics {
void pybindMetrics(py::module& m) {
py::module m_metrics = m.def_submodule("metrics", "Map Metrics (MME, MPV, MOM)");

// Python: arg0: List[numpy.ndarray[numpy.float64[3, n]]], arg1: List[numpy.ndarray[numpy.float64[4, 4]]]) -> float

namespace py = pybind11;

std::vector<cilantro::VectorSet3d> extract_orthogonal(
cilantro::VectorSet3d const & points , config::CustomConfig config, double eps=1e-1)
{
return orth_extract::ExtractOrthogonalSubset(cilantro::PointCloud3d(points), config, eps);
m_metrics.def("MME", &MME, "Mean Map Entropy map metric", py::arg("map_tree"), py::arg("min_component_size"));
m_metrics.def("MPV", &MPV, "Mean Map Variance map metric", py::arg("map_tree"), py::arg("min_component_size"));
m_metrics.def("MOM", &MOM, "Mutually Orthogonal Metric map metric", py::arg("map_tree"),
py::arg("min_component_size"), py::arg("orthogonal_subset") = std::vector<Eigen::Matrix3Xd>());
}

PYBIND11_MODULE(map_metrics, m){
m.doc() = R"(Map-Metrics library
A tool for evaluating the quality of odometry algorithm trajectory.)";

py::module_ mcfg = m.def_submodule("config", "Config submodule");

py::class_<config::CustomConfig>(mcfg, "CustomConfig")
.def(py::init<int, double, int, int>());

m.def("mpv", &metrics::GetMPV, "Mean Plane Variance trajectory metric",
py::arg("pcs"),
py::arg("poses"),
py::arg("config") = config::CustomConfig());

m.def("mme", &metrics::GetMME, "Mean Map Entropy trajectory metric",
py::arg("pcs"),
py::arg("poses"),
py::arg("config") = config::CustomConfig());

m.def("mom", &metrics::GetMOM, "Mutually Orthogonal Metric trajectory metric",
py::arg("pcs"),
py::arg("poses"),
py::arg("config") = config::CustomConfig(),
py::arg("orth_subset") = std::vector<cilantro::VectorSet3d>());

m.def("extract_orthogonal", &extract_orthogonal, "Extract orthogonal plane subset from Point Cloud",
py::arg("pc"),
py::arg("config") = config::CustomConfig(),
py::arg("eps") = 1e-1);
}
} // namespace map_metrics
29 changes: 29 additions & 0 deletions cpp/pybind/metrics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2022, Arthur Saliou, Anastasiia Kornilova
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// Created on: May 20, 2022
// Author: Arthur Saliou
// arthur.salio@gmail.com
//
#ifndef MAP_METRICS_PYBIND_METRICS_H
#define MAP_METRICS_PYBIND_METRICS_H
#include <pybind11/pybind11.h>

namespace py = pybind11;

namespace map_metrics {
void pybindMetrics(py::module& m);
}
#endif // MAP_METRICS_PYBIND_METRICS_H
41 changes: 41 additions & 0 deletions cpp/pybind/utils/cloud_utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) 2022, Arthur Saliou, Anastasiia Kornilova
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// Created on: May 20, 2022
// Author: Arthur Saliou
// arthur.salio@gmail.com
//
#include "cloud_utils.h"

#include <pybind11/eigen.h>

#include "map_metrics/utils/cloud_utils.h"

namespace map_metrics {
void pybindCloudUtils(py::module& m) {
py::module m_cloud_utils = m.def_submodule("cloud_utils", "Orthogonal extraction, map composition utils");

pybindAggregateMap(m_cloud_utils);
pybindFindOrthogonalSubset(m_cloud_utils);
}

void pybindAggregateMap(py::module& m) {
m.def("aggregate_map", &aggregateMap, py::arg("point_sequence"), py::arg("poses"));
}

void pybindFindOrthogonalSubset(py::module& m) {
m.def("find_orthogonal_subset", &findOrthogonalSubset, py::arg("points"), py::arg("config"));
}
} // namespace map_metrics
33 changes: 33 additions & 0 deletions cpp/pybind/utils/cloud_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2022, Arthur Saliou, Anastasiia Kornilova
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// Created on: May 20, 2022
// Author: Arthur Saliou
// arthur.salio@gmail.com
//
#ifndef MAP_METRICS_PYBIND_CLOUD_UTILS_H
#define MAP_METRICS_PYBIND_CLOUD_UTILS_H
#include <pybind11/pybind11.h>

namespace py = pybind11;

namespace map_metrics {
void pybindCloudUtils(py::module& m);

void pybindAggregateMap(py::module& m);

void pybindFindOrthogonalSubset(py::module& m);
} // namespace map_metrics
#endif // MAP_METRICS_PYBIND_CLOUD_UTILS_H