Skip to main content

basic mathematical library for robotics reserach

Project description

Mathrobo

Mathrobo is a Python library for robotics-oriented mathematical computation, including Lie group operations, spatial transformations, numerical differentiation/integration, and B-spline utilities.

Installation

Install the latest release from PyPI:

pip install mathrobo

If you use uv, you can add Mathrobo to your project with:

uv add mathrobo

Development install

For local development, clone the repository:

git clone https://github.com/MathRobotics/MathRobo.git
cd MathRobo

Sync the development environment from pyproject.toml and uv.lock:

uv sync --extra dev

Install the package in editable mode:

uv pip install -e .

Examples

Refer to the examples in the examples folder, where you can find Jupyter notebooks and scripts demonstrating various use cases of the library.

Usage

You can also work with spatial transformations using the SE3 class. The following snippet creates a 90 degree rotation around the Z axis with a translation, applies the transformation to a point and then inverts it:

import numpy as np
import mathrobo as mr

# Rotation of 90 deg about Z and translation of 1 m along X
rot = mr.SO3.exp(np.array([0.0, 0.0, 1.0]), np.pi / 2)
T = mr.SE3(rot, np.array([1.0, 0.0, 0.0]))

point = np.array([0.0, 1.0, 0.0])
transformed = T @ point
recovered = T.inv() @ transformed

print(transformed)
print(recovered)

Here is a quick example that computes the numerical gradient of a simple function:

import numpy as np
import mathrobo as mr

f = lambda x: np.sum(x**2)
x = np.array([1.0, 2.0, -3.0])
grad = mr.numerical_grad(x, f)
print(grad)

You can also perform numerical integration using the Gaussian quadrature helper gq_integrate:

import numpy as np
import mathrobo as mr

f = lambda s: np.array([np.sin(s)])
val = mr.gq_integrate(f, 0.0, np.pi, digit=5)
print(val)  # ~ 2.0

For spline trajectories, SciPy's BSpline can be used to create and evaluate a curve:

import numpy as np
from scipy.interpolate import make_interp_spline

t = np.array([0, 1, 2, 3])
points = np.array([0.0, 1.0, 0.0, 1.0])
spl = make_interp_spline(t, points, k=3)

ts = np.linspace(0, 3, 20)
ys = spl(ts)
print(ys)

Running Tests

Run the test suite with uv:

uv run --extra dev pytest

Changelog

  • Removed SymPy as a runtime dependency. Mathrobo now supports the NumPy and JAX code paths only, and uv.lock no longer includes SymPy or mpmath.

Contributing

Contributions are welcome! Feel free to report issues, suggest features, or submit pull requests.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mathrobo-0.0.4.tar.gz (119.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mathrobo-0.0.4-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file mathrobo-0.0.4.tar.gz.

File metadata

  • Download URL: mathrobo-0.0.4.tar.gz
  • Upload date:
  • Size: 119.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for mathrobo-0.0.4.tar.gz
Algorithm Hash digest
SHA256 7a04ffe1aab25cef4ef92cfb3d08be2fb220f81833d6785e254c6732393553bc
MD5 c544114d711008282a55627cf1d99422
BLAKE2b-256 1c490c035b2ae20664b224025bfcf037a9e1ef06e327ffae7c36e28deb837c22

See more details on using hashes here.

File details

Details for the file mathrobo-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: mathrobo-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for mathrobo-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 347a2a678ce070736254fd952e5d1efc2af70c3b15af518b6a9ff4a4995a048a
MD5 044245778e8bcb4be3c5d06b1d7561ec
BLAKE2b-256 e73f6480ce680ac524c4f2e965ba17634fe544677e705e8f51eac5576375ce0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page