ivy-mech


Nameivy-mech JSON
Version 1.1.9 PyPI version JSON
download
home_pagehttps://ivy-dl.org/mech
SummaryMechanics functions with end-to-end support for machine learning developers, written in Ivy
upload_time2021-12-01 16:07:06
maintainer
docs_urlNone
authorIvy Team
requires_python
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. image:: https://github.com/ivy-dl/mech/blob/master/docs/partial_source/logos/logo.png?raw=true
   :width: 100%



**Mechanics functions with end-to-end support for machine learning developers, written in Ivy.**



.. image:: https://github.com/ivy-dl/ivy-dl.github.io/blob/master/img/externally_linked/logos/supported/frameworks.png?raw=true
   :width: 100%

Contents
--------

* `Overview`_
* `Run Through`_
* `Interactive Demos`_
* `Get Involed`_

Overview
--------

.. _docs: https://ivy-dl.org/mech

**What is Ivy Mechanics?**

Ivy mechanics provides functions for conversions of orientation, pose, and positional representations,
as well as frame-of-reference transformations, and other more applied functions. Check out the docs_ for more info!

The library is built on top of the Ivy machine learning framework.
This means all functions simultaneously support:
Jax, Tensorflow, PyTorch, MXNet, and Numpy.

**Ivy Libraries**

There are a host of derived libraries written in Ivy, in the areas of mechanics, 3D vision, robotics, gym environments,
neural memory, pre-trained models + implementations, and builder tools with trainers, data loaders and more. Click on
the icons below to learn more!



.. image:: https://github.com/ivy-dl/ivy-dl.github.io/blob/master/img/externally_linked/ivy_libraries.png?raw=true
   :width: 100%













**Quick Start**

Ivy mechanics can be installed like so: ``pip install ivy-mech``

.. _demos: https://github.com/ivy-dl/mech/tree/master/ivy_mech_demos
.. _interactive: https://github.com/ivy-dl/mech/tree/master/ivy_mech_demos/interactive

To quickly see the different aspects of the library, we suggest you check out the demos_!
We suggest you start by running the script ``run_through.py``,
and read the "Run Through" section below which explains this script.

For more interactive demos, we suggest you run either
``target_facing_rotation_matrix.py`` or ``polar_to_cartesian_coords.py`` in the interactive_ demos folder.

Run Through
-----------

We run through some of the different parts of the library via a simple ongoing example script.
The full script is available in the demos_ folder, as file ``run_through.py``.
First, we select a random backend framework to use for the examples, from the options
``ivy.jax``, ``ivy.tensorflow``, ``ivy.torch``, ``ivy.mxnd`` or ``ivy.numpy``,
and use this to set the ivy backend framework.

.. code-block:: python

    import ivy
    from ivy_demo_utils.framework_utils import choose_random_framework
    ivy.set_framework(choose_random_framework())

**Orientation Module**

The orientation module is the most comprehensive, with conversions to and from all euler conventions, quaternions,
rotation matrices, rotation vectors, and axis-angle representations.

A few of the orientation functions are outlined below.

.. code-block:: python

    # rotation representations

    # 3
    rot_vec = ivy.array([0., 1., 0.])

    # 3 x 3
    rot_mat = ivy_mech.rot_vec_to_rot_mat(rot_vec)

    # 3
    euler_angles = ivy_mech.rot_mat_to_euler(rot_mat, 'zyx')

    # 4
    quat = ivy_mech.euler_to_quaternion(euler_angles)

    # 3, 1
    axis, angle = ivy_mech.quaternion_to_axis_and_angle(quat)

    # 3
    rot_vec_again = axis * angle

**Pose Module**

The pose representations mirror the orientation representations, with the addition of 3 values to
represent the cartesian position. Again, we give some examples below.

.. code-block:: python

    # pose representations

    # 3
    position = ivy.ones_like(rot_vec)

    # 6
    rot_vec_pose = ivy.concatenate((position, rot_vec), 0)

    # 3 x 4
    mat_pose = ivy_mech.rot_vec_pose_to_mat_pose(rot_vec_pose)

    # 6
    euler_pose = ivy_mech.mat_pose_to_euler_pose(mat_pose)

    # 7
    quat_pose = ivy_mech.euler_pose_to_quaternion_pose(euler_pose)

    # 6
    rot_vec_pose_again = ivy_mech.quaternion_pose_to_rot_vec_pose(quat_pose)

**Position Module**

The position module includes functions for converting between positional representations,
such as cartesian and polar conventions,
and for applying frame-of-reference transformations to cartesian co-ordinates.

We give some examples for conversion of positional representation below.

