Exemple #1
0
    def Measure(self):
        """ Get position from nmea stream
        """
        ret = None
        while ret is None:
            if self.measureIface.state != self.measureIface.IF_OK:
                break
            msg = self.measureUnit.MeasureMsg()
            ret = self._process(msg)
        return ret


if __name__ == '__main__':
    import logging
    from echowriter import EchoWriter
    #from serialiface import SerialIface
    #from httpwriter import HttpWriter
    from localiface import LocalIface
    from nmeagnssunit import NmeaGnssUnit
    logging.basicConfig()
    #iface = SerialIface("", "COM5")
    iface = LocalIface('test', '/home/siki/meresfeldolgozas/nmea1.txt')
    mu = NmeaGnssUnit()
    wrt = EchoWriter()
    #wrt = HttpWriter(url='http://localhost/get.php', angle='DEG')
    g = Gnss('', mu, iface, wrt)
    logging.getLogger().setLevel(logging.DEBUG)
    while g.measureIface.state == g.measureIface.IF_OK:
        g.Measure()
Exemple #2
0
    def GetMag(self):
        """ get magnetometer data

            :returns: 3 axis magneto data
        """
        msg = self.measureUnit.GetMagMsg()
        return self._process(msg, 0)


if __name__ == '__main__':
    import math
    from i2ciface import I2CIface
    from echowriter import EchoWriter

    i1d = I2CIface('accel', 0x1d)  # iface for acellero/magnetic
    i6b = I2CIface('gyro', 0x6b)  # iface for gyroscope
    munit = LSM9DS0Unit()
    wunit = EchoWriter()

    s9dof = LSM9DS0('9 DOF', munit, [i1d, i6b], wunit)
    for i in range(5):
        print("Accelerometer")
        w = s9dof.GetAccel()
        print(math.sqrt(w['acc_x']**2 + w['acc_y']**2 + w['acc_z']**2))
        print("Magnetometer")
        w = s9dof.GetMag()
        print(math.sqrt(w['mag_x']**2 + w['mag_y']**2 + w['mag_z']**2))
        #print("Gyro")
        #w = s9dof.GetGyro()
        #print(math.sqrt(w['gyro_x']**2 + w['gyro_y']**2 + w['gyro_z']**2))
Exemple #3
0
        # serial
        li = SerialIface('test', args.interface, args.speed)
    elif re.search('^([0-9a-fA-F]{2}:){5}[0-9A-f-F]{2}$', args.interface):
        # bluetooth
        li = BluetoothIface('test', args.interface, 1)
    elif os.path.exists(args.interface) and os.path.isfile(args.interface):
        # input from file
        li = LocalIface('test', args.interface)
    else:
        print('invalid interface given')
        sys.exit(1)

    # output
    if args.output is None:
        wrt = EchoWriter(
            '', 'DEG', '.3f', '%Y-%m-%d %H:%M:%S',
            ['id', 'latitude', 'longitude', 'altitude', 'datetime'])
    elif re.search('^https?://', args.output):
        wrt = HttpWriter(
            angle='DEG',
            url=args.output,
            filt=['longitude', 'latitude', 'altitude', 'datetime'])
    elif re.search('\.csv$', args.output):
        wrt = CsvWriter(
            '', 'DEG', '.3f', '%Y-%m-%d %H:%M:%S',
            ['id', 'latitude', 'longitude', 'altitude', 'datetime'],
            args.output)
    else:
        print('invalid output given')
        sys.exit(2)
Exemple #4
0
        print("unsupported instrument type")
        sys.exit(1)
    # set port
    port = '/dev/ttyUSB0'
    if len(sys.argv) > 4:
        port = sys.argv[4]
    iface = SerialIface("test", port)
    # set output file name
    fn = None
    if len(sys.argv) > 5:
        fn = sys.argv[5]
    # write out measurements
    if fn:
        wrt = FileWriter(angle='DEG', dist='.3f', fname=fn)
    else:
        wrt = EchoWriter(angle='DEG', dist='.3f')
    if wrt.GetState() != wrt.WR_OK:
        sys.exit(-1)  # open error
    ts = TotalStation(stationtype, mu, iface, wrt)
    if isinstance(mu, Trimble5500):
        print(
            "Please change to reflectorless EDM mode (MNU 722 from keyboard)")
        print("and turn on red laser (MNU 741 from keyboard) and press enter!")
        raw_input()
    else:
        ts.SetATR(0)  # turn ATR off
        ts.SetEDMMode('RLSTANDARD')  # reflectorless distance measurement
        ts.SetRedLaser(1)  # turn red laser on

    w = raw_input("Target on lower left corner and press Enter")
    w1 = ts.GetAngles()