spatial-casadi
This package implements various data structures and helper methods for manipulating spatial transformations using CasADi variables in Python. The library interface is partially based on the Scipy spatial module.
- Code: https://github.com/cmower/spatial-casadi
- Documentation: https://cmower.github.io/spatial-casadi/
- PyPI: https://pypi.org/project/spatial-casadi
- Issues: https://github.com/cmower/spatial-casadi/issues
Examples
There are three main data structures: Rotation, Translation, and Transformation. The following showcases some of the main functionality of the library.
>>> import spatial_casadi as sc
>>> import casadi as cs
>>> cs.np.random.seed(10)
>>> euler = cs.SX.sym("euler", 3)
>>> sc.Rotation.from_euler('xyz', euler).as_quat()
SX(@1=2, @2=cos((x_2/@1)), @3=cos((x_1/@1)), @4=sin((x_0/@1)), @5=(@3*@4), @6=sin((x_2/@1)), @7=cos((x_0/@1)), @8=sin((x_1/@1)), @9=(@7*@8), @10=(@3*@7), @11=(@8*@4), [((@2*@5)-(@6*@9)), ((@2*@9)+(@6*@5)), ((@10*@6)-(@2*@11)), ((@2*@10)+(@6*@11))])
>>> r = sc.Rotation.random()
>>> r.as_quat()
DM([0.615982, 0.330883, -0.71489, -0.0038783])
>>> r.as_rotvec()
DM([-1.9304, -1.03694, 2.24037])
>>> r.as_matrix()
DM(
[[-0.241103, 0.40209, -0.883285],
[0.41318, -0.781003, -0.468312],
[-0.878152, -0.477867, 0.0221665]])
>>> r.as_euler('xyz')
DM([-1.52444, 1.07199, 2.09902])
>>> r.as_mrp()
DM([-0.613602, -0.329604, 0.712128])
>>> sc.Rotation.from_euler('x', 90, degrees=True).as_matrix()
DM(
[[1, 0, 0],
[0, 2.22045e-16, -1],
[0, 1, 2.22045e-16]])
>> r1 = sc.Rotation.random()
>>> r1.as_quat()
DM([0.625459, -0.724863, 0.267273, 0.109269])
>> r2 = sc.Rotation.random()
>>> r2.as_quat()
DM([0.00332548, -0.1353, 0.335557, 0.932247])
>>> (r1 * r2).as_quat()
DM([0.376374, -0.899524, 0.203617, -0.0879736])
Install
From PyPI
$ pip install spatial-casadi
$ pip install spatial-casadi[test] # if you want to run the test scripts
From source
In a new terminal:
- Clone repository:
- (ssh)
$ git clone git@github.com:cmower/spatial-casadi.git, or - (https)
$ git clone https://github.com/cmower/spatial-casadi.git
- (ssh)
- Change directory:
$ cd spatial-casadi - Ensure
pipis up-to-date:$ python -m pip install --upgrade pip - Install from source:
- (main library)
$ pip install . - (when you want to also run the test scripts)
$ pip install .[test]
- (main library)
Running the test scripts
- Install
spatial-casadifrom source and ensure you install thetestpackages (see previous section). - Change directory:
$ cd /path/to/spatial-casadi - Run tests:
pytest
Build documentation
The documentation is hosted here. However, if you want to build it yourself, then follow these steps.
In a new terminal:
- Clone repository:
- (ssh)
$ git clone git@github.com:cmower/spatial-casadi.git, or - (https)
$ git clone https://github.com/cmower/spatial-casadi.git
- (ssh)
- Change directory:
$ cd spatial-casadi/doc - Install doxygen:
$ sudo apt install doxygen - Build documentation:
$ doxygen - View documentation:
- In a browser, open
html/index.html - Build pdf (requires LaTeX)
$ cd latex$ make- Open the file called
refman.pdf
- In a browser, open
Citing
If you use spatial-casadi in your work, please consider citing the following.
@software{Mower2023
title = "Spatial CasADi: A Compact Library for Manipulating Spatial Transformations",
author = "Christopher E. Mower",
year = "2023",
url = {https://github.com/cmower/spatial-casadi},
}
Contributing
If you have any issues with the library, or find inaccuracies in the documentation please raise an issue. I am happy to consider new features if you fork the library and submit a pull request.
Metadata
Release files for spatial-casadi 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spatial_casadi-1.1.0.tar.gz | 15.1 kB | Without provenance | Details for spatial_casadi-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spatial_casadi-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for spatial_casadi-1.1.0-py3-none-any.whl |
Total release size: 26.7 kB
Release files / spatial_casadi-1.1.0.tar.gz
| Download URL | spatial_casadi-1.1.0.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2696cd318ef2c6078937cb4a0890077f025934a225afe2a6cb3feca9669de66
|
|
BLAKE2b-256 checksum How to use checksums |
6000c73dfcb3d08e4d1292435068f3001b4c33a7a6d9fad21af2a71829c61a0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / spatial_casadi-1.1.0-py3-none-any.whl
| Download URL | spatial_casadi-1.1.0-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf3ae98de874f19b5d2fc82fe3a9072123b47b5d6cd8edd64cad1710056c104b
|
|
BLAKE2b-256 checksum How to use checksums |
c469a6e35a4c42854304ad9f50f20de2e55b6d8e30bc5525de4b9bc47972adab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for spatial-casadi 1.1.0
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.