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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mathrobo-0.0.3.tar.gz.
File metadata
- Download URL: mathrobo-0.0.3.tar.gz
- Upload date:
- Size: 108.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57dc0af2188ebbfd941c484864e9fbb568b2d89ee71b032a0b456c58bbe52aa9
|
|
| MD5 |
636f9898a0ea11c9a04dd33e645c5cd4
|
|
| BLAKE2b-256 |
5be61432b3b3eec6ac99465794a1efeac97664c8e39d82d8695944d9f5eb932e
|
File details
Details for the file mathrobo-0.0.3-py3-none-any.whl.
File metadata
- Download URL: mathrobo-0.0.3-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e735a8d5243fefd42a4aee47c4c6b768d099cb197c871b1310205920a5f3da16
|
|
| MD5 |
e92362fc91dae5693411c4ad69dc90e5
|
|
| BLAKE2b-256 |
29280c496e2d24c03ff71733e73049a8df19c5055b7e053b94efcf44bad59dd3
|