Пример #1
0
def dead_reckon(ax, ay, az, t):
    """
    Attempt dead reckoning (estimating position) from accelerometer data.

    The accelerometer data are too noisy!

    Parameters
    ----------
    ax : list or numpy array of floats
        accelerometer x-axis data
    ay : list or numpy array of floats
        accelerometer y-axis data
    az : list or numpy array of floats
        accelerometer z-axis data
    t : list or numpy array of floats
        accelerometer time points

    Returns
    -------
    x : list or numpy array of floats
        estimated position along x-axis
    y : list or numpy array of floats
        estimated position along y-axis
    z : list or numpy array of floats
        estimated position along z-axis
    distance : float
        estimated change in position

    Examples
    --------
    >>> from mhealthx.extractors.dead_reckon import dead_reckon
    >>> from mhealthx.xio import read_accel_json
    >>> #input_file = '/Users/arno/DriveWork/mhealthx/mpower_sample_data/accel_walking_outbound.json.items-6dc4a144-55c3-4e6d-982c-19c7a701ca243282023468470322798.tmp'
    >>> input_file = '/Users/arno/DriveWork/mhealthx/mpower_sample_data/deviceMotion_walking_outbound.json.items-5981e0a8-6481-41c8-b589-fa207bfd2ab38771455825726024828.tmp'
    >>> start = 150
    >>> device_motion = True
    >>> t, axyz, gxyz, uxyz, rxyz, sample_rate, duration = read_accel_json(input_file, start, device_motion)
    >>> ax, ay, az = axyz
    >>> x, y, z, distance = dead_reckon(ax, ay, az, t)

    """
    import numpy as np

    from mhealthx.extractors.dead_reckon import velocity_from_acceleration,\
        position_from_velocity

    #-------------------------------------------------------------------------
    # De-mean accelerometer readings:
    #-------------------------------------------------------------------------
    ax -= np.mean(ax)
    ay -= np.mean(ay)
    az -= np.mean(az)

    #-------------------------------------------------------------------------
    # Estimate velocity:
    #-------------------------------------------------------------------------
    vx, vy, vz = velocity_from_acceleration(ax, ay, az, t)

    #-------------------------------------------------------------------------
    # Estimate position (dead reckoning):
    #-------------------------------------------------------------------------
    x, y, z, distance = position_from_velocity(vx, vy, vz, t)

    print('distance = {0}'.format(distance))

    return x, y, z, distance
Пример #2
0
def dead_reckon(ax, ay, az, t):
    """
    Attempt dead reckoning (estimating position) from accelerometer data.

    The accelerometer data are too noisy!

    Parameters
    ----------
    ax : list or numpy array of floats
        accelerometer x-axis data
    ay : list or numpy array of floats
        accelerometer y-axis data
    az : list or numpy array of floats
        accelerometer z-axis data
    t : list or numpy array of floats
        accelerometer time points

    Returns
    -------
    x : list or numpy array of floats
        estimated position along x-axis
    y : list or numpy array of floats
        estimated position along y-axis
    z : list or numpy array of floats
        estimated position along z-axis
    distance : float
        estimated change in position

    Examples
    --------
    >>> from mhealthx.extractors.dead_reckon import dead_reckon
    >>> from mhealthx.xio import read_accel_json
    >>> #input_file = '/Users/arno/DriveWork/mhealthx/mpower_sample_data/accel_walking_outbound.json.items-6dc4a144-55c3-4e6d-982c-19c7a701ca243282023468470322798.tmp'
    >>> input_file = '/Users/arno/DriveWork/mhealthx/mpower_sample_data/deviceMotion_walking_outbound.json.items-5981e0a8-6481-41c8-b589-fa207bfd2ab38771455825726024828.tmp'
    >>> start = 150
    >>> device_motion = True
    >>> t, axyz, gxyz, uxyz, rxyz, sample_rate, duration = read_accel_json(input_file, start, device_motion)
    >>> ax, ay, az = axyz
    >>> x, y, z, distance = dead_reckon(ax, ay, az, t)

    """
    import numpy as np

    from mhealthx.extractors.dead_reckon import velocity_from_acceleration,\
        position_from_velocity

    #-------------------------------------------------------------------------
    # De-mean accelerometer readings:
    #-------------------------------------------------------------------------
    ax -= np.mean(ax)
    ay -= np.mean(ay)
    az -= np.mean(az)

    #-------------------------------------------------------------------------
    # Estimate velocity:
    #-------------------------------------------------------------------------
    vx, vy, vz = velocity_from_acceleration(ax, ay, az, t)

    #-------------------------------------------------------------------------
    # Estimate position (dead reckoning):
    #-------------------------------------------------------------------------
    x, y, z, distance = position_from_velocity(vx, vy, vz, t)

    print('distance = {0}'.format(distance))

    return x, y, z, distance
Пример #3
0
    start = 150
    t, axyz, gxyz, uxyz, rxyz, sample_rate, duration = read_accel_json(
        input_file, start, device_motion)
    ax, ay, az = axyz

    #-------------------------------------------------------------------------
    # De-mean accelerometer readings:
    #-------------------------------------------------------------------------
    ax -= np.mean(ax)
    ay -= np.mean(ay)
    az -= np.mean(az)

    plotxyz(ax, ay, az, t, 'Acceleration')

    #-------------------------------------------------------------------------
    # Estimate velocity:
    #-------------------------------------------------------------------------
    vx, vy, vz = velocity_from_acceleration(ax, ay, az, t)

    plotxyz(vx, vy, vz, t, 'Velocity')

    #-------------------------------------------------------------------------
    # Estimate position (dead reckoning):
    #-------------------------------------------------------------------------
    x, y, z, distance = position_from_velocity(vx, vy, vz, t)

    print('distance = {0}'.format(distance))

    plotxyz(x, y, z, t, 'Position')
    #plotxyz3d(x, y, z)
Пример #4
0
    #-------------------------------------------------------------------------
    # De-mean accelerometer readings:
    #-------------------------------------------------------------------------
    ax -= np.mean(ax)
    ay -= np.mean(ay)
    az -= np.mean(az)
    
    plotxyz(ax, ay, az, t, 'Acceleration')
    
    #-------------------------------------------------------------------------
    # Estimate velocity:
    #-------------------------------------------------------------------------
    vx, vy, vz = velocity_from_acceleration(ax, ay, az, t)

    plotxyz(vx, vy, vz, t, 'Velocity')
    
    #-------------------------------------------------------------------------
    # Estimate position (dead reckoning):
    #-------------------------------------------------------------------------
    x, y, z, distance = position_from_velocity(vx, vy, vz, t)

    print('distance = {0}'.format(distance))

    plotxyz(x, y, z, t, 'Position')
    #plotxyz3d(x, y, z)