Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export NIX_CONFIG="allow-import-from-derivation = true"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ binding/python/build
*.swp
CMakeLists.txt.user*
*.autosave
build/
build
.cache/
compile_commands.json
result
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "cmake"]
path = cmake
url = https://github.com/jrl-umi3218/jrl-cmakemodules
[submodule "cmake-v2"]
path = cmake-v2
url = https://github.com/ahoarau/jrl-cmakemodules.git
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
- id: check-useless-excludes
- id: check-hooks-apply
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v21.1.5
rev: v21.1.8
hooks:
- id: clang-format
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
118 changes: 91 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,113 @@
# Copyright 2012-2019 CNRS-UM LIRMM, CNRS-AIST JRL
#

cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.22)

set(CMAKE_CXX_STANDARD 17)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
find_package(jrl-cmakemodules 0.2.0 CONFIG QUIET)
set(JRL_CMAKEMODULES_USE_V2
ON
CACHE BOOL "Use jrl-cmakemodules v2")
if(jrl-cmakemodules_FOUND)
message(
STATUS "Using jrl-cmakemodules from CMake package: ${jrl-cmakemodules_DIR}")
else()
message(STATUS "Using jrl-cmakemodules from source directory: cmake-v2")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake-v2 jrl-cmakemodules)
endif()

set(PROJECT_NAME SpaceVecAlg)
set(PROJECT_DESCRIPTION
project(
SpaceVecAlg
VERSION 1.2.7
DESCRIPTION
"Implementation of spatial vector algebra with the Eigen3 linear algebra library."
)
set(PROJECT_URL "https://github.com/jrl-umi3218/SpaceVecAlg")
set(PROJECT_VERSION 1.2.8)
set(PROJECT_USE_CMAKE_EXPORT TRUE)
set(PYTHON_BINDING_USE_PYTEST ON)
HOMEPAGE_URL "https://github.com/jrl-umi3218/SpaceVecAlg"
LANGUAGES CXX)

include(cmake/base.cmake)
include(cmake/cython/cython.cmake)
include(cmake/msvc-specific.cmake)
# Configure default binary and install directories, build type, etc.
jrl_configure_defaults()

# Disable -Werror on Unix for now.
set(CXX_DISABLE_WERROR True)
project(${PROJECT_NAME} CXX)
set(CMAKE_CXX_STANDARD 17)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

option(BENCHMARKS "Generate benchmark." OFF)
# -------
# OPTIONS
# -------
jrl_option(BUILD_TESTING "Build testing." ON)
jrl_option(BENCHMARKS "Generate benchmark." OFF)
jrl_option(NANOBIND_BINDINGS "Build nanobind Python bindings" ON)
# Disable old python bindings jrl_option(PYTHON_BINDING "Build cython Python
# bindings" OFF)

find_package(Eigen3 QUIET NO_CMAKE_PACKAGE_REGISTRY)
if(Eigen3_FOUND)
add_project_dependency(Eigen3 REQUIRED NO_CMAKE_PACKAGE_REGISTRY)
else()
add_project_dependency(Eigen3 MODULE REQUIRED)
endif()
# ------------
# DEPENDENCIES
# ------------
jrl_find_package(Eigen3 REQUIRED)

# For MSVC, set local environment variable to enable finding the built dll of
# the main library when launching ctest with RUN_TESTS
if(MSVC)
set(CMAKE_MSVCIDE_RUN_PATH "\$(SolutionDir)/src/\$(Configuration)")
endif(MSVC)

add_subdirectory(src)
# FIXME(jrl-cmakemodules v2): when moving the code of this section to
# src/CMakeLists.txt it fails because it cannot find SpaceVecAlg in
# BUILDSYSTEM_TARGETS as BUILDSYSTEM_TARGETS is local to the directory being
# processed

# add_subdirectory(src)

if(${BUILD_TESTING} OR ${BENCHMARKS})
set(HEADERS
src/SpaceVecAlg/fwd.h
src/SpaceVecAlg/MotionVec.h
src/SpaceVecAlg/ForceVec.h
src/SpaceVecAlg/ImpedanceVec.h
src/SpaceVecAlg/AdmittanceVec.h
src/SpaceVecAlg/PTransform.h
src/SpaceVecAlg/RBInertia.h
src/SpaceVecAlg/ABInertia.h
src/SpaceVecAlg/EigenTypedef.h
src/SpaceVecAlg/EigenUtility.h
src/SpaceVecAlg/Operators.h
src/SpaceVecAlg/MathFunc.h
src/SpaceVecAlg/Conversions.h
src/SpaceVecAlg/SpaceVecAlg)

add_library(SpaceVecAlg INTERFACE)
jrl_target_enforce_msvc_conformance(SpaceVecAlg PRIVATE)
target_link_libraries(SpaceVecAlg INTERFACE Eigen3::Eigen)
target_compile_features(SpaceVecAlg INTERFACE cxx_auto_type cxx_constexpr)
if(MSVC)
target_compile_options(SpaceVecAlg INTERFACE /source-charset:utf-8)
endif()
target_include_directories(
SpaceVecAlg INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>)

jrl_target_headers(SpaceVecAlg PUBLIC HEADERS ${HEADERS})
set_target_properties(SpaceVecAlg PROPERTIES VERSION ${PROJECT_VERSION})

# Declare export components
jrl_add_export_component(NAME SpaceVecAlg TARGETS SpaceVecAlg)
# END FIXME

