Ejemplo n.º 1
0
class Location3State(State):
    def __init__(self):
        State.__init__(self, outcomes=['ok', 'match', 'err'], input_keys=['green_shape'])
        self.feature_detector = FeatureDetector()

    def execute(self, ud):
        try:
            features = self.feature_detector.get_features()
            features = [f for f in features if f.colour == 'red']
            features = filter_by_distance(features, 1.)
            depths = feature_depths(features)
            feature = next((f for i, f in enumerate(features) if depths[i] == min(depths)), None)

            if feature is None:
                return 'err'

            print(feature.shape)

            if feature.shape == ud.green_shape:
                notify_match()
                return 'match'

            return 'ok'
        except Exception, e:
            print(e)
            return 'err'
class Location1State(State):
    def __init__(self):
        State.__init__(self, outcomes=['ok'])
        self.feature_detector = FeatureDetector()

    def execute(self, ud):
        features = self.feature_detector.get_features()
        features = [f for f in features if f.colour == 'red']
        features = filter_by_distance(features, max_distance=1.)
        notify_count(len(features))

        return 'ok'
Ejemplo n.º 3
0
class Location2State(State):
    def __init__(self, ud):
        State.__init__(self, outcomes=['ok'])
        self.feature_detector = FeatureDetector()
        self.ud = ud

    def execute(self, ud):
        features = self.feature_detector.get_features()
        green_shape = next(f.shape for f in features if f.colour == 'green')
        self.ud.green_shape = green_shape
        notify_count(len(features))
        print(self.ud.green_shape)

        return 'ok'
class Location3State(State):
    def __init__(self, ud):
        State.__init__(self, outcomes=['ok'])
        self.feature_detector = FeatureDetector()
        self.ud = ud

    def execute(self, ud):
        features = self.feature_detector.get_features()
        features = [f for f in features if f.colour == 'red']
        features = filter_by_distance(features, 1.)
        depths = feature_depths(features)
        feature = next(f for i, f in enumerate(features) if depths[i] == min(depths))
        # feature = select_center(features)
        if feature.shape == self.ud.green_shape:
            notify_match()

        print(feature.shape)

        return 'ok'
Ejemplo n.º 5
0
class Location2State(State):
    def __init__(self):
        State.__init__(self,
                       outcomes=['ok', 'err'],
                       output_keys=['green_shape'])
        self.feature_detector = FeatureDetector()

    def execute(self, ud):
        try:
            features = self.feature_detector.get_features()
            green_shape = next(f.shape for f in features
                               if f.colour == 'green')
            ud.green_shape = green_shape
            notify_count(len(features))
            print(green_shape)
            return 'ok'
        except Exception, e:
            print(e)
            ud.green_shape = None
            return 'err'
 def __init__(self):
     State.__init__(self, outcomes=['ok'])
     self.feature_detector = FeatureDetector()
Ejemplo n.º 7
0
 def __init__(self):
     State.__init__(self, outcomes=['ok', 'match', 'err'], input_keys=['green_shape'])
     self.feature_detector = FeatureDetector()