Skip to content

Commit 31d4b48

Browse files
authored
feat: more flexible ik for 5 dof so101 (#230)
* style: update rl stub files * feat: added more flexible ik for 5 dof so101
1 parent 40f8d4a commit 31d4b48

File tree

17 files changed

+543
-8
lines changed

17 files changed

+543
-8
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from __future__ import annotations
2+
3+
from rcs_robotics_library._core import rl
4+
5+
from . import _core
6+
7+
__all__: list = ["rl"]

extensions/rcs_robotics_library/src/rcs_robotics_library/_core/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# ATTENTION: auto generated from C++ code, use `make stubgen` to update!
21
"""
32
43
Robot Control Stack Python Bindings
@@ -11,9 +10,10 @@
1110
1211
1312
"""
13+
1414
from __future__ import annotations
1515

1616
from . import rl
1717

18-
__all__ = ["rl"]
18+
__all__: list[str] = ["rl"]
1919
__version__: str = "0.5.2"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# ATTENTION: auto generated from C++ code, use `make stubgen` to update!
21
"""
32
rcs robotics library module
43
"""
4+
55
from __future__ import annotations
66

77
import rcs._core.common
88

9-
__all__ = ["RoboticsLibraryIK"]
9+
__all__: list[str] = ["RoboticsLibraryIK"]
1010

1111
class RoboticsLibraryIK(rcs._core.common.Kinematics):
1212
def __init__(self, urdf_path: str, max_duration_ms: int = 300) -> None: ...
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
cmake_minimum_required(VERSION 3.19)
2+
3+
project(
4+
rcs_so101
5+
LANGUAGES C CXX
6+
VERSION 0.5.2
7+
DESCRIPTION "RCS so101 ik"
8+
)
9+
10+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
11+
12+
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) # Allow us to set options for subprojects
13+
14+
cmake_policy(SET CMP0048 NEW) # Set version in project
15+
# Allow target properties affecting visibility during linking in static libraries
16+
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
17+
cmake_policy(SET CMP0072 NEW) # Use GLVND instead of legacy libGL.so
18+
cmake_policy(SET CMP0135 NEW) # Use timestamp of file extraction not download
19+
cmake_policy(SET CMP0140 NEW) # Check return arguments
20+
21+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
22+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
23+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
24+
25+
set(CMAKE_CXX_STANDARD 20)
26+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
27+
set(CMAKE_CXX_EXTENSIONS OFF)
28+
29+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
30+
31+
set(BUILD_SHARED_LIBS OFF)
32+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
33+
34+
set(RL_BUILD_DEMOS OFF)
35+
set(RL_BUILD_RL_SG OFF)
36+
set(RL_BUILD_TESTS OFF)
37+
set(RL_BUILD_EXTRAS OFF)
38+
set(BUILD_PYTHON_INTERFACE OFF)
39+
set(BUILD_DOCUMENTATION OFF)
40+
41+
include(FetchContent)
42+
43+
find_package(Eigen3 REQUIRED)
44+
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
45+
find_package(pinocchio REQUIRED)
46+
find_package(rcs REQUIRED)
47+
48+
FetchContent_Declare(pybind11
49+
GIT_REPOSITORY https://github.com/pybind/pybind11.git
50+
GIT_TAG v2.13.4
51+
GIT_PROGRESS TRUE
52+
EXCLUDE_FROM_ALL
53+
)
54+
FetchContent_MakeAvailable(pybind11)
55+
56+
add_subdirectory(src)

