libfidl.py
def approach_detected(self):
        """
            Function to determin if something is approaching the Sensor
            This use linear regression to approximate the approaching speed

            :return type: boolean
        """
        if any([None in pt for pt in self.measurements]): #TODO fix that somehow
            #Not enough critical data was gethered
            return False

        #using linear regression to determine an approach
        x = [pt[0] for pt in self.measurements]
        x_mean = round(sum(x) / len(x), 2)
        y = [pt[1] for pt in self.measurements]
        y_mean = round(sum(y) / len(y), 2)

        #slope is equivalent to the approaching speed
        speed = round(sum([(pt[0] - x_mean)*(pt[1] - y_mean) for pt in self.measurements])/sum([(x-x_mean)**2 for x in x]),2)

        #threshould is an approaching speed of 30cm per second 
        if speed <= -30:
            return True

        #no approach
        return False

            Function to determin if something is approaching the Sensor
            This use linear regression to approximate the approaching speed

            :return type: boolean
        
Function to determin if something is approaching the Sensor
This use linear regression to approximate the approaching speed
Function to determin if something is approaching the Sensor This use linear regression to approximate the approaching speed
def approach_detected(self):
        if any([None in pt for pt in self.measurements]): 
            return False
        x = [pt[0] for pt in self.measurements]
        x_mean = round(sum(x) / len(x), 2)
        y = [pt[1] for pt in self.measurements]
        y_mean = round(sum(y) / len(y), 2)
        speed = round(sum([(pt[0] - x_mean)*(pt[1] - y_mean) for pt in self.measurements])/sum([(x-x_mean)**2 for x in x]),2)
        if speed <= -30:
            return True
        return False
def approach_detected ( self ) : if any ( [ None in pt for pt in self . measurements ] ) : return False x = [ pt [ 0 ] for pt in self . measurements ] x_mean = round ( sum ( x ) / len ( x ) , 2 ) y = [ pt [ 1 ] for pt in self . measurements ] y_mean = round ( sum ( y ) / len ( y ) , 2 ) speed = round ( sum ( [ ( pt [ 0 ] - x_mean ) * ( pt [ 1 ] - y_mean ) for pt in self . measurements ] ) / sum ( [ ( x - x_mean ) ** 2 for x in x ] ) , 2 ) if speed <= - 30 : return True return False
Function to determin if something is approaching the Sensor
This use linear regression to approximate the approaching speed
Function to determin if something is approaching the Sensor This use linear regression to approximate the approaching speed
"""
            Function to determin if something is approaching the Sensor
            This use linear regression to approximate the approaching speed

            :return type: boolean
        """ #TODO fix that somehow #Not enough critical data was gethered #using linear regression to determine an approach #slope is equivalent to the approaching speed #threshould is an approaching speed of 30cm per second  #no approach
None
type
self