Example #1
0
class PTMotorsClient:
    def __init__(self,ic,prefix, start = False):
        self.motors = PTMotors(ic,prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.motors, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()

    # if client is stopped you can not start again, Threading.Thread raised error
    def start(self):
        self.kill_event.clear()
        self.thread.start()

    # if client is stopped you can not start again
    def stop(self):
        self.kill_event.set()

    def getLimits(self):
        return self.motors.getLimits()

    def hasproxy():
        return self.motors.hasproxy()

    def setPTMotorsData(self, pan, tilt, panspeed, tiltspeed):
        self.motors.setPTMotorsData(pan, tilt, panspeed, tiltspeed)
Example #2
0
    def __init__(self, camera):
        self.lock = threading.Lock()
        self.client = camera

        self.height = self.client.getHeight()
        self.width = self.client.getWidth()

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self, self.kill_event)
        self.thread.daemon = True

        rgbfilter = RgbFilter()
        hsvfilter = HsvFilter()
        yuvfilter = YuvFilter()

        self.filters = {RGB: rgbfilter, YUV: yuvfilter, HSV: hsvfilter}

        if self.client.hasproxy():

            trackImage = np.zeros((self.height, self.width, 3), np.uint8)
            trackImage.shape = self.height, self.width, 3

            self.images = {
                ORIG: trackImage,
                RGB: trackImage,
                HSV: trackImage,
                YUV: trackImage
            }

            self.kill_event.clear()
            self.thread.start()
Example #3
0
class CameraClient:
    def __init__(self, ic, prefix, start=False):
        self.camera = Camera(ic, prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.camera, self.kill_event)
        #self.thread = ThreadSensor(self.camera)
        self.thread.daemon = True

        if start:
            self.start()

    # if client is stopped you can not start again, Threading.Thread raised error
    def start(self):
        self.kill_event.clear()
        self.thread.start()

    # if client is stopped you can not start again
    def stop(self):
        self.kill_event.set()

    def getImage(self):
        return self.camera.getImage()

    def getHeight(self):
        return self.camera.getHeight()

    def getWidth(self):
        return self.camera.getWidth()

    def hasproxy(self):
        return self.camera.hasproxy()
Example #4
0
class CameraClient:
    def __init__(self,ic,prefix, start = False):
        self.camera = Camera(ic,prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.camera, self.kill_event)
        #self.thread = ThreadSensor(self.camera)
        self.thread.daemon = True

        if start:
            self.start()

    # if client is stopped you can not start again, Threading.Thread raised error
    def start(self):
        self.kill_event.clear()
        self.thread.start()

    # if client is stopped you can not start again
    def stop(self):
        self.kill_event.set()

    def getImage(self):
        return self.camera.getImage()

    def getHeight(self):
        return self.camera.getHeight()

    def getWidth(self):
        return self.camera.getWidth()

    def hasproxy (self):
        return self.camera.hasproxy()
