Skip to content

add loop threshold check in detectLoopClosureID #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.11)
project(Scancontext VERSION 1.0.0)

set(CMAKE_CXX_STANDARD 14)

if(NOT CMAKE_BUILD_TYPE)
# Options: Debug, Release, MinSizeRel, RelWithDebInfo
message(STATUS "No build type selected, default to Release")
Expand All @@ -10,36 +11,35 @@ endif()

include(FetchContent)

###############################################################################
# Options
###############################################################################
set(PYTHONVERSION "3.10")

# ##############################################################################
# Options
# ##############################################################################
option(SC_BUILD_PYTHON_BINDING "Build Python bindings for Scancontext" ON)

###############################################################################
# ##############################################################################
# Dependencies
###############################################################################

# ##############################################################################
find_package(Eigen3 3.3 REQUIRED NO_MODULE)

FetchContent_Declare(nanoflann
GIT_REPOSITORY https://github.com/jlblancoc/nanoflann
GIT_TAG v1.4.2
GIT_TAG v1.4.2
)
FetchContent_MakeAvailable(nanoflann)

if(SC_BUILD_PYTHON_BINDING)
if(SC_BUILD_PYTHON_BINDING)
FetchContent_Declare(pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11
GIT_TAG v2.9.2
GIT_TAG v2.9.2
)
FetchContent_MakeAvailable(pybind11)
endif()

###############################################################################
# ##############################################################################
# Targets
###############################################################################

# ##############################################################################
add_subdirectory(scancontext)

if(SC_BUILD_PYTHON_BINDING)
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
$ cmake ..
$ make
```
- CMake doesn’t detect the right Python version
The CMake-based build system will try to automatically detect the installed version of Python and link against that. When this fails, or when there are multiple versions of Python and it finds the wrong one, delete CMakeCache.txt and then add -DPYTHON_EXECUTABLE=$(which python) to your CMake configure line. (Replace $(which python) with a path to python if your prefer.)

You can alternatively try -DPYBIND11_FINDPYTHON=ON, which will activate the new CMake FindPython support instead of pybind11’s custom search. Requires CMake 3.12+, and 3.15+ or 3.18.2+ are even better. You can set this in your CMakeLists.txt before adding or finding pybind11, as well.



- Install the Python package via `pip` with
```
$ cd build
Expand Down
35 changes: 35 additions & 0 deletions examples/ScanContextManagerCPP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pyscancontext as sc

import numpy as np
np.set_printoptions(precision=4)


scm = sc.SCManager()


# ScanContextManager using python binding

class ScanContextManagerCPP:
def __init__(self, shape=[20,60], num_candidates=10, threshold=0.15): # defualt configs are same as the original paper
self.shape = shape
self.num_candidates = num_candidates
self.threshold = threshold

self.max_length = 80 # recommended but other (e.g., 100m) is also ok.

self.ENOUGH_LARGE = 15000 # capable of up to ENOUGH_LARGE number of nodes
self.ptclouds = [None] * self.ENOUGH_LARGE

self.curr_node_idx = 0

def addNode(self, node_idx, ptcloud):
scm.add_node(ptcloud)
self.curr_node_idx = node_idx
self.ptclouds[node_idx] = ptcloud


def getPtcloud(self, node_idx):
return self.ptclouds[node_idx]

def detectLoop(self):
return scm.detect_loop()
40 changes: 20 additions & 20 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set(PYPKG_DIR "${CMAKE_CURRENT_BINARY_DIR}/pyscancontext")

pybind11_add_module(pyscancontext wrapper.cpp)
target_link_libraries(pyscancontext PUBLIC Scancontext::scancontext)
set_target_properties(pyscancontext PROPERTIES OUTPUT_NAME "pyscancontext")
Expand All @@ -15,34 +14,35 @@ configure_file(setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py)

# Create the Python package -- Note that "." is used to conform to PEP 328
file(WRITE "${PYPKG_DIR}/__init__.py"
"from .pyscancontext import *\n"
"from .pyscancontext import __version__\n"
"from .pyscancontext import __doc__")
"from .pyscancontext import *\n"
"from .pyscancontext import __version__\n"
"from .pyscancontext import __doc__")

set(DIST "none")

if(UNIX AND NOT APPLE)
execute_process(COMMAND bash -c "lsb_release -cs" OUTPUT_VARIABLE UBUNTU_DIST)
string(STRIP "${UBUNTU_DIST}" UBUNTU_DIST)
set(DIST "${UBUNTU_DIST}")
execute_process(COMMAND bash -c "lsb_release -cs" OUTPUT_VARIABLE UBUNTU_DIST)
string(STRIP "${UBUNTU_DIST}" UBUNTU_DIST)
set(DIST "${UBUNTU_DIST}")
elseif(APPLE)
# TODO: not very specific...
set(DIST "macos")
# TODO: not very specific...
set(DIST "macos")
elseif(WIN32)
# TODO: not very specific...
set(DIST "win10")
# TODO: not very specific...
set(DIST "win10")
endif()

set(PKGSTR pyscancontext-py3-${DIST}-${PROJECT_VERSION})
add_custom_target(pypkg
DEPENDS pyscancontext
COMMAND ${CMAKE_COMMAND} -E make_directory ${PKGSTR}
COMMAND ${CMAKE_COMMAND} -E copy setup.py ${PKGSTR}/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYPKG_DIR} ${PKGSTR}/pyscancontext
COMMAND ${CMAKE_COMMAND} -E tar zcvf ${PKGSTR}.tar.gz ${PKGSTR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
DEPENDS pyscancontext
COMMAND ${CMAKE_COMMAND} -E make_directory ${PKGSTR}
COMMAND ${CMAKE_COMMAND} -E copy setup.py ${PKGSTR}/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYPKG_DIR} ${PKGSTR}/pyscancontext
COMMAND ${CMAKE_COMMAND} -E tar zcvf ${PKGSTR}.tar.gz ${PKGSTR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

add_custom_target(pip-install
DEPENDS pypkg
COMMAND ${PYTHON_EXECUTABLE} -m pip install .
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PKGSTR}
DEPENDS pypkg
COMMAND ${PYTHON_EXECUTABLE} -m pip install .
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PKGSTR}
)
Loading