当前位置: 首页>>代码示例>>Python>>正文


Python KalmanFilter.H[i,i]方法代码示例

本文整理汇总了Python中filterpy.kalman.KalmanFilter.H[i,i]方法的典型用法代码示例。如果您正苦于以下问题:Python KalmanFilter.H[i,i]方法的具体用法?Python KalmanFilter.H[i,i]怎么用?Python KalmanFilter.H[i,i]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在filterpy.kalman.KalmanFilter的用法示例。


在下文中一共展示了KalmanFilter.H[i,i]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: kinematic_kf

# 需要导入模块: from filterpy.kalman import KalmanFilter [as 别名]
# 或者: from filterpy.kalman.KalmanFilter import H[i,i] [as 别名]
def kinematic_kf(dim, order, dt=1., order_by_dim=True):
    """ Returns a KalmanFilter using newtonian kinematics for an arbitrary
    number of dimensions and order. So, for example, a constant velocity
    filter in 3D space would be created with

    kinematic_kf(3, 1)


    which will set the state `x` to be interpreted as

    [x, x', y, y', z, z'].T

    If you set `order_by_dim` to False, then `x` is assumed to be

    [x y z x' y' z'].T

    As another example, a 2D constant jerk is created with

    kinematic_kf(2, 3)


    Assumes that the measurement z is position in each dimension. If this is not
    true you will have to alter the H matrix by hand.

    P, Q, R are all set to the Identity matrix.

    H is assigned assuming the measurement is position, one per dimension `dim`.

    Parameters
    ----------

    dim : int
        number of dimensions

    order : int, >= 1
        order of the filter. 2 would be a const acceleration model.

    dim_z : int, default 1
        size of z vector *per* dimension `dim`. Normally should be 1

    dt : float, default 1.0
        Time step. Used to create the state transition matrix


    """

    dim_x = order + 1

    kf = KalmanFilter(dim_x=dim * dim_x, dim_z=dim)
    F = kinematic_state_transition(order, dt)
    if order_by_dim:
        diag = [F] * dim
        kf.F = sp.linalg.block_diag(*diag)

    else:
        kf.F.fill(0.0)
        for i, x in enumerate(F.ravel()):
            f = np.eye(dim) * x

            ix, iy = (i // dim_x) * dim,  (i % dim_x) * dim
            kf.F[ix:ix+dim, iy:iy+dim] = f

    if order_by_dim:
        for i in range(dim):
            kf.H[i, i * dim_x] = 1.
    else:
        for i in range(dim):
            kf.H[i, i] = 1.

    return kf
开发者ID:BrianGasberg,项目名称:filterpy,代码行数:72,代码来源:kinematic.py


注:本文中的filterpy.kalman.KalmanFilter.H[i,i]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。