gaitmap.trajectory_reconstruction.MadgwickRtsKalman#
- class gaitmap.trajectory_reconstruction.MadgwickRtsKalman(*, initial_orientation: ndarray | Rotation = cf(array([0., 0., 0., 1.])), zupt_variance: float = 1e-07, velocity_error_variance: float = 1000000.0, orientation_error_variance: float = 0.1, level_walking: bool = True, level_walking_variance: float = 1e-07, zupt_detector=cf(NormZuptDetector(inactive_signal_threshold=34.0, metric='maximum', sensor='gyr', window_length_s=0.05, window_overlap=0.5, window_overlap_samples=None)), madgwick_beta: float = 0.2)[source]#
An extention of the RTS Kalman filter that uses the Madgwick filter for orientation estimation.
This method is basically identical to the normal
RtsKalmanfilter, but uses the Madgwick filter for orientation estimation. This should provide more robust orientation updates during long regions without ZUPTs. The influence of the Madgwick filter can be controlled by themadgwick_betaparameter.- Parameters:
- initial_orientation
The initial orientation of the sensor that is assumed. It is critical that this value is close to the actual orientation. If you pass an array, remember that the order of elements must be x, y, z, w.
- zupt_variance
The variance of the noise of the measured velocity during a ZUPT. As we are typically pretty sure, that the velocity should be zero then, this should be very small.
- velocity_error_variance
The variance of the noise present in the velocity error. Should be based on the sensor accelerometer noise.
- orientation_error_variance
The variance of the noise present in the orientation error. Should be based on the sensor gyroscope noise. The orientation error is internally not represented as quaternion, but as axis-angle representation, which also explains the unit of rad^2 for this variance.
- level_walking
Flag to control if the level walking assumptions should be used during ZUPTs. If this is True, additionally to the velocity, the z position is reset to zero during a ZUPT.
- level_walking_variance
The variance of the noise of the measured position during a level walking update. Should typically be very small.
- zupt_detector
An instance of a valid Zupt detector that will be used to find ZUPTs.
- madgwick_beta
The beta parameter of the Madgwick filter. This parameter controls how harsh the acceleration based correction is. A high value performs large corrections and a small value small and gradual correction. A high value should only be used if the sensor is moved slowly. A value of 0 is identical to just the Gyro Integration (i.e. identical to the
RtsKalman).
- Other Parameters:
- data
The data passed to the estimate method
- sampling_rate_hz
The sampling rate of this data
- Attributes:
orientation_Orientations as pd.DataFrame.
- orientation_object_
The orientations as a single scipy Rotation object
- position_
The calculated positions
- velocity_
The calculated velocities
- covariance_
The covariance matrices of the kalman filter after smoothing. They can be used as a measure of how good the filter worked and how accurate the results are.
- zupts_
2D array indicating the start and the end samples of the detected ZUPTs for debug purposes.
rotated_data_Rotated data.
Notes
For more information on the Kalman Filter, see
RtsKalman. For more information about the Madgwick orientation filter, seeMadgwickAHRS.Methods
clone()Create a new instance of the class with all parameters copied over.
estimate(data, *, sampling_rate_hz[, ...])Estimate the position, velocity and orientation of the sensor.
from_json(json_str)Import an gaitmap object from its json representation.
get_params([deep])Get parameters for this algorithm.
set_params(**params)Set the parameters of this Algorithm.
to_json()Export the current object parameters as json.
- __init__(*, initial_orientation: ndarray | Rotation = cf(array([0., 0., 0., 1.])), zupt_variance: float = 1e-07, velocity_error_variance: float = 1000000.0, orientation_error_variance: float = 0.1, level_walking: bool = True, level_walking_variance: float = 1e-07, zupt_detector=cf(NormZuptDetector(inactive_signal_threshold=34.0, metric='maximum', sensor='gyr', window_length_s=0.05, window_overlap=0.5, window_overlap_samples=None)), madgwick_beta: float = 0.2) None[source]#
- clone() Self[source]#
Create a new instance of the class with all parameters copied over.
This will create a new instance of the class itself and all nested objects
- estimate(data: DataFrame, *, sampling_rate_hz: float, stride_event_list: DataFrame | None = None) Self[source]#
Estimate the position, velocity and orientation of the sensor.
- Parameters:
- data
Continuous sensor data including gyro and acc values. The gyro data is expected to be in deg/s!
- sampling_rate_hz
The sampling rate of the data in Hz
- stride_event_list
Optional stride event list that will be passed to the ZUPT detector. If this information is actually used depends on the ZUPT detector.
- Returns:
- self
The class instance with all result attributes populated
- classmethod from_json(json_str: str) Self[source]#
Import an gaitmap object from its json representation.
For details have a look at the this example.
You can use the
to_jsonmethod of a class to export it as a compatible json string.- Parameters:
- json_str
json formatted string
- get_params(deep: bool = True) dict[str, Any][source]#
Get parameters for this algorithm.
- Parameters:
- deep
Only relevant if object contains nested algorithm objects. If this is the case and deep is True, the params of these nested objects are included in the output using a prefix like
nested_object_name__(Note the two “_” at the end)
- Returns:
- params
Parameter names mapped to their values.