Skip to main content

basic mathematical library for robotics reserach

Project description

Mathrobo

Mathrobo is a lightweight library designed to support mathematical optimization and computations related to robotics.

Installation

Clone the repository

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

Install dependencies with uv

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

uv sync

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 pytest

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.2.tar.gz (105.4 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.2-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mathrobo-0.0.2.tar.gz
  • Upload date:
  • Size: 105.4 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.2.tar.gz
Algorithm Hash digest
SHA256 80c6771cf9facf48ad313715aea2a400f82b9dc013cdbb026b95c8ac9232a987
MD5 dc687142452d577174ba32a9006d499f
BLAKE2b-256 2987e0734e2fb6de61c6a790e9cbc9b9fcdc8871cdad2ed0670cce9652069e4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mathrobo-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 25.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d6e72a2472a9f794519e2a5ca2856d1631c737a1f7a2a0625adb8ec3520ae00a
MD5 5bf517cf866dc5dffd20e4fd3611ed33
BLAKE2b-256 0d6438436408d74eb803befc5b62cf8e30b799f0b8604cd3d0e0beda8038551d

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