Giter VIP home page Giter VIP logo

pyikfast's Introduction

Python Bindings for ikfast

Generate a Python ikfast library from the given URDF file. This project provides all necessary utilities to generate ikpy C++ files and Python bindings for it.

Getting Started

Export URDF from Webots:
Export URDF menu

(right click on the robot in scene tree) > Export > (name it `robot.urdf`) > Save

Move to the directory with robot.urdf and execute:

docker run -v ${PWD}:/output cyberbotics/pyikfast [base_link] [effector] [module_extension]

Replace [base_link] and [effector] with the link-names from the robot.urdf. The [module_extension] will append to the generated Python module name. The module name will be pyikfast + [module_extension]. For example, _irb4600 will generate the Python module named pyikfast_irb4600.

After a few minutes your Python library should be ready ready! Install it as:

pip3 install .

Use the library:

import pyikfast


target_translation = [0.5, 0.5, 0.5]
target_rotation = [1, 0, 0, 0, 1, 0, 0, 0, 1]

# Calculate inverse kinematics
positions = pyikfast.inverse(target_translation, target_rotation)
print(positions)

# Calculate forward kinematics (we use the third IK solution)
translation, rotation = pyikfast.forward(positions[2])
print(translation, rotation)

Distribution

To distribute the generated Python library you can make a Python *.whl file:

pip3 install setuptools wheel
python3 setup.py bdist_wheel

and your *.whl will be located in ./dist/pyikfast-*.whl, so a user can install it as:

pip3 install pyikfast-*.whl

Development

If you are interested into the library development here are a few notes:

# Building using Docker
docker build . --tag pyikfast
docker run -it -v ${PWD}/output:/output --entrypoint bash pyikfast
/entrypoint.bash base_link solid_12208 _ext

# Compile standalone
g++ $(find -name '*.cpp') -o ikfast
./ikfast 1 0 0 0.5 0 1 0 0.5 0 0 1 0.5

# Python
python3 -c "import pyikfast; print(pyikfast.inverse([0.5, 0.5, 0.5], [1, 0, 0, 0, 1, 0, 0, 0, 1]))"
python3 -c "import pyikfast; print(pyikfast.forward([0.927295218001612, -2.899331265288886, 2.048719302774242, -1.057447868999410, 1.163951188044116, 0.612010251709654]))"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.