Skip to content

Commit

Permalink
renamed package, changed to ruff, updated build system
Browse files Browse the repository at this point in the history
  • Loading branch information
tetov committed Apr 15, 2024
1 parent c9f8d38 commit c2bf1cc
Show file tree
Hide file tree
Showing 25 changed files with 154 additions and 481 deletions.
44 changes: 30 additions & 14 deletions .github/workflows/test-publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9, 3.10]

steps:
- name: Checkout repo
Expand All @@ -30,20 +30,29 @@ jobs:

- name: Install
run: |
python -m pip install wheel # https://stackoverflow.com/questions/34819221
python -m pip install --no-cache-dir -e .[dev]
- name: Test import
run: python -m compas_mobile_robot_reloc
run: python -m compas_mrr

- name: Test
run: invoke test
run: pytest

- name: Build docs
run: invoke docs
run: |
sphinx-build -b doctest docs build/docs
sphinx-apidoc \
--separate \
--module-first \
--no-toc \
--force \
--no-headings \
-o docs/reference src/compas_mobile_robot_reloc
sphinx-build -b html docs dist/docs
sphinx-build -b linkcheck docs dist/docs
- name: Build package
run: invoke build
run: python -m build

ironpython-test:
name: windows-ironpython
Expand Down Expand Up @@ -72,7 +81,7 @@ jobs:
- name: Test import
run: |
ipy -m compas_mobile_robot_reloc
ipy -m compas_mrr
env:
IRONPYTHONPATH: ./src

Expand All @@ -98,17 +107,26 @@ jobs:

- name: Install
run: |
pip install wheel # https://stackoverflow.com/questions/34819221
pip install --no-cache-dir -e .[dev]
- name: Build docs
run: invoke docs
run: |
sphinx-build -b doctest docs build/docs
sphinx-apidoc \
--separate \
--module-first \
--no-toc \
--force \
--no-headings \
-o docs/reference src/compas_mobile_robot_reloc
sphinx-build -b html docs dist/docs
sphinx-build -b linkcheck docs dist/docs
- name: Publish docs on branch gh-pages
uses: crazy-max/ghaction-github-pages@5859b4ea7efe6b470a5b19c570460eae9323aefc
with:
target_branch: gh-pages
build_dir: docs
build_dir: dist/docs
jekyll: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -141,12 +159,10 @@ jobs:
python-version: 3.9

- name: Install
run: |
pip install wheel # https://stackoverflow.com/questions/34819221
python -m pip install --no-cache-dir -e .[dev]
run: python -m pip install --no-cache-dir -e .[dev]

- name: Build package
run: invoke build
run: python -m build .

- name: Upload and release package on PyPi
uses: pypa/gh-action-pypi-publish@v1.8.11
Expand Down
18 changes: 4 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: .gh|.ghx
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -14,16 +12,8 @@ repos:
hooks:
- id: python-check-blanket-noqa
- id: rst-backticks
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.7
hooks:
- id: flake8
- repo: https://github.com/psf/black
rev: 21.6b0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.902'
hooks:
- id: mypy
- id: ruff
- id: ruff-format
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ In short, this is how that works.

### Setup

