Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more models to Alitra and refactoring #44

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 7 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,8 @@ 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. The
[test_example.py](tests/test_example.py) is a good place to start.
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.

4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
line_length = 88
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap=0
use_parentheses=True
force_grid_wrap = 0
use_parentheses = True

[mypy]
follow_imports = normal
Expand Down
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"]},
)
52 changes: 26 additions & 26 deletions src/alitra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,47 @@
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
asset coordinate-frame.
internal coordinate-frame. We want to transform a position in the robot coordinate-frame
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.models import Positions, 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 = np.array([np.pi / 4, 0, 0])
>>> translation = Translation(x=1, y=0, from_=robot_frame, to_=asset_frame)
>>> p_robot = Positions.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_array(
... 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.transform_position(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,
from alitra.alignment import align_maps, align_positions
from alitra.models import (
Bounds,
Frame,
Map,
MapAlignment,
Orientation,
Pose,
Position,
Positions,
Translation,
)
from alitra.frame_transform import FrameTransform
from alitra.models.bounds import Bounds
from alitra.models.map_config import MapConfig, load_map_config
from alitra.transform import Transform
Loading