code: def const_vel_filter(
      dt, x0=0, x_ndim=1, P_diag=(1.0, 1.0), R_std=1.0, Q_var=0.0001
  ):
      """helper, constructs 1d, constant velocity filter"""
      f = KalmanFilter(dim_x=2, dim_z=1)
  
      if x_ndim == 1:
          f.x = np.array([x0, 0.0])
      else:
          f.x = np.array([[x0, 0.0]]).T
  
      f.F = np.array([[1.0, dt], [0.0, 1.0]])
  
      f.H = np.array([[1.0, 0.0]])
      f.P = np.diag(P_diag)
      f.R = np.eye(1) * (R_std**2)
      f.Q = Q_discrete_white_noise(2, dt, Q_var)
  
      return f
  
imports: from __future__ import absolute_import, division, print_function
  import numpy.random
  from numpy.random import randn
  import numpy
  import matplotlib.pyplot
  from pytest import approx
  from filterpy.kalman import KalmanFilter, update, predict, batch_filter
  from filterpy.common import Q_discrete_white_noise, kinematic_kf, Saver
  from filterpy.stats import mahalanobis
  from scipy.linalg import block_diag, norm
label_desc: Use image node_id 1 for calling a global function with example usage: const_vel_filter(dt, x0, x_ndim, P_diag, R_std, Q_var) and returns: f