.. code-block:: python

    # conversions of positional representation

    # 3
    cartesian_coord = ivy.random_uniform(0., 1., (3,))

    # 3
    polar_coord = ivy_mech.cartesian_to_polar_coords(
        cartesian_coord)

    # 3
    cartesian_coord_again = ivy_mech.polar_to_cartesian_coords(
        polar_coord)

Assuming cartesian form, we give an example of a frame-of-reference transformations below.

.. code-block:: python

    # cartesian co-ordinate frame-of-reference transformations

    # 3 x 4
    trans_mat = ivy.random_uniform(0., 1., (3, 4))

    # 4
    cartesian_coord_homo = ivy_mech.make_coordinates_homogeneous(
        cartesian_coord)

    # 3
    trans_cartesian_coord = ivy.matmul(
        trans_mat, ivy.expand_dims(cartesian_coord_homo, -1))[:, 0]

    # 4
    trans_cartesian_coord_homo = ivy_mech.make_coordinates_homogeneous(
        trans_cartesian_coord)

    # 4 x 4
    trans_mat_homo = ivy_mech.make_transformation_homogeneous(
        trans_mat)

    # 3 x 4
    inv_trans_mat = ivy.inv(trans_mat_homo)[0:3]

    # 3
    cartesian_coord_again = ivy.matmul(
        inv_trans_mat, ivy.expand_dims(trans_cartesian_coord_homo, -1))[:, 0]

Interactive Demos
-----------------

In addition to the run through above, we provide two further demo scripts,
which are more visual and interactive, and are each built around a particular function.

Rather than presenting the code here, we show visualizations of the demos.
The scripts for these demos can be found in the interactive_ demos folder.

**Target Facing Rotation Matrix**

The first demo uses the method ``ivy_mech.target_facing_rotation_matrix`` to dynamically
track a moving target plant pot with a camera, as shown below:



.. image:: https://github.com/ivy-dl/ivy-dl.github.io/blob/master/img/externally_linked/ivy_mech/demo_a.png?raw=true
   :width: 100%

**Polar to Cartesian Co-ordinates**

The second demo uses the method ``ivy_mech.polar_to_cartesian_coords`` to convert a polar depth image
acquired from an omni-directional camera into cartesian co-ordinates,
enabling the surrounding geometry to be represented as a point cloud, for interactive visualization.



.. image:: https://github.com/ivy-dl/ivy-dl.github.io/blob/master/img/externally_linked/ivy_mech/demo_b.png?raw=true
   :width: 100%

Get Involed
-----------

We hope the functions in this library are useful to a wide range of machine learning developers.
However, there are many more areas of mechanics which could be covered by this library.

If there are any particular mechanics functions you feel are missing,
and your needs are not met by the functions currently on offer,
then we are very happy to accept pull requests!

We look forward to working with the community on expanding and improving the Ivy mechanics library.

Citation
--------

::

    @article{lenton2021ivy,
      title={Ivy: Unified Machine Learning for Inter-Framework Portability},
      author={Lenton, Daniel and Pardo, Fabio and Falck, Fabian and James, Stephen and Clark, Ronald},
      journal={arXiv preprint arXiv:2102.02886},
      year={2021}
    }


            