1. Fork [the repository](https://github.com/gramaziokohler/compas_mobile_robot_reloc) and clone the fork.
1. Fork [the repository](https://github.com/gramaziokohler/compas_mrr_robot_reloc) and clone the fork.

2. Create a virtual environment using your tool of choice (e.g. `virtualenv`, `conda`, etc).

Expand All @@ -21,8 +21,8 @@ In short, this is how that works.
conda config --set channel_priority strict

# use conda to install compas if possible
conda create -n compas_mobile_robot_reloc-dev python=3.8 compas==0.19.3
conda activate compas_mobile_robot_reloc-dev
conda create -n compas_mrr-dev python=3.8 compas==0.19.3
conda activate compas_mrr-dev
pip install -e .[dev]
```

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

Robot localization using external measuring device (total station).

![Build and test](https://github.com/gramaziokohler/compas_mobile_robot_reloc/workflows/workflow/badge.svg)
[![PyPI Package latest release](https://img.shields.io/pypi/v/compas_mobile_robot_reloc.svg)](https://pypi.org/project/compas-mobile-robot-reloc)
[![Conda](https://img.shields.io/conda/v/conda-forge/compas_mobile_robot_reloc)](https://anaconda.org/conda-forge/compas_mobile_robot_reloc)
![License](https://img.shields.io/github/license/gramaziokohler/compas_mobile_robot_reloc)
![Build and test](https://github.com/gramaziokohler/compas_mrr/workflows/workflow/badge.svg)
[![PyPI Package latest release](https://img.shields.io/pypi/v/compas_mrr.svg)](https://pypi.org/project/compas-mrr)
[![Conda](https://img.shields.io/conda/v/conda-forge/compas_mrr)](https://anaconda.org/conda-forge/compas_mrr)
![License](https://img.shields.io/github/license/gramaziokohler/compas_mrr)

![Image of total station and robot setup in Brunnen](docs/images/total_station_brunnen.png)
Photo from video shot by
[MASDFAB 1920 team](https://www.masdfab.com/2019-20-t3-mas-dfab).

* [Documentation](https://gramaziokohler.github.io/compas_mobile_robot_reloc)
* [Issue tracker](https://github.com/gramaziokohler/compas_mobile_robot_reloc)
* [Documentation](https://gramaziokohler.github.io/compas_mrr)
* [Issue tracker](https://github.com/gramaziokohler/compas_mrr)

## Sources

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""compas_mobile_robot_reloc"""
"""compas_mrr"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
Expand Down Expand Up @@ -27,7 +28,7 @@ def _get_version(): # type: () -> str
# and setuptools_scm docs
try:
# import from _version.py generated by setuptools_scm during release
from ._version import version
from ._version import version # type: ignore

return version
except ImportError:
Expand All @@ -48,7 +49,7 @@ def _get_version(): # type: () -> str

@compas.plugins.plugin(category="install")
def installable_rhino_packages():
return ["compas_mobile_robot_reloc"]
return ["compas_mrr"]


__author__ = "Gramazio Kohler Research"
Expand All @@ -58,7 +59,7 @@ def installable_rhino_packages():
__version__ = _get_version()


__all_plugins__ = ["compas_mobile_robot_reloc.rhino_install"]
__all_plugins__ = ["compas_mrr.rhino_install"]

# Backport for path related bug with compas.rpc.Proxy
# See https://github.com/compas-dev/compas/issues/701
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import sys
import compas
import compas_mobile_robot_reloc
import compas_mrr


if __name__ == "__main__":
print()
print("compas_mobile_robot_reloc is installed properly.")
print("compas_mrr is installed properly.")
print()
print("compas_mobile_robot_reloc: {}".format(compas_mobile_robot_reloc.__version__))
print("compas_mrr: {}".format(compas_mrr.__version__))
print("COMPAS: {}".format(compas.__version__))

print("Python: {}".format(sys.version))
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Arbitrary points method for robot relocalization.
*******************************************************************************
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
Expand All @@ -14,7 +15,7 @@
import numpy as np
from scipy.optimize import minimize

from compas_mobile_robot_reloc.utils import TYPE_CHECKING
from compas_mrr.utils import TYPE_CHECKING

try:
from pathlib import Path
Expand All @@ -25,9 +26,9 @@
raise

if TYPE_CHECKING:
from typing import List
from typing import List # noqa: F401

from scipy.optimize import OptimizeResult
from scipy.optimize import OptimizeResult # noqa: F401


def _objective_function(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import compas
import compas.geometry

from compas_mobile_robot_reloc import utils
from compas_mobile_robot_reloc.utils import TYPE_CHECKING
from compas_mobile_robot_reloc.utils import cgpoint_to_rgpoint
from compas_mrr import utils
from compas_mrr.utils import TYPE_CHECKING
from compas_mrr.utils import cgpoint_to_rgpoint

if TYPE_CHECKING:
from typing import Tuple
from typing import Union
from typing import Tuple # noqa: F401
from typing import Union # noqa: F401


class MeasurementPoint(compas.geometry.Point):
Expand Down Expand Up @@ -69,5 +69,5 @@ def _split_pt_name(self): # type: () -> Tuple[str, int]


# Make MeasurementPoint available from utils for backwards compatibility
# with compas_mobile_robot_reloc <= v1.0.4
# with compas_mrr <= v1.0.4
utils.MeasurementPoint = MeasurementPoint # type: ignore[attr-defined]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
"""Three points method for robot relocalization"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from compas.geometry import Frame
from compas.geometry import Transformation

from compas_mobile_robot_reloc.utils import TYPE_CHECKING
from compas_mrr.utils import TYPE_CHECKING

if TYPE_CHECKING:
from typing import List
from typing import Union
from typing import List # noqa: F401
from typing import Union # noqa: F401

from compas.geometry import Point
from compas.geometry import Point # noqa: F401


def _pts_to_frame(pts): # type: (Point) -> Frame
Expand All @@ -26,9 +27,7 @@ def _coerce_frame(frame_or_pts): # type: (Union[List[Point], Frame]) -> Frame
return _pts_to_frame(frame_or_pts)


def three_pts_localization(
rcs_coords, wcs_coords
): # type: (List[Point], List[Point]) -> Frame
def three_pts_localization(rcs_coords, wcs_coords): # type: (List[Point], List[Point]) -> Frame
"""Get the robot base frame in WCS using three points method.
Parameters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
Expand All @@ -7,7 +8,7 @@
import compas.geometry

try:
import Rhino.Geometry
import Rhino.Geometry # type: ignore
except ImportError:
pass

Expand All @@ -33,7 +34,7 @@ def _is_type_checking(): # type: () -> bool
TYPE_CHECKING = _is_type_checking() # type: bool

if TYPE_CHECKING:
from typing import List
from typing import List # noqa: F401


def rgpoint_to_cgpoint(pt):
Expand Down
11 changes: 6 additions & 5 deletions src/compas_mobile_robot_reloc/xforms.py → compas_mrr/xforms.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
"""Transformations"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import compas.geometry as cg

from compas_mobile_robot_reloc.utils import TYPE_CHECKING
from compas_mrr.utils import TYPE_CHECKING

try:
from collections.abc import Sequence
except ImportError:
from collections import Sequence

if TYPE_CHECKING:
from typing import Any
from typing import List
from typing import Any # noqa: F401
from typing import List # noqa: F401


def _coerce_cg_xform(xform): # type: (Any) -> cg.Transformation
try:
from Rhino.Geometry import Transform
from Rhino.Geometry import Transform # type: ignore

if isinstance(xform, Transform):
from compas_mobile_robot_reloc.utils import rgtransform_to_matrix
from compas_mrr.utils import rgtransform_to_matrix

M = rgtransform_to_matrix(xform)
return cg.Transformation.from_matrix(M)
Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

import sphinx_compas_theme

from compas_mobile_robot_reloc import __version__
from compas_mrr import __version__

pkg_name = "compas_mobile_robot_reloc"
pkg_name = "compas_mrr"
project = "COMPAS Mobile Robot Relocalization"
copyright = "Gramazio Kohler Research"
author = "Anton T Johansson"
author = "Anton Tetov"
version = release = __version__

source_suffix = {".rst": "restructuredtext", ".md": "markdown"}
Expand Down

0 comments on commit c2bf1cc

Please sign in to comment.