An optimizing IK solver based on the Lie group of rigid transforms SE(3)
Project description
OptIK
A fast inverse kinematics solver for arbitrary serial chains providing Rust, C++, and Python programming interfaces.
The implementation is similar to TRAC-IK [1] in that a nonlinear optimization problem is formulated and minimized. However, this work differs in a couple of ways:
- The gradient of the objective function is computed analytically. This is an immediate performance improvement over finite difference approaches, because it requires only one evaluation of the forward kinematics per gradient evaluation.
- Random restarting of the nonlinear solver is implemented in a work stealing parallel fashion, so that overall solve time is decreased thanks to the improved chance of finding a good seed.
- Random number generator seeds are carefully controlled in a way that produces deterministic results. (Note that this is only true in single-threaded mode, for now.)
- A parallel Newton's method solver is not included, because the performance of the full nonlinear problem is quite good on its own.
Benchmark [^1]
We compare to TRAC-IK (via tracikpy) by drawing a random valid joint configuration, mapping into Cartesian space with forward kinematics, and then asking each solver to generate an inverse kinematics solution using a random initial guess.
Note that this methodology differs from the original TRAC-IK benchmark which solves for configurations along a dense trajectory, meaning seeds are always relatively close. The benchmark shown below is more similar to a motion planning workload, in which samples are randomly drawn from a space with little knowledge of a nearby seed.
Timing is of a single inverse kinematics solve.
Additionally, we use the ik_benchmarking project (credit to PickNik Robotics) to compare against various solvers for the Franka Emika Panda robot using the MoveIt interfaces for each solver. OptIK is configured to return solutions with roughly equal tolerance to its closest competitor, TRAC-IK.
Timing is of a single inverse kinematics solve. Note the semi-log axes.
[^1]: as of https://github.com/kylc/optik/commit/3f324560b1a6ca5cfba2671e0180dd457ea1a28e
Setup
Python
python3 -m pip install optik-py
Or, to install a prerelease version:
- Download a recent
.whl
from GitHub Releases - Run
pip install optik-py<...>.whl
(replace<...>
with the actual filename) - Test it:
python -c 'import optik'
C++ (CMake)
Include OptIK in your CMake project using FetchContent
:
include(FetchContent)
FetchContent_Declare(
optik
GIT_REPOSITORY https://github.com/kylc/optik
GIT_TAG master
SOURCE_SUBDIR "crates/optik-cpp")
FetchContent_MakeAvailable(optik)
target_link_libraries(mylib PRIVATE optik::optik)
Building Locally
git clone git@github.com:kylc/optik.git
# Build the Rust library
cargo build --release
# Build a Python wheel
maturin build --release -m crates/optik-py/Cargo.toml
# Build the C++ example
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ../examples
cmake --build .
Application Notes
-
For workloads in which the distance between the solution and the seed are not important, you can use a high degree of parallelism (OptIK defaults to the number of CPU cores) to more quickly converge on a solution via parallel random restarting.
-
For workloads such as Cartesian interpolation, it is important to find the solution closest to the seed to avoid joint-space discontinuities. While OptIK does not explicitly try to minimize this distance, the optimizer does generally converge to the nearest solution (subject to joint limits). Prefer using
SolutionMode::Quality
with parallelism to sample many solutions and choose the one nearest the seed. -
For workloads in which determinism is important, consider using
SolutionMode::Quality
, settings amax_restarts
value, and disabling themax_time
. This ensures that the solution is not dependent on CPU processing speed. Due to careful seeding of RNGs inside the solver, solutions should be fully deterministic. Alternatively, useSolutionMode::Speed
and set the parallel threads to1
.
References
P. Beeson and B. Ames, “TRAC-IK: An open-source library for improved solving of generic inverse kinematics,” in 2015 IEEE-RAS 15th International Conference on Humanoid Robots (Humanoids), Seoul, South Korea: IEEE, Nov. 2015, pp. 928–935. doi: 10.1109/HUMANOIDS.2015.7363472.
J. Solà, J. Deray, and D. Atchuthan, “A micro Lie theory for state estimation in robotics.” arXiv, Dec. 08, 2021. Accessed: Jul. 24, 2023. [Online]. Available: http://arxiv.org/abs/1812.01537
Steven G. Johnson, The NLopt nonlinear-optimization package, http://github.com/stevengj/nlopt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file optik_py-0.4.1.tar.gz
.
File metadata
- Download URL: optik_py-0.4.1.tar.gz
- Upload date:
- Size: 38.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f23f4fd2773db6f32044dedfce39cfb91a68d9f94b335d9bb0d7c9326c6abcfb |
|
MD5 | a1209c8f88688afb93eccbeeb7ad480b |
|
BLAKE2b-256 | 6a9105e29295d7d6573e304de9c2cde7dd2ab3b85ad508f8de1947516b79995e |
File details
Details for the file optik_py-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: optik_py-0.4.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e921de73787ee63a499f49717121dfb92f7def898df0874992d42e465915939e |
|
MD5 | d7ac1da599706df2f9865e10fabe7619 |
|
BLAKE2b-256 | aad5e88cfa8ea15dc168dd827b3bafe5aae21cd3e9e66ac2053584be12d18081 |
File details
Details for the file optik_py-0.4.1-cp38-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: optik_py-0.4.1-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 651.2 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49f11a232d0dab9fe032999a43163222717fab92113fe2f257c2bc3e86956df1 |
|
MD5 | bbc205348963ce3b3094dba70435947f |
|
BLAKE2b-256 | c7549d1cebd191ebc4c877e781bb4e3bb9bab143ad79dfdb44026141aae32297 |
File details
Details for the file optik_py-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: optik_py-0.4.1-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 741.9 kB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58a71837d26e2ef63a65a554b64ef077041607c12ae04b19527eca83878926db |
|
MD5 | 8aeb93301a6074ef124e63c83181e78d |
|
BLAKE2b-256 | 41636daaa06ac4135d45927cbbb1c33c5a11c71991ce000b1bbd9b6a49c971f6 |