Gears move great, positional errors abound

When I move x, y, or z position of the stage, the code goes into the following fit (started OFM server in debug mode via OFM serve CLI command). Any advice on getting right appreciated.:

INFO:root:Loading /home/pi/openflexure/settings/microscope_settings.json...
INFO:root:Loading /home/pi/openflexure/settings/microscope_settings.json...
INFO:root:Loading /home/pi/openflexure/settings/microscope_settings.json...
INFO:root:Loading /home/pi/openflexure/settings/microscope_settings.json...
INFO:root:Loading /home/pi/openflexure/settings/microscope_configuration.json...
INFO:root:Loading /home/pi/openflexure/settings/microscope_configuration.json...
WARNING:root:PiCameraStreamer.camera is deprecated. Replace with PiCameraStreamer.picamera
WARNING:root:PiCamera.lens_shading_table returned as None
INFO:root:Loading /home/pi/openflexure/settings/microscope_settings.json...
ERROR:root:Traceback (most recent call last):
  File "/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/labthings/actions/thread.py", line 255, in wrapped
    self._return_value = f(*args, **kwargs)
  File "/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/flask/ctx.py", line 158, in wrapper
    return func(*args, **kwargs)
  File "/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/api/v2/views/actions/stage.py", line 49, in post
    return microscope.state["stage"]["position"]
  File "/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/microscope.py", line 209, in state
    return {"camera": self.camera.state, "stage": self.stage.state}
  File "/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/stage/sanga.py", line 55, in state
    return {"position": self.position_map}
  File "/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/stage/base.py", line 51, in position_map
    return {"x": self.position[0], "y": self.position[1], "z": self.position[2]}
  File "/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/stage/sanga.py", line 72, in position
    return self.board.position
  File "/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/sangaboard/extensible_serial_instrument.py", line 484, in __get__
    value = obj.parsed_query(self.get_cmd, self.response_string)
  File "/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/sangaboard/extensible_serial_instrument.py", line 305, in parsed_query
    % (query_string, original_reply, response_string, response_regex)
ValueError: Stage response to 'p?' ('step: 2') wasn't matched by /%d %d %d/ (generated regex /([-+]?\d+) ([-+]?\d+) ([-+]?\d+)/)

Exception in thread Thread-67:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/labthings/actions/thread.py", line 224, in run
    self._thread_proc(self._target)(*self._args, **self._kwargs)
  File "/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/labthings/actions/thread.py", line 277, in wrapped
    raise e
  File "/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/labthings/actions/thread.py", line 255, in wrapped  
  self._return_value = f(*args, **kwargs)
  File "/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/flask/ctx.py", line 158, in wrapper
    return f(*args, **kwargs)
  File "/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/webargs/core.py", line 450, in wrapper
    return func(*args, **kwargs)
  File "/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/api/v2/views/actions/stage.py", line 49, in post
    return microscope.state["stage"]["position"]
  File "/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/microscope.py", line 209, in state
    return {"camera": self.camera.state, "stage": self.stage.state}
  File "/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/stage/sanga.py", line 55, in state
    return {"position": self.position_map}
  File "/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/stage/base.py", line 51, in position_map
    return {"x": self.position[0], "y": self.position[1], "z": self.position[2]}
  File "/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/stage/sanga.py", line 72, in position
    return self.board.position
  File "/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/sangaboard/extensible_serial_instrument.py", line 484, in __get__
    value = obj.parsed_query(self.get_cmd, self.response_string)
  File "/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/sangaboard/extensible_serial_instrument.py", line 305, in parsed_query
    % (query_string, original_reply, response_string, response_regex)
ValueError: Stage response to 'p?' ('step: 2') wasn't matched by /%d %d %d/ (generated regex /([-+]?\d+) ([-+]?\d+) ([-+]?\d+)/)

ERROR:root:Stage response to 'p?' ('--> in stepMotor.  This step: 1') wasn't matched by /%d %d %d/ (generated regex /([-+]?\d+) ([-+]?\d+) ([-+]?\d+)/)

As I wait for help, I’ve been attempting to debug.

As the stage is calibrating x (initial calibration steps). x starts moving, so movement is detected. However, on a random? movement extensible_serial_printer returns Stage response to ‘p?’ (‘This step: 7’) wasn’t matched by /%d %d %d/ , And yes, that is true, for some reason a call to sangaboard.board.position returns weird stuff like ‘This step: 7’ instead of a position like [0,0,0]. Help would be truly appreciated. Thank you.

So I was thinking this is a buffer overflow? The (com) stream between the Nano and the Rasp Pi filling up too fast and flowing over?

I was using a clone Nano. I had a Nano Every lying around and switched. Doesn’t fix the problem. Help needed and appreciated. Thank you.

on the plus side, I was able to manually focus. This is a sample of my plant’s soil. Be awesome if video because you’d be able to see the microbes moving about and living their life. So busy no Facebook/Twitter concerns…ah…the life of a microbe… Makes me wish I could control it with a joystick!

1 Like

I cannot help with the error log, but that is a nice clear picture. You have got the illumination well aligned and the camera calibration has worked well.

One of my many stock answers to odd software issues is “have you tried re-installing the Pi from a fresh SD image?”

Thank you for the reply @WilliamW re:

One of my many stock answers to odd software issues is “have you tried re-installing the Pi from a fresh SD image?”

3 times.

I’d be most grateful if there was someone who could look at the Traceback and tell why the board position info comes back as (buffer) text instead of a position [0 0 0]. This scenario is completely reproducible.

re:

nice clear picture

Thank you! I “manually” adjusted the axes (mostly the z). It was extremely exciting!!!

Ah…but yet…the golden egg…so elusive…auto adjustment…sadly…so utterly sadly…eludes me.

Thank you.

1 Like

I think it is my stupidity. Which I apologize for - but for me kinda sad to have this stupid feature. Anyways, I had embedded Serial.println() in sangaboard.ino during tests…this came through the com port.

1 Like

That would do it, and will have been a real pain for you to find. Well done for persevering, and thank you for documenting your problems here to help others.

With open code it is not so easy to make things robust against changes like that. The main route to sorting that out will be when someone is able to sell the complete motor driver Sangaboard, which would be able to have the firmware pre-installed.