Exemplo n.º 1
0
        # bigger than the last gyroscope time
        if acceTimeList[i] > gyroTimeList[-1] or math.fabs(
                acceTimeList[i] - gyroTimeList[-1]) < 0.002:
            a2gIndexList.append(len(gyroTimeList) - 1)
            continue
        for j in range(gyroStartIndex, len(gyroTimeList)):
            if math.fabs(acceTimeList[i] - gyroTimeList[j]) < 0.002:
                a2gIndexList.append(j)
                gyroStartIndex = j + 1
                break
            baseTime = acceTimeList[i]
            # Now, the gyroscope should be determined
            if gyroTimeList[j] > baseTime:
                targetIndex = j if gyroTimeList[
                    j] - baseTime < baseTime - gyroTimeList[j - 1] else j - 1
                a2gIndexList.append(targetIndex)
                gyroStartIndex = targetIndex + 1
                break
    return a2gIndexList


if __name__ == "__main__":
    sensorFilePath = ("./Examples/PDRTest/20170622153925_acce.csv",
                      "./Examples/PDRTest/20170622153925_gyro.csv")
    # Load accelerometer data from files
    acceTimeList, acceValueList = loadAcceData(sensorFilePath[0],
                                               relativeTime=False)
    gyroTimeList, gyroValueList = loadGyroData(sensorFilePath[1],
                                               relativeTime=False)
    agTimeAlign(acceTimeList, gyroTimeList)
    print("Done.")
    acceTimeList, acceValueList = loadAcceData(sensorFilePath[0])
    windowSize = 7
    acceVotList, acceVarList = varOfAcce(acceTimeList, acceValueList,
                                         windowSize)

    # Stationary
    timeListForStat = acceVotList[51:341]
    timeListForStat = [t - timeListForStat[0] for t in timeListForStat]
    valueListForStat = acceVarList[51:341]

    # Walking
    timeListForWalk = acceVotList[1511:1801]
    timeListForWalk = [t - timeListForWalk[0] for t in timeListForWalk]
    valueListForWalk = acceVarList[1511:1801]

    gyroTimeList, gyroValueList = loadGyroData(sensorFilePath[1])
    windowSize = 21
    gyroTimeFltList, gyroValueFltList = slidingWindowFilter(
        gyroTimeList, gyroValueList, windowSize)

    # Normal Walking
    timeListForNW = gyroTimeFltList[1101:1601]
    timeListForNW = [t - timeListForNW[0] for t in timeListForNW]
    valueListForNW = gyroValueFltList[1101:1601]

    # Turns
    timeListForTurns = gyroTimeFltList[2581:3081]
    timeListForTurns = [t - timeListForTurns[0] for t in timeListForTurns]
    valueListForTurns = gyroValueFltList[2581:3081]

    # Right and Left turn
Exemplo n.º 3
0
            routeRotClockWise = thirdRouteRotClockWise
            moveVector = thirdMoveVector
            dataBelongs = "t3"

        errorListInSensorError = []
        for i in range(min(len(stepLengthErrorList), len(headingErrorList))):
            slError4Test = stepLengthErrorList[i]
            headingError4Test = headingErrorList[i]
            errorBySteps = []
            for k in range(10):
                for j in range(len(rawDataArray)):
                    filePaths = rawDataArray[j]
                    # Load sensor data from files
                    acceTimeList, acceValueList = loadAcceData(
                        filePaths[0], relativeTime=False)
                    gyroTimeList, gyroValueList = loadGyroData(
                        filePaths[1], relativeTime=False)
                    wifiTimeList, wifiScanList = loadMovingWifi(filePaths[2])
                    # load real locations
                    locRealDF = pd.read_csv(filePaths[3])
                    locRealList = [(loc[0], loc[1])
                                   for loc in locRealDF.values]

                    locEstWorldList = secondAiFi.onlineViterbi(
                        acceTimeList,
                        acceValueList,
                        gyroTimeList,
                        gyroValueList,
                        wifiTimeList,
                        wifiScanList,
                        startingDirection=0.0,
                        startingPointFlag=True,