Raw data

            {
    "_id": null,
    "home_page": "https://ivy-dl.org/mech",
    "name": "ivy-mech",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Ivy Team",
    "author_email": "ivydl.team@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9b/b5/15db2cce9fc5ba8aa0cb74a04c3ed10d982136048e3fe3dbd0abfe04c9cb/ivy-mech-1.1.9.tar.gz",
    "platform": "",
    "description": ".. image:: https://github.com/ivy-dl/mech/blob/master/docs/partial_source/logos/logo.png?raw=true\n   :width: 100%\n\n\n\n**Mechanics functions with end-to-end support for machine learning developers, written in Ivy.**\n\n\n\n.. image:: https://github.com/ivy-dl/ivy-dl.github.io/blob/master/img/externally_linked/logos/supported/frameworks.png?raw=true\n   :width: 100%\n\nContents\n--------\n\n* `Overview`_\n* `Run Through`_\n* `Interactive Demos`_\n* `Get Involed`_\n\nOverview\n--------\n\n.. _docs: https://ivy-dl.org/mech\n\n**What is Ivy Mechanics?**\n\nIvy mechanics provides functions for conversions of orientation, pose, and positional representations,\nas well as frame-of-reference transformations, and other more applied functions. Check out the docs_ for more info!\n\nThe library is built on top of the Ivy machine learning framework.\nThis means all functions simultaneously support:\nJax, Tensorflow, PyTorch, MXNet, and Numpy.\n\n**Ivy Libraries**\n\nThere are a host of derived libraries written in Ivy, in the areas of mechanics, 3D vision, robotics, gym environments,\nneural memory, pre-trained models + implementations, and builder tools with trainers, data loaders and more. Click on\nthe icons below to learn more!\n\n\n\n.. image:: https://github.com/ivy-dl/ivy-dl.github.io/blob/master/img/externally_linked/ivy_libraries.png?raw=true\n   :width: 100%\n\n\n\n\n\n\n\n\n\n\n\n\n\n**Quick Start**\n\nIvy mechanics can be installed like so: ``pip install ivy-mech``\n\n.. _demos: https://github.com/ivy-dl/mech/tree/master/ivy_mech_demos\n.. _interactive: https://github.com/ivy-dl/mech/tree/master/ivy_mech_demos/interactive\n\nTo quickly see the different aspects of the library, we suggest you check out the demos_!\nWe suggest you start by running the script ``run_through.py``,\nand read the \"Run Through\" section below which explains this script.\n\nFor more interactive demos, we suggest you run either\n``target_facing_rotation_matrix.py`` or ``polar_to_cartesian_coords.py`` in the interactive_ demos folder.\n\nRun Through\n-----------\n\nWe run through some of the different parts of the library via a simple ongoing example script.\nThe full script is available in the demos_ folder, as file ``run_through.py``.\nFirst, we select a random backend framework to use for the examples, from the options\n``ivy.jax``, ``ivy.tensorflow``, ``ivy.torch``, ``ivy.mxnd`` or ``ivy.numpy``,\nand use this to set the ivy backend framework.\n\n.. code-block:: python\n\n    import ivy\n    from ivy_demo_utils.framework_utils import choose_random_framework\n    ivy.set_framework(choose_random_framework())\n\n**Orientation Module**\n\nThe orientation module is the most comprehensive, with conversions to and from all euler conventions, quaternions,\nrotation matrices, rotation vectors, and axis-angle representations.\n\nA few of the orientation functions are outlined below.\n\n.. code-block:: python\n\n    # rotation representations\n\n    # 3\n    rot_vec = ivy.array([0., 1., 0.])\n\n    # 3 x 3\n    rot_mat = ivy_mech.rot_vec_to_rot_mat(rot_vec)\n\n    # 3\n    euler_angles = ivy_mech.rot_mat_to_euler(rot_mat, 'zyx')\n\n    # 4\n    quat = ivy_mech.euler_to_quaternion(euler_angles)\n\n    # 3, 1\n    axis, angle = ivy_mech.quaternion_to_axis_and_angle(quat)\n\n    # 3\n    rot_vec_again = axis * angle\n\n**Pose Module**\n\nThe pose representations mirror the orientation representations, with the addition of 3 values to\nrepresent the cartesian position. Again, we give some examples below.\n\n.. code-block:: python\n\n    # pose representations\n\n    # 3\n    position = ivy.ones_like(rot_vec)\n\n    # 6\n    rot_vec_pose = ivy.concatenate((position, rot_vec), 0)\n\n    # 3 x 4\n    mat_pose = ivy_mech.rot_vec_pose_to_mat_pose(rot_vec_pose)\n\n    # 6\n    euler_pose = ivy_mech.mat_pose_to_euler_pose(mat_pose)\n\n    # 7\n    quat_pose = ivy_mech.euler_pose_to_quaternion_pose(euler_pose)\n\n    # 6\n    rot_vec_pose_again = ivy_mech.quaternion_pose_to_rot_vec_pose(quat_pose)\n\n**Position Module**\n\nThe position module includes functions for converting between positional representations,\nsuch as cartesian and polar conventions,\nand for applying frame-of-reference transformations to cartesian co-ordinates.\n\nWe give some examples for conversion of positional representation below.\n\n.. code-block:: python\n\n    # conversions of positional representation\n\n    # 3\n    cartesian_coord = ivy.random_uniform(0., 1., (3,))\n\n    # 3\n    polar_coord = ivy_mech.cartesian_to_polar_coords(\n        cartesian_coord)\n\n    # 3\n    cartesian_coord_again = ivy_mech.polar_to_cartesian_coords(\n        polar_coord)\n\nAssuming cartesian form, we give an example of a frame-of-reference transformations below.\n\n.. code-block:: python\n\n    # cartesian co-ordinate frame-of-reference transformations\n\n    # 3 x 4\n    trans_mat = ivy.random_uniform(0., 1., (3, 4))\n\n    # 4\n    cartesian_coord_homo = ivy_mech.make_coordinates_homogeneous(\n        cartesian_coord)\n\n    # 3\n    trans_cartesian_coord = ivy.matmul(\n        trans_mat, ivy.expand_dims(cartesian_coord_homo, -1))[:, 0]\n\n    # 4\n    trans_cartesian_coord_homo = ivy_mech.make_coordinates_homogeneous(\n        trans_cartesian_coord)\n\n    # 4 x 4\n    trans_mat_homo = ivy_mech.make_transformation_homogeneous(\n        trans_mat)\n\n    # 3 x 4\n    inv_trans_mat = ivy.inv(trans_mat_homo)[0:3]\n\n    # 3\n    cartesian_coord_again = ivy.matmul(\n        inv_trans_mat, ivy.expand_dims(trans_cartesian_coord_homo, -1))[:, 0]\n\nInteractive Demos\n-----------------\n\nIn addition to the run through above, we provide two further demo scripts,\nwhich are more visual and interactive, and are each built around a particular function.\n\nRather than presenting the code here, we show visualizations of the demos.\nThe scripts for these demos can be found in the interactive_ demos folder.\n\n**Target Facing Rotation Matrix**\n\nThe first demo uses the method ``ivy_mech.target_facing_rotation_matrix`` to dynamically\ntrack a moving target plant pot with a camera, as shown below:\n\n\n\n.. image:: https://github.com/ivy-dl/ivy-dl.github.io/blob/master/img/externally_linked/ivy_mech/demo_a.png?raw=true\n   :width: 100%\n\n**Polar to Cartesian Co-ordinates**\n\nThe second demo uses the method ``ivy_mech.polar_to_cartesian_coords`` to convert a polar depth image\nacquired from an omni-directional camera into cartesian co-ordinates,\nenabling the surrounding geometry to be represented as a point cloud, for interactive visualization.\n\n\n\n.. image:: https://github.com/ivy-dl/ivy-dl.github.io/blob/master/img/externally_linked/ivy_mech/demo_b.png?raw=true\n   :width: 100%\n\nGet Involed\n-----------\n\nWe hope the functions in this library are useful to a wide range of machine learning developers.\nHowever, there are many more areas of mechanics which could be covered by this library.\n\nIf there are any particular mechanics functions you feel are missing,\nand your needs are not met by the functions currently on offer,\nthen we are very happy to accept pull requests!\n\nWe look forward to working with the community on expanding and improving the Ivy mechanics library.\n\nCitation\n--------\n\n::\n\n    @article{lenton2021ivy,\n      title={Ivy: Unified Machine Learning for Inter-Framework Portability},\n      author={Lenton, Daniel and Pardo, Fabio and Falck, Fabian and James, Stephen and Clark, Ronald},\n      journal={arXiv preprint arXiv:2102.02886},\n      year={2021}\n    }\n\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Mechanics functions with end-to-end support for machine learning developers, written in Ivy",
    "version": "1.1.9",
    "project_urls": {
        "Docs": "https://ivy-dl.org/mech/",
        "Homepage": "https://ivy-dl.org/mech",
        "Source": "https://github.com/ivy-dl/mech"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e64d051f47f641bf19b19b085b72983b97bac2e873b66bfdc467bb2ede616b14",
                "md5": "859125372ba597dcdb285e0e098e648a",
                "sha256": "c7456d3a79ddce00b17b89dd029513ee4dd1993d81aa564e27382400c745024f"
            },
            "downloads": -1,
            "filename": "ivy_mech-1.1.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "859125372ba597dcdb285e0e098e648a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 23887,
            "upload_time": "2021-12-01T16:07:05",
            "upload_time_iso_8601": "2021-12-01T16:07:05.687567Z",
            "url": "https://files.pythonhosted.org/packages/e6/4d/051f47f641bf19b19b085b72983b97bac2e873b66bfdc467bb2ede616b14/ivy_mech-1.1.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9bb515db2cce9fc5ba8aa0cb74a04c3ed10d982136048e3fe3dbd0abfe04c9cb",
                "md5": "c989982b690d00ff048c3c347a0594e3",
                "sha256": "4db46c74327a9d140212a4d09b38eaf84f41b7a565591c43de6deb6f3097b3de"
            },
            "downloads": -1,
            "filename": "ivy-mech-1.1.9.tar.gz",
            "has_sig": false,
            "md5_digest": "c989982b690d00ff048c3c347a0594e3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 21421,
            "upload_time": "2021-12-01T16:07:06",
            "upload_time_iso_8601": "2021-12-01T16:07:06.822516Z",
            "url": "https://files.pythonhosted.org/packages/9b/b5/15db2cce9fc5ba8aa0cb74a04c3ed10d982136048e3fe3dbd0abfe04c9cb/ivy-mech-1.1.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-12-01 16:07:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ivy-dl",
    "github_project": "mech",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "ivy-mech"
}
        
Elapsed time: 0.10270s