Welcome to pytracik, a Python library that provides convenient and efficient bindings for the Trac-IK inverse kinematics solver. With support for Python 3.8+ and compatibility across both Windows and Linux environments. pytracik eliminates the need for ROS installation and simplifies the integration process.
✨ Differences from Original Repo:
- 🚀 ROS-Free Integration: Say goodbye to the ROS requirement. pytracik allows you to effortlessly incorporate Trac-IK's advanced inverse kinematics solver into your Python projects. However, it still depends on the
boost,eigen,orocos-kdlandnloptlibraries. - 💻 Cross-Platform Compatibility: Whether you're on Windows or Linux, pytracik ensures consistent functionality across environments.
- Trac-IK Repository: https://bitbucket.org/traclabs/trac_ik/src/master/
- Trac-IK Homepage: https://traclabs.com/projects/trac-ik/
- Other ROS-free Trac-IK Python Bindings: https://github.com/mjd3/tracikpy
import os
import numpy as np
from trac_ik import TracIK
urdf_path = os.path.join(os.path.dirname(__file__), "urdf/yumi.urdf")
yumi_rgt_arm_iksolver = TracIK(base_link_name="yumi_body",
tip_link_name="yumi_link_7_r",
urdf_path=urdf_path, )
yumi_lft_arm_iksolver = TracIK(base_link_name="yumi_body",
tip_link_name="yumi_link_7_l",
urdf_path=urdf_path, )
seed_jnt = np.array([-0.34906585, -1.57079633, -2.0943951, 0.52359878, 0.,
0.6981317, 0.])
tgt_pos = np.array([.3, -.4, .1])
tgt_rotmat = np.array([[0.5, 0., 0.8660254],
[0., 1., 0.],
[-0.8660254, 0., 0.5]])
result = yumi_rgt_arm_iksolver.ik(tgt_pos, tgt_rotmat, seed_jnt_values=seed_jnt)
print(result)Output:
[ 1.17331584 -1.99621953 -1.08811406 -0.18234367 0.66571608 1.26591
0.18141696]- Download this library and enter the project directory
git clone https://github.com/chenhaox/pytracik.git
cd pytracik- Install required Python packages
pip install -r requirements.txtHere we use Ubuntu 22.04 as an example.
- Install dependencies: 1. Boost 2. Eigen3 3. Orocos KDL 4. NLopt
sudo apt install libboost-all-dev libeigen3-dev liborocos-kdl-dev libnlopt-dev libnlopt-cxx-dev
- Install the package on Linux
python setup_linux.py install
Download dependencies from Official Websites
- Download Boost 1.79.0 (https://www.boost.org/)
- Eigen3 3.4.0 (https://eigen.tuxfamily.org/index.php?title=Main_Page)
- NLopt (https://nlopt.readthedocs.io/en/latest/)
- Orocos KDL (https://orocos.github.io/orocos_kinematics_dynamics/installation.html)
👉 Shortcut: Instead of downloading them individually, you can grab a pre-packaged zip with all dependencies from the project’s GitHub release:
📥 https://github.com/chenhaox/pytracik/releases/tag/dependency_files
Copy the downloaded dependency zip file and unzip it to project root directory. Then run the following command in the project root directory:
python setup_windows.py install-
Download Visual Studio (https://visualstudio.microsoft.com/downloads/). Here we use Visual Studio 2022 as an example. Install required components:
- Desktop development with C++
- C++ CMake tools for Windows
-
Compile pytracik with Visual Studio following the instructions below. a. Create an C++
Empty projectin Visual Studio.b. Add the source files in
srcfolder to the project.c. Right click the project and select
Properties.- Set the
ConfigurationtoReleaseandPlatformtoActive (x64) - In the
Configuration Properites/Generaltab, set theTarget Nametopytracik_bindings. - Set the
Configuration TypetoDynamic Library (.dll). - Set C++ language standard to
ISO C++17 Standard (/std:c++17).
d. In the
Configuration Properites/Advancedtab, setTaget File Extensionto.pyd.
e. In the
C/C++tab, add the include directories of 1. Boost, 2. Eigen3, 3. NLopt and 4. Orocos KDL 5. Python and 6. Pybind11 toAdditional Include Directories.f. In the
Linker/Generaltab, add the library directories of 1. Boost, 2. NLopt 3. Orocos KDL and 4. Python toAdditional Library Directories.g. In the
Linker/Inputtab, add the library names of 1. Boost, 2. NLopt 3. Orocos KDL and 4. Python toAdditional Dependencies.h. Set the
Solution ConfigurationtoReleaseandSolution Platformtox64. Then build the project. Thepytracik_bindings.pydfile will be generated in theReleasefolder.
- Set the
-
Copy the
pytracik_bindings.pydfile to the pytracik folder. Note: if the errorImportError: DLL load failed while importing pytracik: The specified module could not be found.occurs, please copy thenlopt.dllin the<NLopt installation path\bin>to the pytracik folder: -
Make installation (Optional):
pip install -e .





