Skip to content

Commit

Permalink
Homing & GUI (#14)
Browse files Browse the repository at this point in the history
* Uniformize the usage of "Vector" for "position" property in Tic and M3FS

* Fix issue #12

* Autodetect CNCRouter dev device

* Black Format

* Initialisation of files for GUI

* Usage of Enum (python 3.9) instead of StrEnum (python 3.10)

* Position label and regular updates (100ms)

* Move buttons

* Fix Readthedocs configuration

* Add home() function for stages

* Code formating

* Put home button at the center of gui

* Implement Home function for CNC and make Home button on gui effective

* Formatting files and little updates to remove warnings

* raise exception in case of device not found for tic

* Find devices per serial number

* Add comport selection in gui

* Remove magic numbers in M3FS code

* GUI update: enable/disable controls while connection is not done, add absolute position move, usage of validators

* Find devices per serial number, usage for Corvus

* Adding Qt Event processing as wait routine in GUI + typing

* Make home function not abstract with default implementation

* Add the possibility to perform wait-routine while homing

* Remove several linter warnings

* Update comments

* Update to PyQt6 in documentation and requirements

* Enforce Exception raise when ALARM is reported by the CNC
Sometimes the CNC does not answer to '?'.
Returns after 10 tries to get a byte considering the 1 second timeout.
In get_status, retries if there has been no answer from the CNC

* Bumping version and correcting typo

* Update docs

* Update pyproject.toml

Put 'beta' in version

* Add M3FS in GUI

* Bump version

* Update pyproject.toml

* Update conf.py

* Removing "(object)" in "Vector" class definition
  • Loading branch information
mmouchous-ledger authored Jul 22, 2024
1 parent 0bac827 commit f2fd098
Show file tree
Hide file tree
Showing 21 changed files with 683 additions and 131 deletions.
20 changes: 17 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: "ubuntu-22.04"
tools:
python: "3.8"

python: "3.9"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: requirements.txt
- requirements: docs/requirements.txt
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Documentation Status](https://readthedocs.org/projects/pystages/badge/?version=latest)](https://pystages.readthedocs.io/en/latest/?badge=latest)

# PyStages

[![Documentation Status](https://readthedocs.org/projects/pystages/badge/?version=latest)](https://pystages.readthedocs.io/en/latest/?badge=latest)

PyStages is a Python 3 library for controlling motorized stages which have a
motion controller. It has been designed for microscopy test benches automation.

Expand All @@ -14,16 +14,28 @@ are implemented):
- Tic Stepper Motor controller (USB only)
- CNC Router with GRBL/GCode instructions (CNC 3018-PRO)

The library also provides helper classes for basic vector manipulation and
autofocus calculation
The library also provides helper classes for basic vector manipulation and
autofocus computation.

## Documentation

Documentation is available on [Read the Docs](https://pystages.readthedocs.io).

## PyStages GUI

A user interface has been implemented to control the stages.

You can run it with the following command:

```bash
python -m pystages.gui
```

## Requirements

This library requires the following packages:

- [pyserial](https://pypi.org/project/pyserial/)
- [numpy](https://pypi.org/project/numpy/)
- [pyusb](https://pypi.org/project/pyusb/)
- [pyusb](https://pypi.org/project/pyusb/)
- [PyQt6](https://pypi.org/project/PyQt6/)
10 changes: 5 additions & 5 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Classes
.. automodule:: pystages
:members:

.. autoclass:: Autofocus
:members:
.. .. autoclass:: Autofocus
.. :members:
.. autoclass:: Vector
:special-members: __init__
:members:
.. .. autoclass:: Vector
.. :special-members: __init__
.. :members:
20 changes: 14 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,30 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

import sys
import os

# Add path for autodoc
sys.path.insert(0, os.path.abspath(".."))


# -- Project information -----------------------------------------------------

project = "pystages"
copyright = "2022, Olivier Hériveaux, Manuel San Pedro, Michaël Mouchous"
copyright = "2024, Olivier Hériveaux, Manuel San Pedro, Michaël Mouchous"
author = "Olivier Hériveaux, Manuel San Pedro, Michaël Mouchous"

# The full version, including alpha/beta/rc tags
release = "1.1"
release = "1.2"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx.ext.autodoc"]
extensions = ["sphinx.ext.autodoc", "myst_parser"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand All @@ -54,3 +57,8 @@
html_static_path = []

html_logo = "logo.png"

source_suffix = {
".rst": "restructuredtext",
".md": "markdown",
}
41 changes: 41 additions & 0 deletions docs/gui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# PyStages GUI

A user interface has been implemented to control the stages.

You can run it with the following command:

```bash
python -m pystages.gui
```

This tool presents basic controls. After connection to the stage, it polls the position and prints out
at the bottom of the window.

## Stage selection and connection

Select the type of stage that you want to control and chose either a serial port to connect to, or select `Auto detect`
to make pystage to select the correct one according to the device description.

Then click to `Connect`. If the connection success, the control buttons are activated.

## Relative move

You can click on buttons to move for a positive of negative relative distance.
The direction correspond to the axis number of the stage (`X` for first axe, `Y` for the second one,
`Z` for the third one). The moving distance is selected throug the `Step` dropdown menu.

## Absolute move

You can enter absolute coordinates in the 3 entry boxes and trigger the move by clicking the `Go To Position` button.

## Z offset

The `Z offset` checkbox and dropdown menu permit for each horizontal move (X or Y)
to make first a vertical-up displacement (Z+) followed by the
actual move, and then a final vertical-down displacement (Z-).

## Homing

The `Home` button permits to trigger the calibration process of the stage.
Be careful that your setup is clear before using it.

20 changes: 8 additions & 12 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.. pystages documentation master file, created by
sphinx-quickstart on Tue Jul 7 15:03:18 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to pystages's documentation!
====================================

Expand All @@ -24,13 +19,14 @@ The library also provides helper classes for basic vector manipulation
(:class:`pystages.Autofocus`).

.. toctree::
:maxdepth: 2
:caption: Contents:

Vectors <vectors.rst>
Autofocus <autofocus.rst>
Python API <api.rst>
Troubleshooting <troubleshooting.rst>
:maxdepth: 2
:caption: Contents:

Vectors <vectors.rst>
Autofocus <autofocus.rst>
Python API <api.rst>
GUI <gui.md>
Troubleshooting <troubleshooting.rst>


Indices and tables
Expand Down
6 changes: 6 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pyserial
pyusb
numpy
sphinx
sphinx-rtd-theme
myst-parser
22 changes: 9 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,22 @@ build-backend = "hatchling.build"

[project]
name = "pystages"
version = "1.1.0"
version = "1.2"
authors = [
{ name="Olivier Hérivaux", email="olivier.heriveaux@ledger.fr" },
{ name="Michaël Mouchous", email="michael.mouchous@ledger.fr" },
{ name = "Olivier Hérivaux", email = "olivier.heriveaux@ledger.fr" },
{ name = "Michaël Mouchous", email = "michael.mouchous@ledger.fr" },
]
description = "Motorized stage control library for scientific applications"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: OS Independent",
]
dependencies = [
"pyserial",
"pyusb",
"numpy"
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: OS Independent",
]
dependencies = ["pyserial", "pyusb", "numpy", "pyqt6"]

[project.urls]
"Homepage" = "https://github.com/Ledger-Donjon/pystages"
"Bug Tracker" = "https://github.com/Ledger-Donjon/pystages/issues"
"Documentation" = "https://pystages.readthedocs.io/en/latest"
"Documentation" = "https://pystages.readthedocs.io/en/latest"
13 changes: 13 additions & 0 deletions pystages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,16 @@
from .vector import Vector
from .tic import Tic, TicDirection
from .cncrouter import CNCRouter, CNCStatus

__all__ = [
"Stage",
"Corvus",
"M3FS",
"SMC100",
"Autofocus",
"Vector",
"Tic",
"TicDirection",
"CNCRouter",
"CNCStatus",
]
Loading

0 comments on commit f2fd098

Please sign in to comment.