Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,3 @@ TabWidth: 8
UseCRLF: false
UseTab: Never
...

39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-symlinks
- id: destroyed-symlinks
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-ast
- id: check-added-large-files
args: ["--maxkb=2000"]
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: detect-private-key
- id: debug-statements
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
args:
- --skip=*.ipynb
- -L ths
- repo: https://github.com/python/black
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.4.10'
hooks:
- id: ruff
args:
- --fix
- --unsafe-fixes
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PyTorch Robot Kinematics
- Parallel and differentiable forward kinematics (FK), Jacobian calculation, and damped least squares inverse kinematics (IK)
- Load robot description from URDF, SDF, and MJCF formats
- Load robot description from URDF, SDF, and MJCF formats
- SDF queries batched across configurations and points via [pytorch-volumetric](https://github.com/UM-ARM-Lab/pytorch_volumetric)

# Installation
Expand Down Expand Up @@ -183,7 +183,7 @@ ret = chain.forward_kinematics(th)
## Jacobian calculation
The Jacobian (in the kinematics context) is a matrix describing how the end effector changes with respect to joint value changes
(where ![dx](https://latex.codecogs.com/png.latex?%5Cinline%20%5Cdot%7Bx%7D) is the twist, or stacked velocity and angular velocity):
![jacobian](https://latex.codecogs.com/png.latex?%5Cinline%20%5Cdot%7Bx%7D%3DJ%5Cdot%7Bq%7D)
![jacobian](https://latex.codecogs.com/png.latex?%5Cinline%20%5Cdot%7Bx%7D%3DJ%5Cdot%7Bq%7D)

For `SerialChain` we provide a differentiable and parallelizable method for computing the Jacobian with respect to the base frame.
```python
Expand Down Expand Up @@ -223,7 +223,7 @@ The Jacobian can be used to do inverse kinematics. See [IK survey](https://www.m
for a survey of ways to do so. Note that IK may be better performed through other means (but doing it through the Jacobian can give an end-to-end differentiable method).

## Inverse Kinematics (IK)
Inverse kinematics is available via damped least squares (iterative steps with Jacobian pseudo-inverse damped to avoid oscillation near singularlities).
Inverse kinematics is available via damped least squares (iterative steps with Jacobian pseudo-inverse damped to avoid oscillation near singularlities).
Compared to other IK libraries, these are the typical advantages over them:
- not ROS dependent (many IK libraries need the robot description on the ROS parameter server)
- batched in both goal specification and retries from different starting configurations
Expand Down
74 changes: 74 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,77 @@ test = [
# They will be installed as dependencies during the build, which can take a while the first time.
requires = ["setuptools>=60.0.0", "wheel"]
build-backend= "setuptools.build_meta"


[tool.ruff]
src = ["src", "tests",]
show-fixes = true
# Same as Black.
line-length = 127
# Assume Python 3.8.
target-version = "py38"

[tool.ruff.lint]
extend-select = ["C4", "SIM", "TCH"]

ignore = [
"A001", "A002",
"ARG001", "ARG002",
"B007", "B008", "B019", "B023", "B028", "B904", "B026",
"E501", "ERA001", "E741", "E722",
"FBT001", "FBT002", "FBT003",
"N802", "N803", "N806", "N812",
"PGH003", "PGH004", "PLR2004",
"S101", "S202", "S301", "S310", "S311", "S320",
"UP006",
"T201", "T203"
]

select = [
"A",
"ARG",
"B",
"C4",
"C90",
"E",
"ERA",
"F",
"FBT",
"ICN",
"I",
"ISC",
"N",
"NPY",
"PD",
"PGH",
"PIE",
"PLE",
"PLR",
"Q",
"RUF",
"S",
"SIM",
"T",
"UP",
"W",
]

[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 30

[tool.ruff.lint.isort]
lines-after-imports = 2
extra-standard-library = ["typing_extensions"]

[tool.ruff.lint.pylint]
max-statements = 100
max-branches=25
max-args=20

[tool.ruff.lint.per-file-ignores]
"tests/*.py" = ["PLR2004", "N802", "N801", "SIM115", "E501", "ERA001"]


[tool.black]
line-length = 127
7 changes: 4 additions & 3 deletions src/pytorch_kinematics/cfg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path

ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))
TEST_DIR = os.path.join(ROOT_DIR, 'tests')

ROOT_DIR = Path(__file__).resolve().parent.parent.parent
TEST_DIR = ROOT_DIR / "tests"
Loading