Skip to content

Commit c4f751b

Browse files
authored
Linux Wheel (#24)
* feat: Added new py-bindings * feat: Complete python bindings * feat: Linux wheel to Test-PyPI * fix: yum install boost-graph * fix: install boost ci * fix: boost installation step * fix: cd * fix: try fix perm denied * fix: sudo chown user * fix: remove sudo * fix: moved install boost step after checkout * feat: add BOOST_ROOT variable * feat: set LD_LIBRARY_PATH path to libgraph * fix: removed unused folder Co-authored-by: Arthur_Ch <56088401+ArthurChains@users.noreply.github.com>
1 parent 7e8a367 commit c4f751b

File tree

10 files changed

+143
-12
lines changed

10 files changed

+143
-12
lines changed

.github/workflows/linux_wheel.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# # # # # # # # #
2+
# Source: https://github.com/miloserdova-l/mrob/blob/feature/windows-wheel/.github/workflows/wheels.yml
3+
# # # # # # # # #
4+
name: Build wheels
5+
6+
on: [push, pull_request, workflow_dispatch]
7+
8+
jobs:
9+
build:
10+
name: Build map_metrics project
11+
runs-on: ubuntu-latest
12+
env:
13+
PYTHONPATH: ./lib
14+
strategy:
15+
fail-fast: false
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Install required packages from distro
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install -y --no-install-recommends git build-essential g++ cmake python3-distutils python3-dev python3-numpy python3-pip libboost-graph-dev
23+
python3 -m pip install pytest
24+
25+
- name: Configure and build native map_metrics library with Python bindings
26+
run: |
27+
mkdir -p build
28+
cmake -S $PWD -B $PWD/build \
29+
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$PWD/bin \
30+
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$PWD/lib \
31+
-DCMAKE_BUILD_TYPE=RELEASE \
32+
&& cmake --build build -j $(nproc)
33+
34+
build_wheel_linux:
35+
name: Build wheel on ${{ matrix.os }}
36+
runs-on: ${{ matrix.os }}
37+
container: quay.io/pypa/manylinux2010_x86_64
38+
needs: build
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
os: [ubuntu-latest]
43+
steps:
44+
- name: Install additional utils
45+
run: yum install -y git openssh-clients wget
46+
47+
- uses: actions/checkout@v1
48+
49+
- name: Install fresh CMake into ManyLinux container
50+
run: |
51+
env pybin=$(LANG=C ls -d1r /opt/python/cp3*/bin | head -n 1) bash -c '$pybin/python -m pip install cmake && mkdir -p /usr/local/bin && ln -svf $pybin/cmake /usr/local/bin/cmake'
52+
cmake --version
53+
- name: Install Boost 1.55.0
54+
run: |
55+
wget http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2 --no-check-certificate
56+
tar -xvjf boost_1_55_0.tar.bz2
57+
cd boost_1_55_0/
58+
./bootstrap.sh --with-icu
59+
./b2 --with-graph
60+
chmod -R +x ./*
61+
echo "BOOST_ROOT=$(pwd)" >> $GITHUB_ENV
62+
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/stage/lib" >> $GITHUB_ENV
63+
- name: Build Python wheel
64+
run: |
65+
chmod -R +x scripts/* \
66+
&& scripts/build-wheels-linux.sh
67+
68+
- uses: actions/upload-artifact@v1
69+
with:
70+
name: artifact
71+
path: ./wheelhouse
72+
73+
publish_test_pypi:
74+
name: Publish wheels to Test PyPI
75+
needs: build_wheel_linux
76+
if: github.event_name == 'push'
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Download artifacts
80+
uses: actions/download-artifact@v2
81+
82+
- name: Publish to Test-PyPI
83+
uses: pypa/gh-action-pypi-publish@release/v1
84+
with:
85+
user: __token__
86+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
87+
repository_url: https://test.pypi.org/legacy/
88+
packages_dir: artifact/

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
99
# # # # # # OPTIONS # # # # # #
1010
option(GLIBCXX_USE_CXX11_ABI "Set -D_GLIBCXX_USE_CXX11_ABI=1" OFF)
1111
# Build Tests
12-
option(BUILD_TESTS "Build an executable with tests" ON)
12+
option(BUILD_TESTS "Build an executable with tests" OFF)
1313
# Python Bindings
14-
option(BUILD_PYTHON_MODULE "Build the Python library interface" OFF)
14+
option(BUILD_PYTHON_MODULE "Build the Python library interface" ON)
1515
# Address sanitizer
1616
option(USE_ASAN "Address sanitizer" OFF)
1717
# Memory sanitizer

cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (Eigen3_FOUND)
2626
target_link_libraries(map_metrics_cpp PRIVATE Eigen3::Eigen)
2727
endif()
2828

29-
target_include_directories(map_metrics_cpp PRIVATE "${CMAKE_BINARY_DIR}/external/cilantro/cilantro/include")
29+
target_include_directories(map_metrics_cpp PUBLIC "${CMAKE_BINARY_DIR}/external/cilantro/cilantro/include")
3030
# TODO: Is it really necessary to specify target_include_dir for alglib here?
3131
target_include_directories(map_metrics_cpp PUBLIC "${CMAKE_BINARY_DIR}/external/alglib/include")
3232
target_include_directories(map_metrics_cpp PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")

cpp/config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ namespace config{
2424
LidarConfig(): CustomConfig() {}
2525
};
2626

27+
class DepthConfig: public CustomConfig{
28+
public:
29+
DepthConfig(): CustomConfig(5, 0.2) {}
30+
};
31+
2732
} // namespace config
2833

2934
#endif // MAP_METRICS_CONFIG_H

cpp/metrics.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,10 @@ namespace metrics {
101101
&metrics_utils::metrics_algorithm::ComputeEntropy);
102102
}
103103

104+
double GetMOM(std::vector<cilantro::VectorSet3d> const & pcs_points, std::vector<Eigen::Matrix4d> const & ts,
105+
config::CustomConfig config, std::vector<cilantro::VectorSet3d> const & orth_subset){
106+
return ComputeOrthogonalMetrics(pcs_points, ts, config,
107+
&metrics_utils::metrics_algorithm::ComputeEigenvalues, orth_subset);
108+
}
104109

105110
} // namespace metrics

cpp/metrics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace metrics{
4444

4545
// MOM. Mutually Orthogonal Metric
4646
double GetMOM(std::vector<cilantro::VectorSet3d> const & pcs_points, std::vector<Eigen::Matrix4d> const & ts,
47-
config::CustomConfig config = config::LidarConfig());
47+
config::CustomConfig config = config::LidarConfig(), std::vector<cilantro::VectorSet3d> const & orth_subset = {});
4848
} // namespace metrics
4949

5050
#endif //MAP_METRICS_METRICS_H

cpp/pybind/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
pybind11_add_module(map_metrics metrics.cpp)
22

3+
find_package(Eigen3 3.4 REQUIRED)
4+
5+
target_link_libraries(map_metrics PRIVATE Eigen3::Eigen)
36
target_link_libraries(map_metrics PUBLIC map_metrics_cpp)

cpp/pybind/metrics.cpp

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,46 @@
99
#include <pybind11/stl.h>
1010

1111
#include <metrics.h>
12+
#include <orth_extract.h>
13+
#include <config.h>
1214

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

1517
namespace py = pybind11;
1618

19+
std::vector<cilantro::VectorSet3d> extract_orthogonal(
20+
cilantro::VectorSet3d const & points , config::CustomConfig config, double eps=1e-1)
21+
{
22+
return orth_extract::ExtractOrthogonalSubset(cilantro::PointCloud3d(points), config, eps);
23+
}
24+
1725
PYBIND11_MODULE(map_metrics, m){
18-
m.doc() = "Baseline of MPV and MME metrics";
19-
m.def("mpv", py::overload_cast<
20-
const std::vector<cilantro::VectorSet3d> &,
21-
const std::vector<Eigen::Matrix4d> &, int, double>(&metrics::GetMPV));
22-
m.def("mme", py::overload_cast<
23-
const std::vector<cilantro::VectorSet3d> &,
24-
const std::vector<Eigen::Matrix4d> &, int, double>(&metrics::GetMME));
26+
m.doc() = R"(Map-Metrics library
27+
A tool for evaluating the quality of odometry algorithm trajectory.)";
28+
29+
py::module_ mcfg = m.def_submodule("config", "Config submodule");
30+
31+
py::class_<config::CustomConfig>(mcfg, "CustomConfig")
32+
.def(py::init<int, double, int, int>());
33+
34+
m.def("mpv", &metrics::GetMPV, "Mean Plane Variance trajectory metric",
35+
py::arg("pcs"),
36+
py::arg("poses"),
37+
py::arg("config") = config::CustomConfig());
38+
39+
m.def("mme", &metrics::GetMME, "Mean Map Entropy trajectory metric",
40+
py::arg("pcs"),
41+
py::arg("poses"),
42+
py::arg("config") = config::CustomConfig());
43+
44+
m.def("mom", &metrics::GetMOM, "Mutually Orthogonal Metric trajectory metric",
45+
py::arg("pcs"),
46+
py::arg("poses"),
47+
py::arg("config") = config::CustomConfig(),
48+
py::arg("orth_subset") = std::vector<cilantro::VectorSet3d>());
49+
50+
m.def("extract_orthogonal", &extract_orthogonal, "Extract orthogonal plane subset from Point Cloud",
51+
py::arg("pc"),
52+
py::arg("config") = config::CustomConfig(),
53+
py::arg("eps") = 1e-1);
2554
}

scripts/build-wheels-linux.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ do
4646
-DPYTHON_EXECUTABLE:FILEPATH=${PYBIN} \
4747
-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE \
4848
-DCMAKE_INSTALL_RPATH='$ORIGIN' \
49+
-DBOOST_ROOT=${BOOST_ROOT} \
4950
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$PWD/../bin \
5051
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$PWD/../map_metrics \
5152
&& cmake --build .

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get_tag(self):
6262

6363
setup_kwargs = dict(
6464
name='map_metrics',
65-
version='0.0.4',
65+
version='0.0.5',
6666
packages=find_packages(),
6767
cmdclass={'bdist_wheel': bdist_wheel}
6868
)

0 commit comments

Comments
 (0)