extensions/rcs_so101/Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
PYSRC = src
2+
CPPSRC = src
3+
COMPILE_MODE = Release
4+
5+
# CPP
6+
cppcheckformat:
7+
clang-format --dry-run -Werror -i $(shell find ${CPPSRC} -name '*.cpp' -o -name '*.cc' -o -name '*.h')
8+
9+
cppformat:
10+
clang-format -Werror -i $(shell find ${CPPSRC} -name '*.cpp' -o -name '*.cc' -o -name '*.h')
11+
12+
cpplint:
13+
clang-tidy -p=build --warnings-as-errors='*' $(shell find ${CPPSRC} -name '*.cpp' -o -name '*.cc' -name '*.h')
14+
15+
# import errors
16+
# clang-tidy -p=build --warnings-as-errors='*' $(shell find extensions/rcs_fr3/src -name '*.cpp' -o -name '*.cc' -name '*.h')
17+
18+
gcccompile:
19+
pip install --upgrade --requirement requirements_dev.txt
20+
cmake -DCMAKE_BUILD_TYPE=${COMPILE_MODE} -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -B build -G Ninja
21+
cmake --build build --target _core
22+
23+
clangcompile:
24+
pip install --upgrade --requirement requirements_dev.txt
25+
cmake -DCMAKE_BUILD_TYPE=${COMPILE_MODE} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -B build -G Ninja
26+
cmake --build build --target _core
27+
28+
# Auto generation of CPP binding stub files
29+
stubgen:
30+
pybind11-stubgen -o src --numpy-array-use-type-var rcs_so101
31+
find ./src -name '*.pyi' -print | xargs sed -i '1s/^/# ATTENTION: auto generated from C++ code, use `make stubgen` to update!\n/'
32+
find ./src -not -path "./src/rcs_so101/_core/*" -name '*.pyi' -delete
33+
find ./src/rcs_so101/_core -name '*.pyi' -print | xargs sed -i 's/tuple\[typing\.Literal\[\([0-9]\+\)\], typing\.Literal\[1\]\]/tuple\[typing\.Literal[\1]\]/g'
34+
find ./src/rcs_so101/_core -name '*.pyi' -print | xargs sed -i 's/tuple\[\([M|N]\), typing\.Literal\[1\]\]/tuple\[\1\]/g'
35+
ruff check --fix src/rcs_so101/_core
36+
isort src/rcs_so101/_core
37+
black src/rcs_so101/_core
38+
39+
40+
41+
.PHONY: cppcheckformat cppformat cpplint gcccompile clangcompile stubgen
File renamed without changes.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
if (NOT pinocchio_FOUND)
2+
if (NOT Python3_FOUND)
3+
set(pinocchio_FOUND FALSE)
4+
if (pinocchio_FIND_REQUIRED)
5+
message(FATAL_ERROR "Could not find pinocchio. Please install pinocchio using pip.")
6+
endif()
7+
return()
8+
endif()
9+
10+
# Check if the include directory exists
11+
cmake_path(APPEND Python3_SITELIB cmeel.prefix include OUTPUT_VARIABLE pinocchio_INCLUDE_DIRS)
12+
if (NOT EXISTS ${pinocchio_INCLUDE_DIRS})
13+
set(pinocchio_FOUND FALSE)
14+
if (pinocchio_FIND_REQUIRED)
15+
message(FATAL_ERROR "Could not find pinocchio. Please install pinocchio using pip.")
16+
endif()
17+
return()
18+
endif()
19+
20+
# Check if the library file exists
21+
cmake_path(APPEND Python3_SITELIB cmeel.prefix lib libpinocchio_default.so OUTPUT_VARIABLE pinocchio_library_path)
22+
if (NOT EXISTS ${pinocchio_library_path})
23+
set(pinocchio_FOUND FALSE)
24+
if (pinocchio_FIND_REQUIRED)
25+
message(FATAL_ERROR "Could not find pinocchio. Please install pinocchio using pip.")
26+
endif()
27+
return()
28+
endif()
29+
30+
# Check if the library file exists
31+
cmake_path(APPEND Python3_SITELIB cmeel.prefix lib libpinocchio_parsers.so OUTPUT_VARIABLE pinocchio_parsers_path)
32+
if (NOT EXISTS ${pinocchio_parsers_path})
33+
set(pinocchio_FOUND FALSE)
34+
if (pinocchio_FIND_REQUIRED)
35+
message(FATAL_ERROR "Could not find pinocchio parsers path. Please install pinocchio using pip.")
36+
endif()
37+
return()
38+
endif()
39+
40+
# Extract version from the library filename
41+
file(GLOB pinocchio_dist_info "${Python3_SITELIB}/pin-*.dist-info")
42+
cmake_path(GET pinocchio_dist_info FILENAME pinocchio_library_filename)
43+
string(REPLACE "pin-" "" pinocchio_VERSION "${pinocchio_library_filename}")
44+
string(REPLACE ".dist-info" "" pinocchio_VERSION "${pinocchio_VERSION}")
45+
46+
# Create the imported target
47+
add_library(pinocchio::pinocchio SHARED IMPORTED)
48+
target_include_directories(pinocchio::pinocchio INTERFACE ${pinocchio_INCLUDE_DIRS})
49+
set_target_properties(pinocchio::pinocchio
50+
PROPERTIES
51+
IMPORTED_LOCATION "${pinocchio_library_path}"
52+
)
53+
54+
add_library(pinocchio::parsers SHARED IMPORTED)
55+
target_include_directories(pinocchio::parsers INTERFACE ${pinocchio_INCLUDE_DIRS})
56+
set_target_properties(pinocchio::parsers
57+
PROPERTIES
58+
IMPORTED_LOCATION "${pinocchio_parsers_path}"
59+
)
60+
61+
add_library(pinocchio::all INTERFACE IMPORTED)
62+
set_target_properties(pinocchio::all
63+
PROPERTIES
64+
INTERFACE_LINK_LIBRARIES "pinocchio::pinocchio;pinocchio::parsers"
65+
)
66+
set(pinocchio_FOUND TRUE)
67+
68+
endif()
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
if (NOT rcs_FOUND)
2+
if (NOT Python3_FOUND)
3+
set(rcs_FOUND FALSE)
4+
if (rcs_FIND_REQUIRED)
5+
message(FATAL_ERROR "Could not find rcs. Please install rcs using pip.")
6+
endif()
7+
return()
8+
endif()
9+
10+
# Check if the include directory exists
11+
cmake_path(APPEND Python3_SITELIB rcs include OUTPUT_VARIABLE rcs_INCLUDE_DIRS)
12+
if (NOT EXISTS ${rcs_INCLUDE_DIRS})
13+
set(rcs_FOUND FALSE)
14+
if (rcs_FIND_REQUIRED)
15+
message(FATAL_ERROR "Could not find rcs. Please install rcs using pip.")
16+
endif()
17+
return()
18+
endif()
19+
20+
# Check if the library file exists
21+
cmake_path(APPEND Python3_SITELIB rcs OUTPUT_VARIABLE rcs_library_path)
22+
file(GLOB rcs_library_path "${rcs_library_path}/librcs.so")
23+
if (NOT EXISTS ${rcs_library_path})
24+
set(rcs_FOUND FALSE)
25+
if (rcs_FIND_REQUIRED)
26+
message(FATAL_ERROR "Could not find rcs. Please install rcs using pip.")
27+
endif()
28+
return()
29+
endif()
30+
31+
# Extract version from the library filename
32+
# file(GLOB rcs_dist_info "${Python3_SITELIB}/rcs-*.dist-info")
33+
# cmake_path(GET rcs_dist_info FILENAME rcs_library_filename)
34+
# string(REPLACE "rcs-" "" rcs_VERSION "${rcs_library_filename}")
35+
# string(REPLACE ".dist-info" "" rcs_VERSION "${rcs_VERSION}")
36+
37+
# Create the imported target
38+
add_library(rcs SHARED IMPORTED)
39+
target_include_directories(rcs INTERFACE ${rcs_INCLUDE_DIRS})
40+
set_target_properties(
41+
rcs
42+
PROPERTIES
43+
IMPORTED_LOCATION "${rcs_library_path}"
44+
)
45+
set(rcs_FOUND TRUE)
46+
endif()

extensions/rcs_so101/pyproject.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["setuptools"]
3-
build-backend = "setuptools.build_meta"
2+
requires = []
3+
build-backend = "scikit_build_core.build"
44

55
[project]
66
name = "rcs_so101"
@@ -19,4 +19,12 @@ authors = [
1919
{ name = "Pierre Krack", email = "pierre.krack@utn.de" },
2020
]
2121
requires-python = ">=3.10"
22-
license = "AGPL-3.0-or-later"
22+
license = "AGPL-3.0-or-later"
23+
24+
[tool.scikit-build]
25+
build.verbose = true
26+
build.targets = ["_core"]
27+
logging.level = "INFO"
28+
build-dir = "build"
29+
wheel.packages = ["src/rcs_so101"]
30+
install.components = ["python_package"]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target_include_directories(rcs INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
2+
add_subdirectory(pybind)

0 commit comments

Comments
 (0)