Skip to main content

Differentiable Forward Kinematics for TensorFlow and Keras based on URDF files

Project description

dlkinematics

Deep Learning Kinematics

Differentiable Forwad Kinematics for TensorFlow and Keras

Supported Joint Types:

  • Fixed
  • Revolute
  • Continious
  • Prismatic
  • Floating (not coverd by unit tests)
  • Planar (not coverd by unit tests)

Installation

Install from source

$ pip3 install -e git+https://github.com/lumoe/dlkinematics.git@main#egg=DLKinematics

Install from PyPi

Coming soon

Usage:

import tensorflow as tf
from dlkinematics.urdf import chain_from_urdf_file
from dlkinematics.dlkinematics import DLKinematics

# Load URDF
chain = chain_from_urdf_file('data/human.urdf')

# Create DLKinematics
dlkinematics = DLKinematics(
   chain,
   base_link="human_base",
   end_link="human_spine_2",
   batch_size=2)

# Joint configuartion
thetas = tf.Variable([1., 2., 3., 4.], dtype=tf.float32)

# Forward pass
with tf.GradientTape() as tape:
    result = dlkinematics.forward(thetas)

print(result)
print(tape.gradient(result, thetas))

As Keras Layer

from dlkinematics.training_utils import ForwardKinematics
from tensorflow import keras
import tensorflow as tf

model = keras.Sequential()

FK_layer = ForwardKinematics(
   urdf_file = 'path/to/urdf',
   base_link = 'link0',
   end_link = 'linkN',
   batch_size = 2)

model.add(FK_layer)
# Output shape of FK_layer is (batch_size, 4, 4)

Run tests

The tests use ROS packages to validate the result of the dlkinematics module.

  1. Build the docker image for tests:
    $ docker build -t dlkinematics_tests .

  2. Start the container in the root folder of the project:
    $ docker run -it -v $PWD:/work dlkinematics_tests python3 -m pytest

  3. Execute all tests:
    $ docker run -it -v $PWD:/work dlkinematics_tests python3 -m pytest
    Execute only a single testfile:
    $ docker run -it -v $PWD:/work dlkinematics_tests python3 -m pytest tests/test_prismatic.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dlkinematics-0.1.0rc3.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

dlkinematics-0.1.0rc3-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file dlkinematics-0.1.0rc3.tar.gz.

File metadata

  • Download URL: dlkinematics-0.1.0rc3.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.8.10 Linux/5.8.13-050813-generic

File hashes

Hashes for dlkinematics-0.1.0rc3.tar.gz
Algorithm Hash digest
SHA256 ad82d97f9fef2f3a4455b151b9a2c7eb0a291d6a521cd7bf61c6a61c82a9eafc
MD5 3162cca54b567d1038b069f24f1bd6b6
BLAKE2b-256 e0872cd72c5f5dfb93b6dca8da1499a1bdd38475cc28a4a8f62be65c1e1d6ad8

See more details on using hashes here.

File details

Details for the file dlkinematics-0.1.0rc3-py3-none-any.whl.

File metadata

  • Download URL: dlkinematics-0.1.0rc3-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.8.10 Linux/5.8.13-050813-generic

File hashes

Hashes for dlkinematics-0.1.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 18651997363a3eadcdec439fa5ce0606fd119a9542fef134c0e09ebe69c70eb9
MD5 8f55fc46ae9a0eb62f37060289ecd266
BLAKE2b-256 f8bfa764e3544b5e5f5a37339a631988bc385f6aaf86cd72a355337a2bfe59df

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page