Skip to content

Commit

Permalink
Add Pose, Position and Orientation models to alitra and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Christdej committed Apr 6, 2022
1 parent f6a3d66 commit 79ec335
Show file tree
Hide file tree
Showing 56 changed files with 1,851 additions and 1,341 deletions.
28 changes: 16 additions & 12 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
name: Python package

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
python-version: ["3.8"]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install -e .[dev]
- name: Lint
run: |
pip install black mypy
black --check .
mypy src/alitra
mypy tests
mypy .
- name: Test with pytest
run: |
pip install pytest
pytest
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
Expand Down
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ help(alitra)
### Installation from source

```
pip install .
git clone https://github.com/equinor/alitra
cd alitra
pip install .[dev]
```

You can test whether installation was successfull with pytest

```
pip install pytest
pytest .
```

Expand All @@ -40,15 +41,7 @@ pip install -e /path/to/package

This will install package in _editable_ mode. Convenient for local development

## Components
### How to use

### Frame transform

Class for transforming coordinates between two coordinates frames. Use custom
dataclasses for conveniency, and to ensure that no mistakes are made in the transform.

### Align frames

Finds the rotations and translations between two coordinate systems by minimizing the
matching error given a set of points described in both coordinate frames.
Run `python examples/example_manual_alignment.py` for a demonstration of its use.
The tests in this repository can be used as examples
of how to use the different models and functions
Binary file removed examples/Echo.png
Binary file not shown.
Empty file removed examples/__init__.py
Empty file.
81 changes: 0 additions & 81 deletions examples/example_manual_alignment.py

This file was deleted.

Binary file removed examples/localization-inspector.png
Binary file not shown.
7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

7 changes: 1 addition & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,5 @@
include_package_data=True,
install_requires=["scipy", "numpy", "dacite"],
python_requires=">=3.8",
extras_require={
"dev": [
"pytest",
"black",
]
},
extras_require={"dev": ["pytest", "black", "mypy"]},
)
47 changes: 22 additions & 25 deletions src/alitra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,44 @@
easier by using custom dataclasses
Imagine we have an "asset" with one coordinate-frame and a "robot" with its own
internal coordinate-frame. We want to transform a point on the robot to a point in the
internal coordinate-frame. We want to transform a position on the robot to a position in the
asset coordinate-frame.
>>> import numpy as np
>>> from alitra.align_frames import AlignFrames
>>> from alitra.frame_dataclasses import Euler, Quaternion, PointList, Translation
>>> from alitra.frame_transform import FrameTransform
>>> from alitra import align_frames
>>> from alitra.models import Euler, Quaternion, PositionList, Transform, Translation
Setting up rotations, translations and points for transformation
Setting up rotations, translations and positions for transformation
>>> eul_rot = Euler(psi=np.pi / 4, from_="robot", to_="asset").as_np_array()
>>> ref_translations = Translation(x=1, y=0, from_="robot", to_="asset")
>>> p_robot = PointList.from_array(np.array([[1, 1, 0], [10, 1, 0]]), frame="robot")
>>> robot_frame = Frame("robot")
>>> asset_frame = Frame("asset")
>>> euler = Euler(psi=np.pi / 4, from_=robot_frame, to_=asset_frame).to_array()
>>> translation = Translation(x=1, y=0, from_=robot_frame, to_=asset_frame)
>>> p_robot = PositionList.from_array(np.array([[1, 1, 0], [10, 1, 0]]), frame=robot_frame)
>>> rotation_axes = "z"
Making the transform
>>> c_frame_transform = FrameTransform(
... eul_rot, ref_translations, from_=eul_rot.from_, to_=eul_rot.to_
>>> transform = Transform.from_euler(
... translation=translation, euler=euler, from_=robot_frame, to_=asset_frame
... )
Tranform point on robot to a point on the asset
Tranform position on robot to a position on the asset
>>> p_asset = c_frame_transform.transform_point(p_robot, from_="robot", to_="asset")
>>> p_asset = transform_position(transform, p_robot, from_=robot_frame, to_=asset_frame)
If you have one point in two different frames and the rotation between the axes you can find the transform
If you have one position in two different frames and the rotation between the axes you can find the transform
between the two frames.
>>> transform = AlignFrames.align_frames(p_robot, p_asset, rotation_axes)
>>> transform = Transform(p_robot, p_asset, rotation_axes)
"""

from alitra.align_frames import AlignFrames
from alitra.frame_dataclasses import (
Euler,
Point,
PointList,
Quaternion,
Transform,
Translation,
from alitra.alignment import align_maps, align_positions
from alitra.transformations import (
transform_euler,
transform_orientation,
transform_pose,
transform_position,
transform_quaternion,
)
from alitra.frame_transform import FrameTransform
from alitra.models.bounds import Bounds
from alitra.models.map_config import MapConfig, load_map_config
Loading

0 comments on commit 79ec335

Please sign in to comment.