Metadata-Version: 2.3
Name: screwmpcpy
Version: 0.5.1
Summary: Dual Quaternion based MPC generating screw motion for n-DOF robot arm.
Project-URL: Homepage, https://github.com/greinerth/screwmpcpy
Project-URL: Bug Tracker, https://github.com/greinerth/screwmpcpy/issues
Project-URL: Discussions, https://github.com/greinerth/screwmpcpy/discussions
Project-URL: Changelog, https://github.com/greinerth/screwmpcpy/releases
Author-email: Gerhard Reinerth <g.reinerth@tum.de>
License: Copyright 2024 Gerhard Reinerth
        
        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.
License-File: LICENSE
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering
Classifier: Typing :: Typed
Requires-Python: <3.12,>=3.8
Requires-Dist: daqp
Requires-Dist: dqrobotics==23.4.0a22
Requires-Dist: nptyping
Requires-Dist: numpy>=1.24.0
Requires-Dist: osqp
Requires-Dist: qpsolvers
Requires-Dist: roboticstoolbox-python
Requires-Dist: scipy>=1.10.0
Provides-Extra: dev
Requires-Dist: bumpver; extra == 'dev'
Requires-Dist: furo>=2023.08.17; extra == 'dev'
Requires-Dist: myst-parser>=0.13; extra == 'dev'
Requires-Dist: nox; extra == 'dev'
Requires-Dist: panda-python; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: pytest-cov>=3; extra == 'dev'
Requires-Dist: pytest-mypy; extra == 'dev'
Requires-Dist: pytest>=6; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: sphinx-autodoc-typehints; extra == 'dev'
Requires-Dist: sphinx-copybutton; extra == 'dev'
Requires-Dist: sphinx>=7.0; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Provides-Extra: docs
Requires-Dist: furo>=2023.08.17; extra == 'docs'
Requires-Dist: myst-parser>=0.13; extra == 'docs'
Requires-Dist: panda-python; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints; extra == 'docs'
Requires-Dist: sphinx-copybutton; extra == 'docs'
Requires-Dist: sphinx>=7.0; extra == 'docs'
Provides-Extra: examples
Requires-Dist: panda-python; extra == 'examples'
Provides-Extra: test
Requires-Dist: nox; extra == 'test'
Requires-Dist: pytest-cov>=3; extra == 'test'
Requires-Dist: pytest-mypy; extra == 'test'
Requires-Dist: pytest>=6; extra == 'test'
Requires-Dist: ruff; extra == 'test'
Description-Content-Type: text/markdown

<p align="center">
  <img src="logo.jpg">
</p>
<h1 align="center">screwmpcpy</h1>

[![Actions Status][actions-badge]][actions-link]
[![Documentation Status][rtd-badge]][rtd-link]
[![PyPI version][pypi-version]][pypi-link]
[![PyPI platforms][pypi-platforms]][pypi-link]
[![GitHub Discussion][github-discussions-badge]][github-discussions-link]

<!-- SPHINX-START -->

<!-- prettier-ignore-start -->
[actions-badge]:            https://github.com/greinerth/screwmpcpy/actions/workflows/python-package.yml/badge.svg
[actions-link]:             https://github.com/greinerth/screwmpcpy/actions
[github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
[github-discussions-link]:  https://github.com/greinerth/screwmpcpy/discussions
[pypi-link]:                https://pypi.org/project/screwmpcpy/
[pypi-platforms]:           https://img.shields.io/pypi/pyversions/screwmpcpy
[pypi-version]:             https://img.shields.io/pypi/v/screwmpcpy
[rtd-badge]:                https://readthedocs.org/projects/screwmpcpy/badge/?version=latest
[rtd-link]:                 https://screwmpcpy.readthedocs.io/en/latest/?badge=latest

<!-- prettier-ignore-end -->

Generate smooth motions for a n-DOF robot arm end effector using Dual
Quaternions while enforcing velocity-, acceleration- and jerk constraints. The
package includes a base optimization scheme and a base motion generator, which
can be easily extended for custom robot arms. A motion generator for the Franka
Emika Panda robot is included.

## Install

The package is available in PyPI, you can install it via pip:

```
pip install screwmpcpy
```

## Getting started

The motion generators yield velocity commands for an n-DoF robot arm. For the
basic usage have a look at `examples/motiongenerator.py`. You can also use the
dual quaternions to generate waypoints. Check it out the example for the panda
robot at `examples/panda_screwmotion_ik.py`. To install the required package
dependencies execute `pip install screwmpcpy[examples]`. You can find advanced
usage examples [here](https://github.com/JeanElsner/screwmpc-experiments). We
include two generators for the panda robot:\
The basic screw motion generator and a modified variant, which includes manipulability
maximization from [[1]](#1).

## Extending the available robots

You can easily extend the base class by adding your custom robot arm. Ensure the
forward kinematics of your robot are available.\
Create a new file `your_robot_mg.py` in folder `src/screwmpc.py`.

#### Custom robot example

```
from dqrobotics import DQ
from .basemg import BaseMotionGenerator
from .screwmpc import BOUND


class YourRobotMotionGenerator(BaseMotionGenerator):

    def __init__(
                self,
                n_p: int,
                n_c: int,
                q_mpc: float,
                r_mpc: float,
                lu_bound_vel: BOUND,
                lu_bound_acc: BOUND,
                lu_bound_jerk: BOUND,
                ) -> None:
        super().__init__(
            n_p, n_c, q_mpc, r_mpc, lu_bound_vel, lu_bound_acc, lu_bound_jerk
        )
        # custom attributes here
        self._kin = YourRobotKinematics()

    def step(self, q_robot: np.ndarray, goal: DQ) -> np.ndarray:

        # Initialize Dual Quaternion with 6D pose
        x_current = DQ(self._kin.your_forward_kinematics(q_robot))
        error, smooth_traj = super()._step(x_current, goal)
        # calculate commanded dq here
        ...
        return dq
```

## References

<a id="1">[1]</a> Haviland, J., & Corke, P. (2020). A Purely-Reactive
Manipulability-Maximising Motion Controller. ArXiv. /abs/2002.11901