if(BUILD_TESTING OR BENCHMARKS)
enable_testing()
add_subdirectory(tests)
endif()

if(${PYTHON_BINDING})
add_subdirectory(binding/python)
if(NANOBIND_BINDINGS)
message(STATUS "[${PROJECT_NAME}] Building Python bindings")
jrl_find_python(3.8 REQUIRED COMPONENTS Interpreter Development.Module)
jrl_find_nanobind(2.4.0 CONFIG REQUIRED)
add_subdirectory(binding/nanobind)
endif()

# Disable cython bindings if(PYTHON_BINDING) add_subdirectory(binding/python)
# endif()

# Export the package files (headers, targets, config files, etc.)
jrl_export_package()

# Print summaries
jrl_print_dependencies_summary()
jrl_print_options_summary()
2 changes: 2 additions & 0 deletions binding/nanobind/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CMakeCache.txt
CMakeFiles/
61 changes: 61 additions & 0 deletions binding/nanobind/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# We are now ready to compile the actual extension module
nanobind_add_module(
# Name of the extension
sva_pywrap
# Target the stable ABI for Python 3.12+, which reduces the number of binary
# wheels that must be built. This does nothing on older Python versions
STABLE_ABI
# Build libnanobind statically and merge it into the extension (which itself
# remains a shared library)
#
# If your project builds multiple extensions, you can replace this flag by
# NB_SHARED to conserve space by reusing a shared libnanobind across libraries
NB_STATIC
LTO
NB_SUPPRESS_WARNINGS
# Source code goes here
src/sva_module/sva_module.cpp
src/sva_module/bind_PTransformd.cpp
src/sva_module/bind_ForceVecd.cpp
src/sva_module/bind_MotionVecd.cpp)
jrl_check_python_module_name(sva_pywrap)
target_link_libraries(sva_pywrap PRIVATE SpaceVecAlg)
target_include_directories(
sva_pywrap PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
jrl_target_set_default_compile_options(sva_pywrap PRIVATE)
jrl_target_set_output_directory(sva_pywrap OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/lib/site-packages/sva)

jrl_python_generate_init_py(
sva_pywrap OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/site-packages/sva/__init__.py)

# Display output of stub generation
set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT)

nanobind_add_stub(
sva_pywrap_stub
MODULE
sva.sva_pywrap
OUTPUT
${CMAKE_BINARY_DIR}/lib/site-packages/test_project/test_project_pywrap.pyi
PYTHON_PATH
${CMAKE_BINARY_DIR}/lib/site-packages
# MARKER_FILE ${CMAKE_BINARY_DIR}/lib/site-packages/sva/py.typed
DEPENDS
sva_pywrap
VERBOSE)

jrl_python_compile_all(DIRECTORY ${CMAKE_BINARY_DIR}/lib/site-packages/sva
VERBOSE)

jrl_python_compute_install_dir(python_install_dir)
install(
DIRECTORY ${CMAKE_BINARY_DIR}/lib/site-packages/sva
DESTINATION ${python_install_dir}
FILES_MATCHING
PATTERN "*.py"
PATTERN "*.pyc"
PATTERN "*.pyi"
PATTERN "*.typed"
PATTERN "*.so"
PATTERN "*.pyd")
5 changes: 5 additions & 0 deletions binding/nanobind/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# nanobind python bindings for mc_rtc

## Build

See https://nanobind.readthedocs.io/en/latest/packaging.html for details
20 changes: 20 additions & 0 deletions binding/nanobind/docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions binding/nanobind/docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
46 changes: 46 additions & 0 deletions binding/nanobind/docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "SpaceVecAlg"
copyright = "2025, CNRS-AIST JRL, LIRMM"
author = "CNRS-AIST JRL, LIRMM"
release = "2.12.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ["autoapi.extension"]

templates_path = ["_templates"]
exclude_patterns = []

autoapi_dirs = [
"/home/vscode/workspace/python-venv/lib/python3.12/site-packages/sva"
]
autoapi_file_patterns = ["*.pyi", "*.py"]
autoapi_python_class_content = "both"


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

# html_theme = 'alabaster'

html_theme = "sphinx_book_theme"
html_theme_options = {
"repository_url": "https://github.com/jrl-umi3218/SpaceVecAlg",
"use_repository_button": True,
"use_download_button": False,
}
html_title = ""
# html_logo = "_static/images/mc_rtc_logo.png"


html_static_path = ["_static"]

autodoc_typehints = "description"
14 changes: 14 additions & 0 deletions binding/nanobind/docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SpaceVecAlg python bindings documentation
=========================================

Add your content using ``reStructuredText`` syntax. See the
`reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
documentation for details.


.. toctree::
:maxdepth: 2
:caption: Contents:

introduction
.. API is auto-generated from mc_rtc python module with api-autodoc
2 changes: 2 additions & 0 deletions binding/nanobind/docs/source/introduction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Introduction
============
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once
#include <nanobind/nanobind.h>

namespace mc_rtc_python
{
void bind_mc_rbdyn_module(nanobind::module_ & m);
void bind_RobotModule(nanobind::module_ & m);
} // namespace mc_rtc_python
7 changes: 7 additions & 0 deletions binding/nanobind/include/mc_rtc_python/mc_rtc_module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once
#include <nanobind/nanobind.h>

namespace mc_rtc_python
{
void bind_configuration(nanobind::module_ & m);
}
Loading
Loading