Skip to content

Draft: axis: Normalize low limit as lower than high limit

Valentin Valls requested to merge normalize-user-limits into master

Closes #4449

Normalize the user limit to return consistent values -> limits[0] <= limits[1].

Basically the user unit is an abstraction. With the user API we should not notice any difference if a motor is setup with sign 1, and a sign -1. Else it's not an abstraction.

axis1.dial_limits = -100, 0
axis1.sign = -1

axis2.dial_limits = 0, 100
axis2.sign = 1

axis1.limits == axis2.limits   <- by definition

I have reworked the stuff assuming dial limits are properly ordered.

But we can see in the code there is no check at all.

There is no way to trust input which can be set by people.

def dial_limits(self, limits):
    # So it would be better to check here the order of the `limits`
    # Raise an exception
    #                    or hiddenly reorder it

def low_limit(self, limit):
def high_limit(self, limit):
    # Same for this 2 functions
    # And in my opinion, this 2 setter should be dropped, this open too much potential problems
    # that only can be resolved by the caller.

Merge request reports

Loading