Esempio n. 1
0
class AIDrive:
    """
    A class to interface with the Neural Net which captures data from
    the ZED STEREO VISION camera and then calls the SocketServer for
    sending that information to the VESC.
    """
    def __init__(self):
        self.model_name = "models/30epoch_depthrgb.hdf5"
        self.throttle = 0.0
        self.image_size = 250

        self.throttle = 0.0
        self.steering = 0.0

        self.comms = CommServerS()

        self.capture = Capture(self.model_name)

        print("[INFO] AI Neural Net is firing!")

    def run(self):
        # get image from camera
        img = self.capture.capture_image(self.image_size)

        # get steering value from the NN
        self.steering = self.capture.evaluate_one(img)

        # send values over UDP socket.
        self.comms.send(self.throttle, self.steering)

    def generate(self):
        while (1):
            self.run()