reader.py 810 Bytes
Newer Older
1
class Reader:
2
    # reader class for getting data from the robot and passing to ROS
3 4 5 6 7 8 9 10 11 12 13
    def __init__(self, name, p):
        # constructor for settings class
        self.probes = p
        self.name = name
        self.queue = {}
        for label in p:
            self.queue[label] = 0

    def run(self, data):
        ## Publish data
        self.pub.publish(data)
14

15 16
    def add(name, val):
        # add data piece
17
        try:
18 19 20 21
            if name in self.probes:
                self.queue[name] = val
            else:
                pass
22 23
        except Exception as e:
            raise e
24

25 26 27 28 29 30 31
    def needs(name):
        # check if name is used by this class
        return True if name in self.probes else False

    def get_probes():
        # return an array of all probes
        return self.probes