Exemple #1
0
    def __initSensors__(self):
        """
        Initialized sensors and data packets to be ran in the run loop.
        :return:
        """
        if platform.platform(
        ) == 'Linux-3.10.96-aarch64-with-Ubuntu-16.04-xenial':
            self.computerVisionProcess.start()
            pass
        else:
            self.computerVisionConnected = False

        try:
            self.killSwitchSerial = serial.Serial("/dev/ttyACM0", 9600)
        except:
            print "Unable to connect to Kill Switch"

        if useMaestro:
            try:
                self.maestroSerial = serial.Serial("/dev/ttyACM1", 9600)
            except:
                print "Unable to connect to Maestro"
        else:
            pass

        if False:
            try:
                self.arduinoSerial = serial.Serial("/dev/ttyACM2", 9600)
                self.pressureArduinoDataPackets = pressureArduino.pressureResponse(
                    self.arduinoSerial)
                self.pressureArduinoDataPackets.start()
            except:
                print "Unable to connect to Arduino for pressure"
        else:
            pass

        if False:
            try:
                self.arduinoDisplaySerial = serial.Serial(
                    "/dev/ttyACM3", 115200)
                self.arduinoDisplayDataPackets = displayArduino.displayArduino(
                    self.arduinoDisplaySerial)
            except:
                print "Unable to connect to Arduino for display"
        else:
            pass

        # DVL initialization
        try:
            DVLComPort = serial.Serial("/dev/ttyUSB10", 115200)
            self.dvlDataPackets = dvl.DVLDataPackets(DVLComPort)
            self.dvlResponseThread = dvl.DVLResponse(DVLComPort)
            self.dvlResponseThread.start()

            dvlAhrsComPort = serial.Serial("/dev/ttyUSB1", 38400)
            self.dvlAhrsDummyThread = dvl.AHRSDummyCommunicator(dvlAhrsComPort)
            self.dvlAhrsDummyThread.start()
        except:
            print "Unable to connect to DVL"

        try:
            # AHRS initializing
            # Need to put the correct comm ports in
            self.spartonResponseThread1 = sparton_ahrs.SpartonAhrsResponse(
                "/dev/ttyUSB5")
            self.spartonResponseThread1.start()

        except:
            print "Unable to connect to AHRS1"

        try:
            self.spartonResponseThread2 = sparton_ahrs.SpartonAhrsResponse(
                "/dev/ttyUSB4")
            self.spartonResponseThread2.start()

        except:
            print "Unable to connect to AHRS2"

        try:
            self.spartonResponseThread3 = sparton_ahrs.SpartonAhrsResponse(
                "/dev/ttyUSB6")
            self.spartonResponseThread3.start()

        except:
            print "Unable to connect to AHRS3"

        try:
            self.motherSerial = serial.Serial("/dev/ttyUSB0", 9600)
            self.motherPackets = motherboard.motherBoardDataPackets(
                self.motherSerial)

            self.motherResponseThread = motherboard.motherBoardResponse(
                self.motherSerial)
            self.motherResponseThread.start()
        except:
            print "Unable to connect to Mother Board"
        '''
Exemple #2
0
    def __initSensors__(self):
        """
        Initialized sensors and data packets to be ran in the run loop.
        :return:
        """
        if platform.platform(
        ) == 'Linux-4.4.15-aarch64-with-Ubuntu-16.04-xenial':
            self.computerVisionProcess.start()
            pass
        else:
            self.computerVisionConnected = False
        if False:
            try:
                self.killSwitchSerial = serial.Serial("/dev/ttyACM9", 9600)
            except:
                print "Unable to connect to Kill Switch"
        '''if useMaestro:
            try:
                self.maestroSerial = serial.Serial("/dev/ttyACM2", 9600)
                pass
            except:
                print "Unable to connect to Maestro"
        else:
            pass'''

        try:
            maestroPort = None
            available_ports = lp.comports()
            for port in available_ports:
                description = str(port[1])

                if description.startswith("Pololu"):
                    if maestroPort == None:
                        maestroPort = port[0]
                    elif (int(port[0][-1:]) < int(maestroPort[-1:])):
                        maestroPort = port[0]
            self.maestroSerial = serial.Serial(maestroPort, 9600)
        except:
            self.maestroSerial = serial.Serial("/dev/ttyACM0", 9600)
            print "Maestro was not found"

        if True:
            try:
                self.arduinoSerial = serial.Serial("/dev/ttyACM3", 9600)
                self.pressureArduinoDataPackets = pressureArduino.pressureResponse(
                    self.arduinoSerial)
                self.pressureArduinoDataPackets.start()
            except:
                print "Unable to connect to Arduino for pressure"
        else:
            pass

        if False:
            try:
                self.arduinoDisplaySerial = serial.Serial(
                    "/dev/ttyACM8", 115200)
                self.arduinoDisplayDataPackets = displayArduino.displayArduino(
                    self.arduinoDisplaySerial)
            except:
                print "Unable to connect to Arduino for display"
        else:
            pass

        # DVL initialization
        try:

            DVLComPort = serial.Serial("/dev/ttyUSB5", 115200)
            self.dvlDataPackets = dvl.DVLDataPackets(DVLComPort)
            self.dvlResponseThread = dvl.DVLResponse(DVLComPort)
            self.dvlResponseThread.start()

            dvlAhrsComPort = serial.Serial("/dev/ttyUSB6", 38400)
            self.dvlAhrsDummyThread = dvl.AHRSDummyCommunicator(dvlAhrsComPort)
            self.dvlAhrsDummyThread.start()

        except:
            print "Unable to connect to DVL"

        try:
            # AHRS initializing
            # Need to put the correct comm ports in
            self.spartonResponseThread1 = sparton_ahrs.SpartonAhrsResponse(
                "/dev/ttyUSB3")
            self.spartonResponseThread1.start()

        except:
            print "Unable to connect to AHRS1"

        try:
            pass
            #self.spartonResponseThread2 = sparton_ahrs.SpartonAhrsResponse("/dev/ttyUSB6")
            #self.spartonResponseThread2.start()

        except:
            print "Unable to connect to AHRS2"

        try:
            pass
        #self.spartonResponseThread3 = sparton_ahrs.SpartonAhrsResponse("/dev/ttyUSB1")
        #self.spartonResponseThread3.start()

        except:
            print "Unable to connect to AHRS3"

        try:

            self.motherSerial = serial.Serial("/dev/ttyUSB0", 9600)
            self.motherPackets = motherboard.motherBoardDataPackets(
                self.motherSerial)

            self.motherResponseThread = motherboard.motherBoardResponse(
                self.motherSerial)
            self.motherResponseThread.start()

        except:
            print "Unable to connect to Mother Board"

#Pitch
        try:
            pass
            #self.hydrasSerial1 = serial.Serial("/dev/ttyUSB2", 115200)
            #self.hydrasResponseThread1 = hydrasBoard.hydrasBoardResponseThread(self.hydrasSerial1)
            #self.hydrasResponseThread1.start()
        except:
            print "Unable to connect to Hydras1"

        #Heading
        try:
            pass
            self.hydrasSerial2 = serial.Serial("/dev/ttyUSB7", 115200)
            self.hydrasResponseThread2 = hydrasBoard.hydrasBoardResponseThread(
                self.hydrasSerial2)
            self.hydrasResponseThread2.start()
        except:
            print "Unable to connect to Hydras2"
        '''