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: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Some unofficial versions in other languages are being developed:
* [C++ version](https://github.com/Le0nX/ModernRoboticsCpp)
* [Julia version](https://github.com/ferrolho/ModernRoboticsBook.jl)
* [Nim version](https://github.com/Nimbotics/ModernRoboticsNim)
* [PyTorch version](https://github.com/Agaggar/PyTorch_MR) in `packages/PyTorch`, installable as `pip install -e packages/PyTorch` and used as `import pytorch_mr as pmr`

Some libraries built on ours:
* [KinematicsFromDescriptionTool](https://github.com/Interbotix/kinematics_from_description), which calculates the kinematics input parameters from a robot's URDF or robot_description parameter using ROS and Python3.
Expand Down
8 changes: 8 additions & 0 deletions packages/PyTorch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dist/
build/
*.egg-info/
.eggs/
.pytest_cache/
__pycache__/
*.pyc
src/*.egg-info/
21 changes: 21 additions & 0 deletions packages/PyTorch/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Northwestern University CRB

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 58 additions & 0 deletions packages/PyTorch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# PyTorch Modern Robotics (`pytorch_mr`)

PyTorch implementation of the routines from *Modern Robotics: Mechanics, Planning, and Control*, aligned with the NumPy `modern_robotics` reference in `packages/Python`.

## Install (global)
```bash
pip install pytorch-mr
```

## Install (local / editable)

From this directory (`packages/PyTorch`):

```bash
pip install -e .
```

Dependencies are declared in `pyproject.toml` (`numpy`, `torch`).

## Import

```python
import pytorch_mr as pmr
# or
from pytorch_mr.core import MatrixExp3, FKinBody
```

## Tests (NumPy parity)

Install the reference `modern_robotics` (local tree or PyPI) and `pytest`:

```bash
pip install -e ../Python # local reference
# or
pip install modern_robotics
pip install pytest
```

From `packages/PyTorch` (uses `[tool.pytest.ini_options]` `pythonpath = ["src"]`):

```bash
cd packages/PyTorch
python -m pytest tests -q
```

From `packages/` with explicit `PYTHONPATH`:

```bash
cd packages
PYTHONPATH=PyTorch/src:Python python -m pytest PyTorch/tests -q
```

Chapter summary:

```bash
cd packages
PYTHONPATH=PyTorch/src:Python python PyTorch/tests/run_tests_by_chapter.py
```
51 changes: 51 additions & 0 deletions packages/PyTorch/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[build-system]
requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "pytorch_mr"
description = "PyTorch implementation of Modern Robotics: Mechanics, Planning, and Control"
readme = "README.md"
requires-python = ">=3.6"
license = { file = "LICENSE" }
authors = [
{ name = "Ayush Gaggar", email = "agaggar@u.northwestern.edu" }
]
keywords = ["robotics", "kinematics", "dynamics", "pytorch", "modern robotics"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Topic :: Education",
"Topic :: Scientific/Engineering",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
dependencies = [
"numpy>=1.20",
"torch>=1.10",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/Agaggar/PyTorch_MR/tree/master/packages/PyTorch"
Documentation = "http://modernrobotics.org/"
Repository = "https://github.com/Agaggar/PyTorch_MR.git"
Issues = "https://github.com/Agaggar/PyTorch_MR/issues"

[project.optional-dependencies]
dev = ["pytest>=7"]

[tool.setuptools.packages.find]
where = ["src"]

# Read version from the lightweight module only (avoid importing core.py -> torch in isolated builds).
[tool.setuptools.dynamic]
version = { attr = "pytorch_mr.__version__.__version__" }

[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["src"]
46 changes: 46 additions & 0 deletions packages/PyTorch/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from setuptools import find_packages, setup

exec(open('src/pytorch_mr/__version__.py').read())

long_description = """
# Modern Robotics (PyTorch)

PyTorch implementation of the mathematical routines from
_Modern Robotics: Mechanics, Planning, and Control_.

This package mirrors the reference NumPy `modern_robotics` library with batched tensor support.

Install the NumPy reference separately from `packages/Python` if you need parity tests or side-by-side use:
`pip install -e ../Python` (from this directory's parent) or `pip install modern_robotics`.
"""

setup(
name="pytorch_mr",
version=__version__,
author="Ayush Gaggar, Huan Weng, Mikhail Todes, Jarvis Schultz, Bill Hunt, ",
author_email="agaggar@u.northwestern.edu",
description=(
"Modern Robotics: Mechanics, Planning, and Control — PyTorch implementation"
),
license="MIT",
long_description=long_description,
long_description_content_type="text/markdown",
keywords="kinematics robotics dynamics pytorch",
url="http://modernrobotics.org/",
packages=find_packages(include=["pytorch_mr", "pytorch_mr.*"]),
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Topic :: Education",
"Topic :: Scientific/Engineering",
],
install_requires=[
"numpy",
"torch",
],
platforms="Linux, Mac, Windows",
)
3 changes: 3 additions & 0 deletions packages/PyTorch/src/pytorch_mr/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .__version__ import __version__

from .core import *
2 changes: 2 additions & 0 deletions packages/PyTorch/src/pytorch_mr/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

__version__ = '0.0.1'
Loading