Skip to main content
https://github.com/ivy-dl/mech/blob/master/docs/partial_source/logos/logo.png?raw=true

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

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

Contents

Overview

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!

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

Quick Start

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

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.

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.

# 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.

# 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.

# 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.

# 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:

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

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.

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

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}
}

Metadata

Release files for ivy-mech 1.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ivy-mech 1.1.9
File Size Uploaded Provenance Actions
ivy-mech-1.1.9.tar.gz 21.4 kB Without provenance Details for ivy-mech-1.1.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ivy-mech 1.1.9
File Interpreter ABI Platform Actions
ivy_mech-1.1.9-py3-none-any.whl Python 3 none any Details for ivy_mech-1.1.9-py3-none-any.whl

Total release size: 45.3 kB

Release files / ivy-mech-1.1.9.tar.gz

Download URL ivy-mech-1.1.9.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4db46c74327a9d140212a4d09b38eaf84f41b7a565591c43de6deb6f3097b3de
BLAKE2b-256 checksum
How to use checksums
9bb515db2cce9fc5ba8aa0cb74a04c3ed10d982136048e3fe3dbd0abfe04c9cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Release files / ivy_mech-1.1.9-py3-none-any.whl

Download URL ivy_mech-1.1.9-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7456d3a79ddce00b17b89dd029513ee4dd1993d81aa564e27382400c745024f
BLAKE2b-256 checksum
How to use checksums
e64d051f47f641bf19b19b085b72983b97bac2e873b66bfdc467bb2ede616b14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Security for ivy-mech 1.1.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page