PyMoDAQ / pymodaq_plugins_thorlabs

Set of PyMoDAQ plugins for instruments from Thorlabs (Kinesis K10CR1 (stepper rotation actuator), Kinesis Flipper, Kinesis KSP100...)
MIT License
3 stars 27 forks source link

Problem loading a camera #4

Open LMSC-NTappy opened 2 years ago

LMSC-NTappy commented 2 years ago

Hello,

I am facing an error initialize a thorlabs camera. The Camera is correctly detected

...
[datetime] pymodaq.pymodaq.daq_viewer_main.Testing - INFO - Ready
[datetime] pymodaq.pymodaq.daq_viewer_main.Testing - INFO -   File "C:\Users\admin\.conda\envs\sp_dev\lib\site-packages  
\pymodaq_plugins_thorlabs\daq_viewer_plugins\plugins_2D\daq_2Dviewer_Thorlabs_DCx.py", line 91, in ini_detector
    self.settings.child('exposure').setValue(self.controller.exposure.m_as('ms'))
'UC480_Camera' object has no attribute 'exposure'
[datetime]pymodaq.pymodaq.daq_viewer_main.Testing - INFO - detector initialized: False

I think the fix might be as easy as replacing https://github.com/CEMES-CNRS/pymodaq_plugins_thorlabs/blob/5df60c9fea7b6f41546dd1b3ea8d3732d351e3e0/src/pymodaq_plugins_thorlabs/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Thorlabs_DCx.py#L91

and other similar instances such as

https://github.com/CEMES-CNRS/pymodaq_plugins_thorlabs/blob/5df60c9fea7b6f41546dd1b3ea8d3732d351e3e0/src/pymodaq_plugins_thorlabs/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Thorlabs_DCx.py#L54

by self.controller._get_exposure() and self.controller._set_exposure(Q_(...))

I am unable to submit a PR right now since I don't manage to get this plugin installed from source, see
CEMES-CNRS/PyMoDAQ#71 but I hope to get it right at some point lol

seb5g commented 2 years ago

Hello, for this plugin I'm using the package Instrumental that at the time was missing some functionalities. I did a PR from my fork but it seems it is not yet included in the official branch. You can therefore try to install Instrumental from :

https://github.com/CEMES-CNRS/Instrumental

see pip documentation on how to install from a git url!

However Instrumental also requires the thorlabs library to be processed once for the python code to work. If you cannot find how to do it, you can try to execute the module __builduc480.py: image

Let me know if it works

LMSC-NTappy commented 2 years ago

Hello,

Did you have success controlling the camera exposure time with your implementation?

I have checked mabuchilab/Instrumental#144 and in my opinion there is something broken beyond the missing exposure facet.

See mabuchilab/Instrumental#150

seb5g commented 2 years ago

Well I got that camera only for a short time to produce the new PID module and the video on it. I don't remember if I made it finally working but I think so. @quantumm is the owner of the camera, so maybe he can do some testing?

LMSC-NTappy commented 2 years ago

If he can, that'd be great!

In any case, I've opened #5 on the topic. For me it currently works so if @quantumm finds some time to test it'd be great

quantumm commented 2 years ago

Hello, I will try to do those tests but unfortunately for now it is difficult to find some time :/

quantumm commented 2 years ago

Hi,

I tried again to install the plugin to use a DCC camera with a fresh install of pymodaq (3.5.6). I was surprised to see that this issue is still not solved. It seems like something wrong happened during the merge of the PR #5 . Such call like controller.exposure should have been removed, which is not the case if you look at lign 91 in the current version of this file : https://github.com/CEMES-CNRS/pymodaq_plugins_thorlabs/blob/0.1.2/src/pymodaq_plugins_thorlabs/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Thorlabs_DCx.py

LMSC-NTappy commented 2 years ago

Hi @quantumm,

The merge is fine, the changes have just not been released in a new version of the plugin yet.

For now, you should still install from source the main branch of this PR to obtain theses fix

quantumm commented 2 years ago

Ah ok. Think I got it ;) Thanks.

seb5g commented 2 years ago

Do you think the modifications in the plugin are stable enough? If yes, I'll publish a new version of the plugin on pypi

Le lun. 11 avr. 2022 à 13:57, quantumm @.***> a écrit :

Ah ok. Think I got it ;) Thanks.

— Reply to this email directly, view it on GitHub https://github.com/CEMES-CNRS/pymodaq_plugins_thorlabs/issues/4#issuecomment-1094961147, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSNYIZR53TMPJTPJ6EQNC3VEQHTHANCNFSM5NBZPX5Q . You are receiving this because you commented.Message ID: @.***>

quantumm commented 2 years ago

I only tested the camera, not the other instruments, but it is fine for that part yes.

seb5g commented 2 years ago

I tested myself the new plugin for the TLPM powermeter but it depends on a release of instrumental-lib not yet out... I'd like to put requirements pointing on an archive file of the forked instrumental but could not find the solution yet, any idea? Could be also useful for other libraries where we write drivers that we then need in our plugins...

Le lun. 11 avr. 2022 à 14:25, quantumm @.***> a écrit :

I only tested the camera, not the other instruments, but it is fine for that part yes.

— Reply to this email directly, view it on GitHub https://github.com/CEMES-CNRS/pymodaq_plugins_thorlabs/issues/4#issuecomment-1094985845, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSNYI64IYNK2HT7KKT462LVEQKZ3ANCNFSM5NBZPX5Q . You are receiving this because you commented.Message ID: @.***>

LMSC-NTappy commented 2 years ago

I think this can be achieved directly from the install_requires if you have a clone of instrumental_lib on github that will reliably work for an extended period of time:

https://stackoverflow.com/questions/32688688/how-to-write-setup-py-to-include-a-git-repository-as-a-dependency

Cheers

Nicolas

seb5g commented 2 years ago

well yes, but this option requires git on your system and most windows user will not have it. I would rather try installing from an archive as:

pip install https://github.com/CEMES-CNRS/Instrumental/archive/refs/tags/cemes.0.6.tar.gz

This is working if you type it directly in the command line, but it does not if you place the url directly in the requirements...

seb5g commented 2 years ago

FOUND IT !!!

You have to put this in the requirements (in your plugin toml file):

[plugin-install]

packages required for your plugin:

packages-required = ["pythonnet", "pywin32", "nicelib", "instrumental-lib @ https://github.com/CEMES-CNRS/Instrumental/archive/refs/tags/cemes.0.6.tar.gz"]

so you can point directly to an archive file without need of git. You could also do it for your dependencies on pylablib also

seb5g commented 2 years ago

I will therefore publish a new version of thorlabs plugin including this requirement (until the new version of instrumental is published)

rgeneaux commented 2 years ago

Hi guys,

Just wanted to note that the new release of the plugin didn't get uploaded to pypi

( error in upload workflow)

" Invalid value for requires_dist. Error: Can't have direct dependency:  
         'instrumental-lib @ https://github.com/CEMES-CNRS/Instrumental/archive/
         refs/tags/cemes.0.6.tar.gz' 

so at the moment, it cannot be installed by the plugin manager. I was running into the camera exposure issue and it kind of drove me crazy until I noticed that I wasn't on the last release :-)

seb5g commented 2 years ago

Ok I reverted the requirements on instrumental-lib for the moment and published v 0.2.0 on pypi manually. I'm in the process of a push release on instrumental so should have the next release soon to make it all work.