From ae3a9041e970e07b39ae015d3ebbb6a229f4a688 Mon Sep 17 00:00:00 2001 From: Hauke Strasdat Date: Sun, 9 Jun 2024 20:45:53 -0700 Subject: [PATCH] maintenance update --- .github/ISSUE_TEMPLATE/bug_report.md | 4 +- .github/workflows/coverage.yml | 59 --- .github/workflows/format.yml | 22 + .github/workflows/gh_pages.yml | 34 -- .github/workflows/main.yml | 137 +++-- ...-and-test-sophus-pybind.yml => pybind.yml} | 6 +- .gitignore | 2 +- .pre-commit-config.yaml | 28 + CMakeLists.txt | 215 +++----- LICENSE.txt | 2 +- README.md | 79 +++ README.rst | 44 -- Sophus.code-workspace | 66 ++- SophusConfig.cmake.in | 1 - appveyor.yml | 35 -- cmake_modules/FindEigen3.cmake | 107 ---- doxyfile | 24 - doxyrest-config.lua | 20 - examples/CMakeLists.txt | 34 +- .../custom_ensure_handler.cpp | 5 +- examples/ensure_example.cpp | 5 + examples/{HelloSO3.cpp => hello_so3.cpp} | 13 +- make_docs.sh | 3 - rst-dir/conf.py | 54 -- rst-dir/page_index.rst | 9 - rst-dir/pysophus.rst | 23 - run_format.sh | 1 - scripts/install_docs_deps.sh | 21 - scripts/install_linux_deps.sh | 27 - scripts/install_linux_fmt_deps.sh | 14 - scripts/install_osx_deps.sh | 52 -- scripts/install_osx_deps_incl_ceres.sh | 29 ++ scripts/install_ubuntu_deps_incl_ceres.sh | 30 ++ ...un_cpp_tests.sh => run_cpp_tests_clang.sh} | 4 +- scripts/run_cpp_tests_gcc.sh | 12 + sophus/average.hpp | 51 +- sophus/cartesian.hpp | 12 +- sophus/ceres_local_parameterization.hpp | 52 -- sophus/ceres_typetraits.hpp | 4 +- sophus/common.hpp | 269 +++++----- sophus/geometry.hpp | 15 +- sophus/interpolate.hpp | 4 +- sophus/rotation_matrix.hpp | 2 +- sophus/rxso2.hpp | 31 +- sophus/rxso3.hpp | 12 +- sophus/se2.hpp | 21 +- sophus/se3.hpp | 22 +- sophus/sim2.hpp | 12 +- sophus/sim3.hpp | 12 +- sophus/so2.hpp | 19 +- sophus/so3.hpp | 61 ++- sophus/test_macros.hpp | 128 ++--- sophus/types.hpp | 10 +- sophus/velocities.hpp | 71 --- sophus_pybind/README | 16 +- sophus_pybind/SE3PyBind.h | 479 ++++++++++-------- sophus_pybind/SO3PyBind.h | 347 +++++++------ sophus_pybind/SophusPyBind.h | 15 +- test/CMakeLists.txt | 4 +- test/ceres/CMakeLists.txt | 2 +- test/ceres/tests.hpp | 15 - test/core/CMakeLists.txt | 47 +- test/core/test_common.cpp | 14 +- test/core/test_rxso2.cpp | 12 +- test/core/test_rxso3.cpp | 12 +- test/core/test_se2.cpp | 4 +- test/core/test_se3.cpp | 4 +- test/core/test_so2.cpp | 4 +- test/core/test_so3.cpp | 8 +- test/core/test_velocities.cpp | 130 ----- test/core/tests.hpp | 95 ++-- 71 files changed, 1375 insertions(+), 1862 deletions(-) delete mode 100644 .github/workflows/coverage.yml create mode 100644 .github/workflows/format.yml delete mode 100644 .github/workflows/gh_pages.yml rename .github/workflows/{build-and-test-sophus-pybind.yml => pybind.yml} (95%) create mode 100644 .pre-commit-config.yaml create mode 100644 README.md delete mode 100644 README.rst delete mode 100644 appveyor.yml delete mode 100644 cmake_modules/FindEigen3.cmake delete mode 100644 doxyfile delete mode 100644 doxyrest-config.lua rename sophus/example_ensure_handler.cpp => examples/custom_ensure_handler.cpp (78%) create mode 100644 examples/ensure_example.cpp rename examples/{HelloSO3.cpp => hello_so3.cpp} (80%) delete mode 100755 make_docs.sh delete mode 100644 rst-dir/conf.py delete mode 100644 rst-dir/page_index.rst delete mode 100644 rst-dir/pysophus.rst delete mode 100755 run_format.sh delete mode 100755 scripts/install_docs_deps.sh delete mode 100755 scripts/install_linux_deps.sh delete mode 100755 scripts/install_linux_fmt_deps.sh delete mode 100755 scripts/install_osx_deps.sh create mode 100755 scripts/install_osx_deps_incl_ceres.sh create mode 100755 scripts/install_ubuntu_deps_incl_ceres.sh rename scripts/{run_cpp_tests.sh => run_cpp_tests_clang.sh} (50%) create mode 100755 scripts/run_cpp_tests_gcc.sh delete mode 100644 sophus/ceres_local_parameterization.hpp delete mode 100644 sophus/velocities.hpp delete mode 100644 test/core/test_velocities.cpp diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ec2377616..867a07e65 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -14,8 +14,8 @@ assignees: '' **To Reproduce** [Steps to reproduce the behavior:] 1. -2. -3. +2. +3. **Expected behavior** [A clear and concise description of what you expected to happen.] diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index 12d5935fd..000000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Coverage Analysis - -on: - push: - branches: [ master ] - pull_request: - - workflow_dispatch: - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - fail-fast: false - env: - BUILD_TYPE: Coverage - - - steps: - - uses: actions/checkout@v2 - - - name: ccache - uses: hendrikmuhs/ccache-action@v1 - - - name: Install dependencies (Linux) - run: | - ./scripts/install_linux_deps.sh - ./scripts/install_linux_fmt_deps.sh - - - name: Install Coverage - run: | - DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \ - lcov - - - name: Run tests for coverage - run: | - mkdir build - cd build - cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. - make - make CTEST_OUTPUT_ON_FAILURE=1 test - - - name: Run lcov - run: | - set -x - cd build - lcov --directory . --capture --output-file coverage.info - lcov --remove coverage.info 'test/*' '/usr/*' --output-file coverage.info - lcov --list coverage.info - ls - pwd - - - name: Coveralls - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: /home/runner/work/Sophus/Sophus/build/coverage.info diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..7af55f7e8 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,22 @@ +name: format + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + pre-commit-check: + runs-on: ubuntu-latest + steps: + - name: Checkout workspace + uses: actions/checkout@v3 + - name: Install pre-commit and install + run: | + pip install pre-commit + pre-commit install + - name: Run pre-commit checks + run: pre-commit run --all-files diff --git a/.github/workflows/gh_pages.yml b/.github/workflows/gh_pages.yml deleted file mode 100644 index 429067c1c..000000000 --- a/.github/workflows/gh_pages.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Build Docs - -on: - push: - branches: [ master ] - - workflow_dispatch: - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - fail-fast: false - - - steps: - - uses: actions/checkout@v2 - - - name: build docs - run: | - scripts/install_docs_deps.sh - ./make_docs.sh - cd html-dir - touch .nojekyll - cd ../.. - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: html-dir - publish_branch: gh_pages diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2e4988f1b..402bd9107 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,51 +12,114 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04] - build_type: [Debug, Release] - row_major: [ON, OFF] - basic_logging: [ON, OFF] - exclude: - - build_type: Release - row_major: ON - - build_type: Release - basic_logging: ON - - build_type: Debug - row_major: ON - basic_logging: ON - fail-fast: false - env: - BUILD_TYPE: ${{ matrix.build_type }} - ROW_MAJOR_DEFAULT: ${{ matrix.row_major }} - USE_BASIC_LOGGING: ${{ matrix.basic_logging }} + include: + - test: unit_tests + os: ubuntu-22.04 + access: row_major + ensure: default_panic + compiler: clang + - test: unit_tests + os: ubuntu-24.04 + access: col_major + ensure: default_panic + compiler: clang + - test: unit_tests + os: ubuntu-22.04 + access: col_major + ensure: default_panic + compiler: gcc + - test: unit_tests + os: ubuntu-24.04 + access: col_major + ensure: default_panic + compiler: gcc + - test: unit_tests + os: macos-13 + access: col_major + ensure: default_panic + compiler: clang + - test: unit_tests + os: macos-14 + access: col_major + ensure: default_panic + compiler: clang + - test: install_test + os: ubuntu-22.04 + access: col_major + ensure: default_panic + compiler: clang + - test: install_test + os: ubuntu-22.04 + access: col_major + ensure: custom_handler + compiler: clang + - test: install_test + os: macos-14 + access: col_major + ensure: default_panic + compiler: clang + - test: install_test + os: macos-14 + access: col_major + ensure: custom_handler + compiler: clang + fail-fast: false steps: - - uses: actions/checkout@v2 + - name: Set default value for for environment variables + run: | + echo "ROW_MAJOR_DEFAULT=OFF" >> $GITHUB_ENV + echo "SOPHUS_ENABLE_ENSURE_HANDLER=OFF" >> $GITHUB_ENV - - name: Format - uses: DoozyX/clang-format-lint-action@v0.12 - with: - source: '.' - extensions: 'hpp,cpp' - exclude: './sympy ./doxyrest_b' - clangFormatVersion: 9 - if: matrix.os == 'ubuntu-20.04' + - name: Update ROW_MAJOR_DEFAULT=ON if condition is met + if: matrix.access == 'row_major' + run: echo "ROW_MAJOR_DEFAULT=ON" >> $GITHUB_ENV + + - name: Update SOPHUS_ENABLE_ENSURE_HANDLER=ON if condition is met + if: matrix.ensure == 'custom_handler' + run: echo "SOPHUS_ENABLE_ENSURE_HANDLER=ON" >> $GITHUB_ENV + + - uses: actions/checkout@v2 - name: ccache uses: hendrikmuhs/ccache-action@v1 + with: + key: ${{ runner.os }}-${{ matrix.os }}-${{ matrix.access }}-${{ matrix.ensure }}-${{ matrix.compiler }} + restore-keys: | + ${{ runner.os }}-${{ matrix.os }}-${{ matrix.access }}-${{ matrix.ensure }}-${{ matrix.compiler }} + + - name: Install dependencies (Linux incl. Ceres) + run: ./scripts/install_ubuntu_deps_incl_ceres.sh + if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-24.04' - - name: Install dependencies (Linux) - run: ./scripts/install_linux_deps.sh - if: matrix.os == 'ubuntu-20.04' + - name: Install dependencies (Mac OS incl. Ceres) + run: ./scripts/install_osx_deps_incl_ceres.sh + if: matrix.os == 'macos-14' || matrix.os == 'macos-13' - - name: Install fmt dependency (Linux) - run: ./scripts/install_linux_fmt_deps.sh - if: matrix.os == 'ubuntu-20.04' && matrix.basic_logging == 'OFF' + - name: Build (gcc) and run tests + run: ./scripts/run_cpp_tests_gcc.sh + if: matrix.test == 'unit_tests' && matrix.compiler == 'gcc' - - name: Install dependencies (Mac OS) - run: ./scripts/install_osx_deps.sh - if: matrix.os == 'macos-10.15' + - name: Build (clang) and run tests + run: ./scripts/run_cpp_tests_clang.sh + if: matrix.test == 'unit_tests' && matrix.compiler == 'clang' - - name: Run tests - run: ./scripts/run_cpp_tests.sh + - name: Install test + run: | + echo "Install test" + mkdir build_dir + cd build_dir + cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .. -DSOPHUS_ENABLE_ENSURE_HANDLER=$SOPHUS_ENABLE_ENSURE_HANDLER + # Ubuntu builds via Github actions run on 2-core virtual machines + make -j2 + sudo make install + cd .. + cd examples + mkdir build_dir + cd build_dir + cmake .. + make + ls -la + ./hello_so3 + if: matrix.test == 'install_test' diff --git a/.github/workflows/build-and-test-sophus-pybind.yml b/.github/workflows/pybind.yml similarity index 95% rename from .github/workflows/build-and-test-sophus-pybind.yml rename to .github/workflows/pybind.yml index 2cf39d06e..42f15068e 100644 --- a/.github/workflows/build-and-test-sophus-pybind.yml +++ b/.github/workflows/pybind.yml @@ -1,4 +1,4 @@ -name: Build and Test +name: Pybind tests on: push: @@ -12,7 +12,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, macos-10.15] + os: [ubuntu-20.04, macos-13] + fail-fast: false + steps: - name : Checkout uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 0aed9a819..d2df4b884 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ build CMakeLists.txt.user *.pyc -.vscode/settings.json \ No newline at end of file +.vscode/settings.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..fb2cd2fca --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + exclude: (thirdparty/.*)|(.txt)$ + - id: check-yaml + args: ["--unsafe"] + - id: check-json + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v14.0.0 + hooks: + - id: clang-format + exclude: (sympy/.*) + types_or: [file] + files: .*(\.hpp|\.cpp|\.h\.glsl|\.proto)$ + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.7.1 + hooks: + - id: prettier + files: ^.*\/ts\/.*\.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|tsx|xml|yaml|yml)$ + - repo: https://github.com/cheshirekow/cmake-format-precommit + rev: v0.6.10 + hooks: + - id: cmake-format + # lint does not pass + #- id: cmake-lint diff --git a/CMakeLists.txt b/CMakeLists.txt index eed097231..9dfc48f89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,141 +1,102 @@ -cmake_minimum_required(VERSION 3.4) -project(Sophus VERSION 1.22.10) +cmake_minimum_required(VERSION 3.16) +project(Sophus VERSION 1.24.06) include(CMakePackageConfigHelpers) include(GNUInstallDirs) -# Determine if sophus is built as a subproject (using add_subdirectory) -# or if it is the master project. -if (NOT DEFINED SOPHUS_MASTER_PROJECT) +# Determine if sophus is built as a subproject (using add_subdirectory) or if it +# is the master project. +if(NOT DEFINED SOPHUS_MASTER_PROJECT) set(SOPHUS_MASTER_PROJECT OFF) - if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(SOPHUS_MASTER_PROJECT ON) message(STATUS "CMake version: ${CMAKE_VERSION}") - endif () -endif () + endif() +endif() option(SOPHUS_INSTALL "Generate the install target." ${SOPHUS_MASTER_PROJECT}) -option(SOPHUS_USE_BASIC_LOGGING "Use basic logging (in ensure and test macros)" OFF) if(SOPHUS_MASTER_PROJECT) - # Release by default - # Turn on Debug with "-DCMAKE_BUILD_TYPE=Debug" + # Release by default Turn on Debug with "-DCMAKE_BUILD_TYPE=Debug" if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) + set(CMAKE_BUILD_TYPE RelWithDebInfo) endif() - set(CMAKE_CXX_STANDARD 14) - - # Set compiler specific settings (FixMe: Should not cmake do this for us automatically?) - IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") - SET(CMAKE_CXX_FLAGS_RELEASE "-O3") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wno-deprecated-register -Qunused-arguments -fcolor-diagnostics") - ELSEIF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") - SET(CMAKE_CXX_FLAGS_RELEASE "-O3") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -std=c++14 -Wno-deprecated-declarations -ftemplate-backtrace-limit=0") - SET(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG} --coverage -fno-inline -fno-inline-small-functions -fno-default-inline") - SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS_DEBUG} --coverage") - SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} --coverage") - ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "^MSVC$") - ADD_DEFINITIONS("-D _USE_MATH_DEFINES /bigobj /wd4305 /wd4244 /MP") - ENDIF() + set(CMAKE_CXX_STANDARD 17) + + # Set compiler specific settings (FixMe: Should not cmake do this for us + # automatically?) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") + set(CMAKE_CXX_FLAGS_RELEASE "-O3") + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wno-deprecated-register -Qunused-arguments -fcolor-diagnostics" + ) + elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") + set(CMAKE_CXX_FLAGS_RELEASE "-O3") + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -std=c++14 -Wno-deprecated-declarations -ftemplate-backtrace-limit=0 -Wno-array-bounds" + ) + endif() # Add local path for finding packages, set the local version first list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules") endif() -if(SOPHUS_USE_BASIC_LOGGING) - set (CMAKE_DISABLE_FIND_PACKAGE_fmt ON) -endif() - -# Find public dependencies if targets are not yet defined. (Targets might be for example -# defined by a parent project including Sophus via `add_subdirectory`.) +# Find public dependencies if targets are not yet defined. (Targets might be for +# example defined by a parent project including Sophus via `add_subdirectory`.) if(NOT TARGET Eigen3::Eigen) - find_package(Eigen3 3.3.0 REQUIRED) + find_package(Eigen3 3.4.0 REQUIRED) endif() -if(NOT TARGET fmt::fmt) - find_package(fmt) -endif() - - # Define interface library target add_library(sophus INTERFACE) -add_library (Sophus::Sophus ALIAS sophus) +add_library(Sophus::Sophus ALIAS sophus) set(SOPHUS_HEADER_FILES - sophus/average.hpp - sophus/cartesian.hpp - sophus/ceres_local_parameterization.hpp - sophus/ceres_manifold.hpp - sophus/ceres_typetraits.hpp - sophus/common.hpp - sophus/geometry.hpp - sophus/interpolate.hpp - sophus/interpolate_details.hpp - sophus/num_diff.hpp - sophus/rotation_matrix.hpp - sophus/rxso2.hpp - sophus/rxso3.hpp - sophus/se2.hpp - sophus/se3.hpp - sophus/sim2.hpp - sophus/sim3.hpp - sophus/sim_details.hpp - sophus/so2.hpp - sophus/so3.hpp - sophus/spline.hpp - sophus/types.hpp - sophus/velocities.hpp -) - -set(SOPHUS_OTHER_FILES - sophus/test_macros.hpp - sophus/example_ensure_handler.cpp -) + sophus/average.hpp + sophus/cartesian.hpp + sophus/ceres_manifold.hpp + sophus/ceres_typetraits.hpp + sophus/common.hpp + sophus/geometry.hpp + sophus/interpolate.hpp + sophus/interpolate_details.hpp + sophus/num_diff.hpp + sophus/rotation_matrix.hpp + sophus/rxso2.hpp + sophus/rxso3.hpp + sophus/se2.hpp + sophus/se3.hpp + sophus/sim2.hpp + sophus/sim3.hpp + sophus/sim_details.hpp + sophus/so2.hpp + sophus/so3.hpp + sophus/spline.hpp + sophus/types.hpp) + +set(SOPHUS_OTHER_FILES sophus/test_macros.hpp) if(MSVC) # Define common math constants if we compile with MSVC - target_compile_definitions (sophus INTERFACE _USE_MATH_DEFINES) -endif (MSVC) + target_compile_definitions(sophus INTERFACE _USE_MATH_DEFINES) +endif(MSVC) # Add Eigen interface dependency, depending on available cmake info if(TARGET Eigen3::Eigen) target_link_libraries(sophus INTERFACE Eigen3::Eigen) set(Eigen3_DEPENDENCY "find_dependency (Eigen3 ${Eigen3_VERSION})") else() - target_include_directories (sophus SYSTEM INTERFACE ${EIGEN3_INCLUDE_DIR}) -endif() - -if(SOPHUS_USE_BASIC_LOGGING OR NOT TARGET fmt::fmt) - # NOTE fmt_FOUND does not seem to be defined even though the package config - # was found. - target_compile_definitions(sophus INTERFACE SOPHUS_USE_BASIC_LOGGING=1) - message(STATUS "Turning basic logging ON") -else() - target_link_libraries(sophus INTERFACE fmt::fmt) - set(fmt_DEPENDENCY "find_dependency (fmt ${fmt_VERSION})") - message(STATUS "Turning basic logging OFF") + target_include_directories(sophus SYSTEM INTERFACE ${EIGEN3_INCLUDE_DIR}) endif() # Associate target with include directory -target_include_directories(sophus INTERFACE - "$" - "$" -) - -# Declare all used C++14 features -target_compile_features (sophus INTERFACE - cxx_auto_type - cxx_decltype - cxx_nullptr - cxx_right_angle_brackets - cxx_variadic_macros - cxx_variadic_templates -) +target_include_directories( + sophus INTERFACE "$" + "$") # Add sources as custom target so that they are shown in IDE's add_custom_target(other SOURCES ${SOPHUS_OTHER_FILES} ${SOPHUS_HEADER_FILES}) @@ -143,14 +104,8 @@ add_custom_target(other SOURCES ${SOPHUS_OTHER_FILES} ${SOPHUS_HEADER_FILES}) # Create 'test' make target using ctest option(BUILD_SOPHUS_TESTS "Build tests." ON) if(BUILD_SOPHUS_TESTS) - enable_testing() - add_subdirectory(test) -endif() - -# Create examples make targets using ctest -option(BUILD_SOPHUS_EXAMPLES "Build examples." ON) -if(BUILD_SOPHUS_EXAMPLES) - add_subdirectory(examples) + enable_testing() + add_subdirectory(test) endif() # Build python sophus bindings @@ -158,14 +113,14 @@ option(BUILD_PYTHON_BINDINGS "Build python sophus bindings." OFF) if(BUILD_PYTHON_BINDINGS) include(FetchContent) FetchContent_Declare( - pybind11 - GIT_REPOSITORY https://github.com/pybind/pybind11.git - GIT_TAG master - ) + pybind11 + GIT_REPOSITORY https://github.com/pybind/pybind11.git + GIT_TAG master) FetchContent_MakeAvailable(pybind11) add_subdirectory(${pybind11_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/pybind) - pybind11_add_module(sophus_pybind ${CMAKE_CURRENT_SOURCE_DIR}/sophus_pybind/bindings.cpp) + pybind11_add_module(sophus_pybind + ${CMAKE_CURRENT_SOURCE_DIR}/sophus_pybind/bindings.cpp) target_link_libraries(sophus_pybind PUBLIC sophus) endif(BUILD_PYTHON_BINDINGS) @@ -176,45 +131,41 @@ if(SOPHUS_INSTALL) set_target_properties(sophus PROPERTIES EXPORT_NAME Sophus) install(TARGETS sophus EXPORT SophusTargets) - install(EXPORT SophusTargets + install( + EXPORT SophusTargets NAMESPACE Sophus:: - DESTINATION ${SOPHUS_CMAKE_EXPORT_DIR} - ) + DESTINATION ${SOPHUS_CMAKE_EXPORT_DIR}) - export(TARGETS sophus NAMESPACE Sophus:: FILE SophusTargets.cmake) + export( + TARGETS sophus + NAMESPACE Sophus:: + FILE SophusTargets.cmake) export(PACKAGE Sophus) configure_package_config_file( - SophusConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/SophusConfig.cmake + SophusConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/SophusConfig.cmake INSTALL_DESTINATION ${SOPHUS_CMAKE_EXPORT_DIR} - NO_CHECK_REQUIRED_COMPONENTS_MACRO - ) + NO_CHECK_REQUIRED_COMPONENTS_MACRO) # Remove architecture dependence. Sophus is a header-only library. set(TEMP_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) unset(CMAKE_SIZEOF_VOID_P) # Write version to file - write_basic_package_version_file ( + write_basic_package_version_file( SophusConfigVersion.cmake VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion - ) + COMPATIBILITY SameMajorVersion) # Recover architecture dependence set(CMAKE_SIZEOF_VOID_P ${TEMP_SIZEOF_VOID_P}) # Install cmake targets - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/SophusConfig.cmake - ${CMAKE_CURRENT_BINARY_DIR}/SophusConfigVersion.cmake - DESTINATION ${SOPHUS_CMAKE_EXPORT_DIR} - ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/SophusConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/SophusConfigVersion.cmake + DESTINATION ${SOPHUS_CMAKE_EXPORT_DIR}) # Install header files - install( - FILES ${SOPHUS_HEADER_FILES} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sophus - ) + install(FILES ${SOPHUS_HEADER_FILES} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sophus) endif() diff --git a/LICENSE.txt b/LICENSE.txt index fb67702de..5e0fd3e3f 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright 2011-2017 Hauke Strasdat +Copyright 2011-2017 Hauke Strasdat 2012-2017 Steven Lovegrove Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/README.md b/README.md new file mode 100644 index 000000000..cf5ac6fa0 --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +

