-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: Quantities in DictFeat #35
Comments
This is something that we need to resolve in a more general way. The following things need to be considered:
In this context, consider an hypothetical instrument that can change the position with the command # Position has cm units by default
>>> print(inst.position)
0 centimeter
>>> inst.position = Q_(1, 'cm')
# Transmitted to the instrument as POS 1 (meaning 1 centimeter)
>>> inst.units = 'mm'
>>> inst.position = Q_(1, 'cm')
# Transmitted to the instrument as POS 10 (meaning 10 millimeter) But your case is a different one which only applies to 'dimensionless' feats. I say dimensionless (in quotes) because even if you are changing a physical magnitude the API will be dimensionless because the units might:
So the program would look like: >>> print(inst.position)
0
>>> inst.position = 1
# Transmitted to the instrument as POS 1 (meaning 1 centimeter)
>>> inst.units = 'encodercount'
>>> inst.position = 1
# Transmitted to the instrument as POS 1 (meaning 1 encodercount) There is no proper and easy way (that I can think of) to have units in this type of # Position has cm units by default
>>> print(inst.position)
0 centimeter
>>> inst.position = Q_(1, 'cm')
# Transmitted to the instrument as POS 1 (meaning 1 centimeter)
>>> inst.units = 'encodercount'
>>> inst.position = Q_(1, 'cm')
# What should it do???? The only way will be to define a context attached to the Feat to teach non specific unit conversions. The way I have used in the past to deal with something like this was defining only certain units for the Feat (millimeter, inch, etc). And if really need radians or encodercount I define other feats. It is not nice but it works. Going back to your question. If you are NOT going to relate to a Feat, the best way is to use string instead of Quantities. (Additionally, quantities might not be a good idea as "2 meters" and "1 meter" will be different keys even though is the same unit. |
This is a long standing open issue. I came across it when using an newport motion controller, which can have several axis connected. Depending on the connected motion device, it can use different units (radian for rotational devices). It would be nice if Lantz could automatically determine the kind of motion device and set the relevant units. |
I have implemented the ability to set the units of feats after creation of the object: https://github.com/vascotenner/lantz/tree/drivers_developv |
I have a device that returns the unit that is used in the device. This given as a number, and should be converted in a quatitity. I also can set this unit. The logical way would be to use a DictFeat. However, to do this one should make a dict, which does not work with Quantities objects:
Furthermore I want to use this unit as default unit for all my functions in my driver. Is there an easy somultion
The text was updated successfully, but these errors were encountered: