OpenFlexure Microscope python

For delta stage I wanted to run a program in python which consists from two parts:

  • main.py: the script that executes the XYZ scan. Runs on the PC, talks to the RPi which is controlling the OpenFlexure stage
  • stage.py: a plugin that was added to the OpenFlexure server code. This exposes a “moveMeasure” API which commands the stage to move to a position and then read the ADC (ADC is connected to RPi, it’s ADS 1115)

I’m updating post, I successful loaded the plugin to the openflexure server. I’ve made probably a mistake in plugin code, which is stage.py.

The issue is located on my GitHub, named “Sever plugin load success”, here is link: GitHub

I’ll be very grateful for your suggestions.

I don’t use the Python client myself, but the website instructions say "The library can be installed with pip install openflexure-microscope-client." are you running the Python client on the Pi controlling the stage, or from another computer?

I’m running the python on Raspberry Pi and I’m communicating with it from another computer.
In script which runs on Raspberry Pi I have a line: from openflexure_microscope.utilities import axes_to_array
which in my opinion requires ”openflexure-microscope” package.

Hi @pawel1010, the Python code for the microscope is split into two packages (and is not as well documented as I’d like, sorry!).

  • The server code (which runs on the Pi) is in a module called openflexure_microscope and is not published to PyPI, it’s just on GitLab and our build server. This code is not really intended for use outside of the microscope’s built-in Pi, and depends on things like the picamerax module which isn’t available on other platforms. I’d really like to have renamed the module to openflexure_microscope_server but for historical reasons we’ve not changed it. Maybe the next major release would be a good time to do that…
  • The client code is intended to be used in Python scripts that control the microscope. This is in a package called openflexure-microscope-client which installs a module called openflexure_microscope_client. It should not depend on the server package, and should run anywhere - it’s basically just an HTTP client.

I am not sure there’s an equivalent neatly packaged function in the Python client, but there is some code that does the same thing.

I’d really like to revamp the python client, perhaps another task for the next major version…

To be more clear, I wanted to run module on Raspberry: module

Which libraries require lines:

from openflexure_microscope.stage.base import BaseStage
from openflexure_microscope.utilities import axes_to_array

?
Do I have to install this: lib?
Are they already included in Raspbian-OpenFlexure system?

I am not an very familiar with the Python part of the microscope. Reading Richard’s post I think he is saying that openflexure_microscope is running the server on the Pi, so it is already there on the Pi. However I have a feeling that it may not be in the user space.

The library that you link at the end of your post is is an old library, all the current Microscope things are in the Openflexure GitLab space : OpenFlexure · GitLab

I figure out that my python program is a plugin.
I don’t know how to load python plugin to openflexure server, any suggestions?

Does any of this help? Extensions (openflexure.org)?