Sophus

+ +

+ A collection of c++ types for 2d and 3d geometric problems. +

+ +
+ + + Build CI Badge + + +PyBind CI Badge + + +Sympy CI Badge + + + License Badge + + +
+ + +This is a c++ implementation of Lie groups commonly used for 2d and 3d +geometric problems (i.e. for Computer Vision or Robotics applications). +Among others, this package includes the special orthogonal groups SO(2) and +SO(3) to present rotations in 2d and 3d as well as the special Euclidean group +SE(2) and SE(3) to represent isometries also known as rigid body transformations +(i.e. rotations and translations) in 2d and 3d. + +## Status + + +*Sophus (aka Sophus 1) is in maintenance mode and there is no plane to add new larger features +(as of June 2024).* + + +However, next incarnations of Sophus are under development: + + + - sophus2 is the next c++ iteration of Sophus and is a complete rewrite. + In addition to the Lie groups, it includes a more geometric concepts + such unit vector, splines, image classes, camera models and more. + + It is currently hosted as part of the [farm-ng-core repository](https://github.com/farm-ng/farm-ng-core/tree/cygnet-dev) + and has likely only a few community users. While the code itself is in a good shape, there are + no good build instructions yet. Hopefully, this will change in the near future. + + + - sophus-rs is a Rust version of Sophus. Similar to sophus2, it includes a more geometric concepts + such unit vector, splines, image classes, camera models and more. Also it includes an early and + experimental version of non-linear least squares optimization library (similar to Ceres, g2o, + etc.). + + sophus-rs has likely only a few community users so far, but should be easy to build and + experiment with - of course being written in Rust. + + https://github.com/sophus-vision/sophus-rs + + https://crates.io/crates/sophus + + + +How to build +------------ + +Sophus requires a C++17 compiler (though older versions build with C++14). + +Sophus is tested on Linux and macOS. It also worked on Windows in the past, however there is +currently no CI for Windows, so it might require some smaller patches to build on Windows. + +There are no comprehensive build instructions but inspecting the install [scripts](scripts/) +as well as the [main.yml](.github/workflows/main.yml) file should give you a good idea how to +build the required dependencies. diff --git a/README.rst b/README.rst deleted file mode 100644 index e7aab639b..000000000 --- a/README.rst +++ /dev/null @@ -1,44 +0,0 @@ -|GithubCICpp|_ windows: |AppVeyor|_ |GithubCISympy|_ |ci_cov|_ - - -Sophus -====== - -Overview --------- - -This is a c++ implementation of Lie groups commonly used for 2d and 3d -geometric problems (i.e. for Computer Vision or Robotics applications). -Among others, this package includes the special orthogonal groups SO(2) and -SO(3) to present rotations in 2d and 3d as well as the special Euclidean group -SE(2) and SE(3) to represent rigid body transformations (i.e. rotations and -translations) in 2d and 3d. - -API documentation: https://strasdat.github.io/Sophus/ - -Cross platform support ----------------------- - -Sophus compiles with clang and gcc on Linux and OS X as well as msvc on Windows. -The specific compiler and operating system versions which are supported are -the ones which are used in the Continuous Integration (CI): See GitHubCI_ and -AppVeyor_ for details. - -However, it should work (with no to minor modification) on many other -modern configurations as long they support c++14, CMake, Eigen 3.3.X and -(optionally) fmt. The fmt dependency can be eliminated by passing -"-DUSE_BASIC_LOGGING=ON" to cmake when configuring Sophus. - -.. _GitHubCI: https://github.com/strasdat/Sophus/actions - -.. |AppVeyor| image:: https://ci.appveyor.com/api/projects/status/um4285lwhs8ci7pt/branch/master?svg=true -.. _AppVeyor: https://ci.appveyor.com/project/strasdat/sophus/branch/master - -.. |ci_cov| image:: https://coveralls.io/repos/github/strasdat/Sophus/badge.svg?branch=master -.. _ci_cov: https://coveralls.io/github/strasdat/Sophus?branch=master - -.. |GithubCICpp| image:: https://github.com/strasdat/Sophus/actions/workflows/main.yml/badge.svg?branch=master -.. _GithubCICpp: https://github.com/strasdat/Sophus/actions/workflows/main.yml?query=branch%3Amaster - -.. |GithubCISympy| image:: https://github.com/strasdat/Sophus/actions/workflows/sympy.yml/badge.svg?branch=master -.. _GithubCISympy: https://github.com/strasdat/Sophus/actions/workflows/sympy.yml?query=branch%3Amaster diff --git a/Sophus.code-workspace b/Sophus.code-workspace index 876a1499c..b3aa39876 100644 --- a/Sophus.code-workspace +++ b/Sophus.code-workspace @@ -4,5 +4,67 @@ "path": "." } ], - "settings": {} -} \ No newline at end of file + "settings": { + "files.associations": { + "type_traits": "cpp", + "array": "cpp", + "optional": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "complex": "cpp", + "concepts": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "random": "cpp", + "ratio": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "utility": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "semaphore": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "cinttypes": "cpp", + "typeinfo": "cpp" + } + } +} diff --git a/SophusConfig.cmake.in b/SophusConfig.cmake.in index e8283eda3..1e9a11765 100644 --- a/SophusConfig.cmake.in +++ b/SophusConfig.cmake.in @@ -3,6 +3,5 @@ include (CMakeFindDependencyMacro) @Eigen3_DEPENDENCY@ -@fmt_DEPENDENCY@ include ("${CMAKE_CURRENT_LIST_DIR}/SophusTargets.cmake") diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 6fe6813fb..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,35 +0,0 @@ -branches: - only: - - master - -os: Visual Studio 2015 - -clone_folder: c:\projects\sophus - -platform: x64 -configuration: Debug - -build: - project: c:\projects\sophus\build\Sophus.sln - -install: - - ps: wget https://gitlab.com/libeigen/eigen/-/archive/3.3.4/eigen-3.3.4.zip -outfile eigen3.zip - - cmd: 7z x eigen3.zip -o"C:\projects" -y > nul - - git clone https://github.com/fmtlib/fmt.git - - cd fmt - - git checkout 5.3.0 - - mkdir build - - cd build - - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Debug .. - - cmake --build . - - cmake --build . --target install - - cd ../.. - -before_build: - - cd c:\projects\sophus - - mkdir build - - cd build - - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Debug -D EIGEN3_INCLUDE_DIR=C:\projects\eigen-3.3.4 .. - -after_build: - - ctest --output-on-failure diff --git a/cmake_modules/FindEigen3.cmake b/cmake_modules/FindEigen3.cmake deleted file mode 100644 index 0b36805e7..000000000 --- a/cmake_modules/FindEigen3.cmake +++ /dev/null @@ -1,107 +0,0 @@ -# - Try to find Eigen3 lib -# -# This module supports requiring a minimum version, e.g. you can do -# find_package(Eigen3 3.1.2) -# to require version 3.1.2 or newer of Eigen3. -# -# Once done this will define -# -# EIGEN3_FOUND - system has eigen lib with correct version -# EIGEN3_INCLUDE_DIR - the eigen include directory -# EIGEN3_VERSION - eigen version -# -# and the following imported target: -# -# Eigen3::Eigen - The header-only Eigen library -# -# This module reads hints about search locations from -# the following environment variables: -# -# EIGEN3_ROOT -# EIGEN3_ROOT_DIR - -# Copyright (c) 2006, 2007 Montel Laurent, -# Copyright (c) 2008, 2009 Gael Guennebaud, -# Copyright (c) 2009 Benoit Jacob -# Redistribution and use is allowed according to the terms of the 2-clause BSD license. - -if(NOT Eigen3_FIND_VERSION) - if(NOT Eigen3_FIND_VERSION_MAJOR) - set(Eigen3_FIND_VERSION_MAJOR 2) - endif() - if(NOT Eigen3_FIND_VERSION_MINOR) - set(Eigen3_FIND_VERSION_MINOR 91) - endif() - if(NOT Eigen3_FIND_VERSION_PATCH) - set(Eigen3_FIND_VERSION_PATCH 0) - endif() - - set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}") -endif() - -macro(_eigen3_check_version) - file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) - - string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") - set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") - set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") - set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}") - - set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION}) - if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) - set(EIGEN3_VERSION_OK FALSE) - else() - set(EIGEN3_VERSION_OK TRUE) - endif() - - if(NOT EIGEN3_VERSION_OK) - - message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, " - "but at least version ${Eigen3_FIND_VERSION} is required") - endif() -endmacro() - -if (EIGEN3_INCLUDE_DIR) - - # in cache already - _eigen3_check_version() - set(EIGEN3_FOUND ${EIGEN3_VERSION_OK}) - set(Eigen3_FOUND ${EIGEN3_VERSION_OK}) - -else () - - # search first if an Eigen3Config.cmake is available in the system, - # if successful this would set EIGEN3_INCLUDE_DIR and the rest of - # the script will work as usual - find_package(Eigen3 ${Eigen3_FIND_VERSION} NO_MODULE QUIET) - - if(NOT EIGEN3_INCLUDE_DIR) - find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library - HINTS - ENV EIGEN3_ROOT - ENV EIGEN3_ROOT_DIR - PATHS - ${CMAKE_INSTALL_PREFIX}/include - ${KDE4_INCLUDE_DIR} - PATH_SUFFIXES eigen3 eigen - ) - endif() - - if(EIGEN3_INCLUDE_DIR) - _eigen3_check_version() - endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) - - mark_as_advanced(EIGEN3_INCLUDE_DIR) - -endif() - -if(EIGEN3_FOUND AND NOT TARGET Eigen3::Eigen) - add_library(Eigen3::Eigen INTERFACE IMPORTED) - set_target_properties(Eigen3::Eigen PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${EIGEN3_INCLUDE_DIR}") -endif() diff --git a/doxyfile b/doxyfile deleted file mode 100644 index 995ed8991..000000000 --- a/doxyfile +++ /dev/null @@ -1,24 +0,0 @@ -DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = "Sophus" -INPUT = sophus -EXTRACT_ALL = YES -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = YES -WARN_AS_ERROR = YES -EXPAND_ONLY_PREDEF = NO -SKIP_FUNCTION_MACROS = NO -AUTOLINK_SUPPORT = YES -MULTILINE_CPP_IS_BRIEF = YES -MARKDOWN_SUPPORT = YES -INLINE_INHERITED_MEMB = NO -EXCLUDE_SYMBOLS = Eigen::internal Sophus::details Sophus::interp_details Sophus::experimental -GENERATE_LATEX = NO -STRIP_CODE_COMMENTS = NO - -GENERATE_XML = YES -GENERATE_HTML = NO -XML_OUTPUT = xml-dir -XML_PROGRAMLISTING = NO -CASE_SENSE_NAMES = NO -HIDE_UNDOC_RELATIONS = YES -EXTRACT_ALL = YES \ No newline at end of file diff --git a/doxyrest-config.lua b/doxyrest-config.lua deleted file mode 100644 index c4e8bc864..000000000 --- a/doxyrest-config.lua +++ /dev/null @@ -1,20 +0,0 @@ -FRAME_DIR_LIST = { "doxyrest_b/doxyrest/frame/cfamily", "doxyrest_b/doxyrest/frame/common" } -FRAME_FILE = "index.rst.in" -INPUT_FILE = "xml-dir/index.xml" -OUTPUT_FILE = "rst-dir/index.rst" -INTRO_FILE = "page_index.rst" -SORT_GROUPS_BY = "title" -GLOBAL_AUX_COMPOUND_ID = "group_global" -LANGUAGE = cpp -VERBATIM_TO_CODE_BLOCK = "cpp" -ESCAPE_ASTERISKS = true -ESCAPE_PIPES = true -ESCAPE_TRAILING_UNDERSCORES = true -PROTECTION_FILTER = "protected" -EXCLUDE_EMPTY_DEFINES = true -EXCLUDE_DEFAULT_CONSTRUCTORS = false -EXCLUDE_DESTRUCTORS = false -EXCLUDE_PRIMITIVE_TYPEDEFS = true -SHOW_DIRECT_DESCENDANTS = true -TYPEDEF_TO_USING = true -ML_PARAM_LIST_LENGTH_THRESHOLD = 80 \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ff933a214..810800e7d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,31 @@ +cmake_minimum_required(VERSION 3.16) + +project(SophusExample) + +find_package(Sophus 1.24.06 REQUIRED) +set(CMAKE_CXX_STANDARD 17) + +# Release by default Turn on Debug with "-DCMAKE_BUILD_TYPE=Debug" +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE RelWithDebInfo) +endif() + # Tests to run -SET( EXAMPLE_SOURCES HelloSO3) +set(EXAMPLE_SOURCES hello_so3 ensure_example) + +option(SOPHUS_ENABLE_ENSURE_HANDLER "Enable the custem ensure handler." OFF) +if(SOPHUS_ENABLE_ENSURE_HANDLER) + add_library(custom_ensure_handler custom_ensure_handler.cpp) + target_link_libraries(custom_ensure_handler PRIVATE Sophus::Sophus) +endif() -FOREACH(example_src ${EXAMPLE_SOURCES}) - ADD_EXECUTABLE( ${example_src} ${example_src}.cpp) - TARGET_LINK_LIBRARIES( ${example_src} sophus) -ENDFOREACH(example_src) +foreach(example_src ${EXAMPLE_SOURCES}) + add_executable(${example_src} ${example_src}.cpp) + if(SOPHUS_ENABLE_ENSURE_HANDLER) + target_compile_definitions(${example_src} + PRIVATE SOPHUS_ENABLE_ENSURE_HANDLER=1) + target_link_libraries(${example_src} Sophus::Sophus custom_ensure_handler) + else() + target_link_libraries(${example_src} Sophus::Sophus) + endif() +endforeach(example_src) diff --git a/sophus/example_ensure_handler.cpp b/examples/custom_ensure_handler.cpp similarity index 78% rename from sophus/example_ensure_handler.cpp rename to examples/custom_ensure_handler.cpp index 5acf26a40..e79b98ce0 100644 --- a/sophus/example_ensure_handler.cpp +++ b/examples/custom_ensure_handler.cpp @@ -1,4 +1,4 @@ -#include "common.hpp" +#include #include #include @@ -8,7 +8,6 @@ void ensureFailed(char const* function, char const* file, int line, char const* description) { std::printf("Sophus ensure failed in function '%s', file '%s', line %d.\n", file, function, line); - std::printf("Description: %s\n", description); - std::abort(); + throw std::runtime_error("Sophus ensure failed"); } } // namespace Sophus diff --git a/examples/ensure_example.cpp b/examples/ensure_example.cpp new file mode 100644 index 000000000..05d1b6856 --- /dev/null +++ b/examples/ensure_example.cpp @@ -0,0 +1,5 @@ +#include + +#include + +int main() { SOPHUS_ENSURE(false, "There is an error. Details: {}", 42); } diff --git a/examples/HelloSO3.cpp b/examples/hello_so3.cpp similarity index 80% rename from examples/HelloSO3.cpp rename to examples/hello_so3.cpp index ad998a353..11a778744 100644 --- a/examples/HelloSO3.cpp +++ b/examples/hello_so3.cpp @@ -1,5 +1,6 @@ #include -#include "sophus/geometry.hpp" + +#include int main() { // The following demonstrates the group multiplication of rotation matrices @@ -22,17 +23,17 @@ int main() { Eigen::Vector3d x; x << 0.0, 0.0, 1.0; std::cout << "Rotation matrices can act on vectors" << std::endl; - std::cout << "x\n" << x << std::endl; + std::cout << "x\n" << x.transpose() << std::endl; std::cout << "R2*x\n" << R2 * x << std::endl; - std::cout << "R1*(R2*x)\n" << R1 * (R2 * x) << std::endl; - std::cout << "(R1*R2)*x\n" << (R1 * R2) * x << std::endl; + std::cout << "R1*(R2*x)\n" << (R1 * (R2 * x)).transpose() << std::endl; + std::cout << "(R1*R2)*x\n" << ((R1 * R2) * x).transpose() << std::endl; std::cout << std::endl; // SO(3) are internally represented as unit quaternions. std::cout << "R1 in matrix form:\n" << R1.matrix() << std::endl; std::cout << "R1 in unit quaternion form:\n" - << R1.unit_quaternion().coeffs() << std::endl; + << R1.unit_quaternion().coeffs().transpose() << std::endl; // Note that the order of coefficients of Eigen's quaternion class is // (imag0, imag1, imag2, real) std::cout << std::endl; -} \ No newline at end of file +} diff --git a/make_docs.sh b/make_docs.sh deleted file mode 100755 index 6393cef3d..000000000 --- a/make_docs.sh +++ /dev/null @@ -1,3 +0,0 @@ -doxygen doxyfile -doxyrest_b/build/doxyrest/bin/Release/doxyrest -c doxyrest-config.lua -sphinx-build -b html rst-dir html-dir \ No newline at end of file diff --git a/rst-dir/conf.py b/rst-dir/conf.py deleted file mode 100644 index 76ed90a84..000000000 --- a/rst-dir/conf.py +++ /dev/null @@ -1,54 +0,0 @@ -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# http://www.sphinx-doc.org/en/master/config - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -import os -import sys -sys.path.insert(0, os.path.abspath('../sympy')) - - -sys.path.insert(1, os.path.abspath('../doxyrest_b/doxyrest/sphinx')) -extensions = ['doxyrest', 'cpplexer', 'sphinx.ext.autodoc'] - -# -- Project information ----------------------------------------------------- - -project = 'Sophus' -copyright = '2019, Hauke Strasdat' -author = 'Hauke Strasdat' - - -# Tell sphinx what the primary language being documented is. -primary_domain = 'cpp' - -# Tell sphinx what the pygments highlight language should be. -highlight_language = 'cpp' - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = [] - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = "sphinx_rtd_theme" - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] diff --git a/rst-dir/page_index.rst b/rst-dir/page_index.rst deleted file mode 100644 index 9955aca10..000000000 --- a/rst-dir/page_index.rst +++ /dev/null @@ -1,9 +0,0 @@ -Sophus - Lie groups for 2d/3d Geometry -======================================= - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - GitHub Page - pysophus \ No newline at end of file diff --git a/rst-dir/pysophus.rst b/rst-dir/pysophus.rst deleted file mode 100644 index 3e532a0ac..000000000 --- a/rst-dir/pysophus.rst +++ /dev/null @@ -1,23 +0,0 @@ -Python API -========== - -.. automodule:: sophus.matrix - :members: - -.. automodule:: sophus.complex - :members: - -.. automodule:: sophus.quaternion - :members: - -.. automodule:: sophus.so2 - :members: - -.. automodule:: sophus.so3 - :members: - -.. automodule:: sophus.se2 - :members: - -.. automodule:: sophus.se3 - :members: \ No newline at end of file diff --git a/run_format.sh b/run_format.sh deleted file mode 100755 index ef6b7403d..000000000 --- a/run_format.sh +++ /dev/null @@ -1 +0,0 @@ -find . -type d \( -path ./sympy -o -path ./doxyrest_b -o -path "./*/CMakeFiles/*" \) -prune -o \( -iname "*.hpp" -o -iname "*.cpp" \) -print | xargs clang-format -i diff --git a/scripts/install_docs_deps.sh b/scripts/install_docs_deps.sh deleted file mode 100755 index c947a41e8..000000000 --- a/scripts/install_docs_deps.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -x # echo on -set -e # exit on error - -sudo apt-get -qq update -sudo apt-get install doxygen liblua5.3-dev ragel -pip3 install 'sphinx==2.0.1' -pip3 install sphinx_rtd_theme -pip3 install sympy - -git clone https://github.com/vovkos/doxyrest_b -cd doxyrest_b -git reset --hard ad45c064d1199e71b8cae5aa66d4251c4228b958 -git submodule update --init -mkdir build -cd build -cmake .. -cmake --build . - -cd ../.. diff --git a/scripts/install_linux_deps.sh b/scripts/install_linux_deps.sh deleted file mode 100755 index 39c188de4..000000000 --- a/scripts/install_linux_deps.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -set -x # echo on -set -e # exit on error - -cmake --version - -sudo apt-get -qq update -sudo apt-get install gfortran libc++-dev libgoogle-glog-dev libatlas-base-dev libsuitesparse-dev libceres-dev ccache -wget https://gitlab.com/libeigen/eigen/-/archive/3.3.4/eigen-3.3.4.tar.bz2 -tar xvf eigen-3.3.4.tar.bz2 -mkdir build-eigen -cd build-eigen -cmake ../eigen-3.3.4 -DEIGEN_DEFAULT_TO_ROW_MAJOR=$ROW_MAJOR_DEFAULT -sudo make install -cd .. - -git clone https://ceres-solver.googlesource.com/ceres-solver ceres-solver -cd ceres-solver -git reset --hard b0aef211db734379319c19c030e734d6e23436b0 -mkdir build -cd build -ccache -s -cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .. -make -j8 -sudo make install -cd ../.. diff --git a/scripts/install_linux_fmt_deps.sh b/scripts/install_linux_fmt_deps.sh deleted file mode 100755 index acbfda2ca..000000000 --- a/scripts/install_linux_fmt_deps.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -set -x # echo on -set -e # exit on error - -git clone https://github.com/fmtlib/fmt.git -cd fmt -git checkout 5.3.0 -mkdir build -cd build -cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .. -make -j8 -sudo make install -cd ../.. diff --git a/scripts/install_osx_deps.sh b/scripts/install_osx_deps.sh deleted file mode 100755 index e2125dff7..000000000 --- a/scripts/install_osx_deps.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -set -x # echo on -set -e # exit on error - -brew update -brew install fmt -brew install ccache - -# Build a specific version of ceres-solver instead of one shipped over brew -curl https://raw.githubusercontent.com/Homebrew/homebrew-core/b0792ccba6e71cd028263ca7621db894afc602d2/Formula/ceres-solver.rb -o ceres-solver.rb -patch < -optional iterativeMean( +std::optional iterativeMean( SequenceContainer const& foo_Ts_bar, int max_num_iterations) { size_t N = foo_Ts_bar.size(); SOPHUS_ENSURE(N >= 1, "N must be >= 1."); @@ -52,23 +52,16 @@ optional iterativeMean( foo_T_average = foo_T_newaverage; } // LCOV_EXCL_START - return nullopt; + return std::nullopt; // LCOV_EXCL_STOP } -#ifdef DOXYGEN_SHOULD_SKIP_THIS -/// Mean implementation for any Lie group. -template -optional average( - SequenceContainer const& foo_Ts_bar); -#else - // Mean implementation for Cartesian. template -enable_if_t >::value, - optional > +std::enable_if_t >::value, + std::optional > average(SequenceContainer const& foo_Ts_bar) { size_t N = std::distance(std::begin(foo_Ts_bar), std::end(foo_Ts_bar)); SOPHUS_ENSURE(N >= 1, "N must be >= 1."); @@ -84,9 +77,9 @@ average(SequenceContainer const& foo_Ts_bar) { // Mean implementation for SO(2). template -enable_if_t< +std::enable_if_t< std::is_same >::value, - optional > + std::optional > average(SequenceContainer const& foo_Ts_bar) { // This implements rotational part of Proposition 12 from Sec. 6.2 of // ftp://ftp-sop.inria.fr/epidaure/Publications/Arsigny/arsigny_rr_biinvariant_average.pdf. @@ -105,9 +98,9 @@ average(SequenceContainer const& foo_Ts_bar) { // Mean implementation for RxSO(2). template -enable_if_t< +std::enable_if_t< std::is_same >::value, - optional > + std::optional > average(SequenceContainer const& foo_Ts_bar) { size_t N = std::distance(std::begin(foo_Ts_bar), std::end(foo_Ts_bar)); SOPHUS_ENSURE(N >= 1, "N must be >= 1."); @@ -179,9 +172,9 @@ Eigen::Quaternion averageUnitQuaternion( // TODO: Detect degenerated cases and return nullopt. template -enable_if_t< +std::enable_if_t< std::is_same >::value, - optional > + std::optional > average(SequenceContainer const& foo_Ts_bar) { return SO3(details::averageUnitQuaternion(foo_Ts_bar)); } @@ -189,9 +182,9 @@ average(SequenceContainer const& foo_Ts_bar) { // Mean implementation for R x SO(3). template -enable_if_t< +std::enable_if_t< std::is_same >::value, - optional > + std::optional > average(SequenceContainer const& foo_Ts_bar) { size_t N = std::distance(std::begin(foo_Ts_bar), std::end(foo_Ts_bar)); @@ -208,9 +201,9 @@ average(SequenceContainer const& foo_Ts_bar) { template -enable_if_t< +std::enable_if_t< std::is_same >::value, - optional > + std::optional > average(SequenceContainer const& foo_Ts_bar, int max_num_iterations = 20) { // TODO: Implement Proposition 12 from Sec. 6.2 of // ftp://ftp-sop.inria.fr/epidaure/Publications/Arsigny/arsigny_rr_biinvariant_average.pdf. @@ -219,31 +212,29 @@ average(SequenceContainer const& foo_Ts_bar, int max_num_iterations = 20) { template -enable_if_t< +std::enable_if_t< std::is_same >::value, - optional > + std::optional > average(SequenceContainer const& foo_Ts_bar, int max_num_iterations = 20) { return iterativeMean(foo_Ts_bar, max_num_iterations); } template -enable_if_t< +std::enable_if_t< std::is_same >::value, - optional > + std::optional > average(SequenceContainer const& foo_Ts_bar, int max_num_iterations = 20) { return iterativeMean(foo_Ts_bar, max_num_iterations); } template -enable_if_t< +std::enable_if_t< std::is_same >::value, - optional > + std::optional > average(SequenceContainer const& foo_Ts_bar, int max_num_iterations = 20) { return iterativeMean(foo_Ts_bar, max_num_iterations); } -#endif // DOXYGEN_SHOULD_SKIP_THIS - } // namespace Sophus diff --git a/sophus/cartesian.hpp b/sophus/cartesian.hpp index 8ade57eae..ee3e210a5 100644 --- a/sophus/cartesian.hpp +++ b/sophus/cartesian.hpp @@ -191,8 +191,8 @@ class CartesianBase { /// Group action on points, again just vector addition. /// template ::value>::type> + typename = typename std::enable_if_t< + IsFixedSizeVector::value>> SOPHUS_FUNC PointProduct operator*( Eigen::MatrixBase const& p) const { return PointProduct(params() + p); @@ -201,8 +201,8 @@ class CartesianBase { /// Group action on homogeneous points. See above for more details. /// template ::value>::type> + typename = typename std::enable_if_t< + IsFixedSizeVector::value>> SOPHUS_FUNC HomogeneousPointProduct operator*( Eigen::MatrixBase const& p) const { const auto rp = *this * p.template head(); @@ -228,8 +228,8 @@ class CartesianBase { /// type. /// template >::value>::type> + typename = typename std::enable_if_t< + std::is_same>::value>> SOPHUS_FUNC CartesianBase& operator*=( CartesianBase const& other) { *static_cast(this) = *this * other; diff --git a/sophus/ceres_local_parameterization.hpp b/sophus/ceres_local_parameterization.hpp deleted file mode 100644 index 63ee4a715..000000000 --- a/sophus/ceres_local_parameterization.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include - -#include - -namespace Sophus { - -/// Templated local parameterization for LieGroup [with implemented -/// LieGroup::Dx_this_mul_exp_x_at_0() ] -template