Example #5
0
class PTMotorsClient:
    def __init__(self, ic, prefix, start=False):
        self.motors = PTMotors(ic, prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.motors, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()

    # if client is stopped you can not start again, Threading.Thread raised error
    def start(self):
        self.kill_event.clear()
        self.thread.start()

    # if client is stopped you can not start again
    def stop(self):
        self.kill_event.set()

    def getLimits(self):
        return self.motors.getLimits()

    def hasproxy():
        return self.motors.hasproxy()

    def setPTMotorsData(self, pan, tilt, panspeed, tiltspeed):
        self.motors.setPTMotorsData(pan, tilt, panspeed, tiltspeed)
Example #6
0
    def __init__(self,ic,prefix, start = False):
        self.pose3d = Pose3D(ic,prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.pose3d, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()
Example #7
0
    def __init__(self, ic, prefix, start=False):
        self.motors = PTMotors(ic, prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.motors, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()
    def __init__(self, ic, prefix, start=False):
        self.navdata = NavData(ic, prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.navdata, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()
Example #9
0
    def __init__(self, ic, prefix, start=False):
        self.bumper = Bumper(ic, prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.bumper, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()
Example #10
0
    def __init__(self, ic, prefix, start=False):
        self.camera = Camera(ic, prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.camera, self.kill_event)
        #self.thread = ThreadSensor(self.camera)
        self.thread.daemon = True

        if start:
            self.start()
Example #11
0
class Sensor(threading.Thread):
    def __init__(self, grid, pose3d, start):
        self.grid = grid
        self.pose3d = pose3d
        if self.pose3d.hasproxy():
            self.grid.initPose(self.pose3d.getPose3d().x,
                               self.pose3d.getPose3d().y,
                               self.pose3d.getPose3d().yaw)
        else:
            self.grid.initPose(0, 0, 0)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()

    # if client is stopped you can not start again, Threading.Thread raised error
    def start(self):
        self.kill_event.clear()
        self.thread.start()

    # if client is stopped you can not start again
    def stop(self):
        self.kill_event.set()

    def update(self):
        if self.pose3d.hasproxy():
            self.pose3d.pose3d.update()
            self.grid.updatePose(self.pose3d.getPose3d().x,
                                 self.pose3d.getPose3d().y,
                                 self.pose3d.getPose3d().yaw)

    def setGetPathSignal(self, signal):
        self.getPathSig = signal

    def getPose3D(self):
        if self.pose3d.hasproxy():
            return self.pose3d.getPose3d()

    def getRobotX(self):
        if self.pose3d.hasproxy():
            return self.pose3d.getPose3d().x

    def getRobotY(self):
        if self.pose3d.hasproxy():
            return self.pose3d.getPose3d().y

    def getRobotTheta(self):
        if self.pose3d.hasproxy():
            return self.pose3d.getPose3d().yaw
Example #12
0
class Sensor(threading.Thread):

    def __init__(self, grid, pose3d, start):
        self.grid = grid
        self.pose3d = pose3d
        if self.pose3d.hasproxy():
            self.grid.initPose(self.pose3d.getX(), self.pose3d.getY(), self.pose3d.getYaw())
        else:
            self.grid.initPose(0, 0, 0)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()

    # if client is stopped you can not start again, Threading.Thread raised error
    def start(self):
        self.kill_event.clear()
        self.thread.start()

    # if client is stopped you can not start again
    def stop(self):
        self.kill_event.set()


    def update(self):
        if self.pose3d.hasproxy():
            self.pose3d.update()
            self.grid.updatePose(self.pose3d.getX(), self.pose3d.getY(), self.pose3d.getYaw())

        
    def setGetPathSignal(self, signal):
        self.getPathSig = signal


    def getPose3D(self):
        if self.pose3d.hasproxy():
            return self.pose3d.getPose3D()

    def getRobotX(self):
        if self.pose3d.hasproxy():
            return self.pose3d.getX()

    def getRobotY(self):
        if self.pose3d.hasproxy():
            return self.pose3d.getY()

    def getRobotTheta(self):
        if self.pose3d.hasproxy():
            return self.pose3d.Yaw()    
Example #13
0
    def __init__(self, grid, pose3d, start):
        self.grid = grid
        self.pose3d = pose3d
        if self.pose3d.hasproxy():
            self.grid.initPose(self.pose3d.getX(), self.pose3d.getY(),
                               self.pose3d.getYaw())
        else:
            self.grid.initPose(0, 0, 0)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()
Example #14
0
    def __init__(self, camera):
        self.lock = threading.Lock()
        self.client = camera

        self.height= self.client.getHeight()
        self.width = self.client.getWidth()


        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self, self.kill_event)
        self.thread.daemon = True

        rgbfilter = RgbFilter()
        hsvfilter =  HsvFilter()
        yuvfilter = YuvFilter()

        self.filters = {RGB:rgbfilter, YUV:yuvfilter, HSV: hsvfilter}


        if self.client.hasproxy():
             
            trackImage = np.zeros((self.height, self.width,3), np.uint8)
            trackImage.shape = self.height, self.width, 3

            self.images = {ORIG: trackImage, RGB: trackImage, HSV: trackImage, YUV: trackImage} 

            self.kill_event.clear()
            self.thread.start()
Example #15
0
    def __init__(self,ic,prefix, start = False):
        self.motors = PTMotors(ic,prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.motors, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()
Example #16
0
    def __init__(self,ic,prefix, start = False):
        self.navdata = NavData(ic,prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.navdata, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()
Example #17
0
    def __init__(self,ic,prefix, start = False):
        self.laser = Laser(ic,prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.laser, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()
Example #18
0
    def __init__(self,ic,prefix, start = False):
        self.camera = Camera(ic,prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.camera, self.kill_event)
        #self.thread = ThreadSensor(self.camera)
        self.thread.daemon = True

        if start:
            self.start()
Example #19
0
class Pose3DClient:
    def __init__(self,ic,prefix, start = False):
        self.pose3d = Pose3D(ic,prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.pose3d, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()

    # if client is stopped you can not start again, Threading.Thread raised error
    def start(self):
        self.kill_event.clear()
        self.thread.start()

    # if client is stopped you can not start again
    def stop(self):
        self.kill_event.set()

    def getPose3D(self):
        return self.pose3d.getPose3D()

    def getX (self):
        return self.pose3d.getX()

    def getY (self):
        return self.pose3d.getY()

    def getZ (self):
        return self.pose3d.getZ()

    def getYaw (self):
        return self.pose3d.getYaw()

    def getPitch (self):
        return self.pose3d.getPitch()

    def getRoll (self):
        return self.pose3d.getRoll()
Example #20
0
class LaserClient:
    def __init__(self,ic,prefix, start = False):
        self.laser = Laser(ic,prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.laser, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()

    # if client is stopped you can not start again, Threading.Thread raised error
    def start(self):
        self.kill_event.clear()
        self.thread.start()

    # if client is stopped you can not start again
    def stop(self):
        self.kill_event.set()

    def getLaserData(self):
        return self.laser.getLaserData()
class NavDataClient:
    def __init__(self, ic, prefix, start=False):
        self.navdata = NavData(ic, prefix)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self.navdata, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()

    # if client is stopped you can not start again, Threading.Thread raised error
    def start(self):
        self.kill_event.clear()
        self.thread.start()

    # if client is stopped you can not start again
    def stop(self):
        self.kill_event.set()

    def getNavdata(self):
        return self.navdata.getNavdata()
Example #22
0
    def __init__(self, grid, pose3d, start):
        self.grid = grid
        self.pose3d = pose3d
        if self.pose3d.hasproxy():
            self.grid.initPose(self.pose3d.getX(), self.pose3d.getY(), self.pose3d.getYaw())
        else:
            self.grid.initPose(0, 0, 0)

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self, self.kill_event)
        self.thread.daemon = True

        if start:
            self.start()
Example #23
0
class CameraFilter:

    def __init__(self, camera):
        self.lock = threading.Lock()
        self.client = camera

        self.height= self.client.getHeight()
        self.width = self.client.getWidth()


        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self, self.kill_event)
        self.thread.daemon = True

        rgbfilter = RgbFilter()
        hsvfilter =  HsvFilter()
        yuvfilter = YuvFilter()

        self.filters = {RGB:rgbfilter, YUV:yuvfilter, HSV: hsvfilter}


        if self.client.hasproxy():
             
            trackImage = np.zeros((self.height, self.width,3), np.uint8)
            trackImage.shape = self.height, self.width, 3

            self.images = {ORIG: trackImage, RGB: trackImage, HSV: trackImage, YUV: trackImage} 

            self.kill_event.clear()
            self.thread.start()


    # if client is stopped you can not start again, Threading.Thread raised error
    def stop(self):
        self.kill_event.set()
        self.client.stop()
    
    
    def getImage(self):
        return getOrigImage()

    
    def getFilteredImage(self, filt):
        if self.client.hasproxy():
            img = np.zeros((self.height, self.width,3), np.uint8)
            self.lock.acquire()
            img = self.images[filt]
            img.shape = self.images[filt].shape
            self.lock.release()
            return img
        return None

    def getOrigImage(self):
        return self.getFilteredImage(ORIG)

    def getHSVImage (self):
        return self.getFilteredImage(HSV)

    def getRGBImage (self):
        return self.getFilteredImage(RGB)

    def getYUVImage (self):
        return self.getFilteredImage(YUV)


    def update(self):
        img = self.client.getImage()
        rgb = self.getFilter(RGB).apply(img)
        hsv = self.getFilter(HSV).apply(img)
        yuv = self.getFilter(YUV).apply(img)

        self.lock.acquire()
        self.images[ORIG] = img
        self.images[RGB] = rgb
        self.images[HSV] = hsv
        self.images[YUV] = yuv
        self.lock.release()



    def getFilter (self, name):
        return self.filters[name]
Example #24
0
class CameraFilter:
    def __init__(self, camera):
        self.lock = threading.Lock()
        self.client = camera

        self.height = self.client.getHeight()
        self.width = self.client.getWidth()

        self.kill_event = threading.Event()
        self.thread = ThreadSensor(self, self.kill_event)
        self.thread.daemon = True

        rgbfilter = RgbFilter()
        hsvfilter = HsvFilter()
        yuvfilter = YuvFilter()

        self.filters = {RGB: rgbfilter, YUV: yuvfilter, HSV: hsvfilter}

        if self.client.hasproxy():

            trackImage = np.zeros((self.height, self.width, 3), np.uint8)
            trackImage.shape = self.height, self.width, 3

            self.images = {
                ORIG: trackImage,
                RGB: trackImage,
                HSV: trackImage,
                YUV: trackImage
            }

            self.kill_event.clear()
            self.thread.start()

    # if client is stopped you can not start again, Threading.Thread raised error
    def stop(self):
        self.kill_event.set()
        self.client.stop()

    def getImage(self):
        return getOrigImage()

    def getFilteredImage(self, filt):
        if self.client.hasproxy():
            img = np.zeros((self.height, self.width, 3), np.uint8)
            self.lock.acquire()
            img = self.images[filt]
            img.shape = self.images[filt].shape
            self.lock.release()
            return img
        return None

    def getOrigImage(self):
        return self.getFilteredImage(ORIG)

    def getHSVImage(self):
        return self.getFilteredImage(HSV)

    def getRGBImage(self):
        return self.getFilteredImage(RGB)

    def getYUVImage(self):
        return self.getFilteredImage(YUV)

    def update(self):
        img = self.client.getImage()
        rgb = self.getFilter(RGB).apply(img)
        hsv = self.getFilter(HSV).apply(img)
        yuv = self.getFilter(YUV).apply(img)

        self.lock.acquire()
        self.images[ORIG] = img
        self.images[RGB] = rgb
        self.images[HSV] = hsv
        self.images[YUV] = yuv
        self.lock.release()

    def getFilter(self, name):
        return self.filters[name]