remove_jumps#
- ahrs.common.quaternion.QuaternionArray.remove_jumps(self) None#
Flip sign of negated quaternions.
Some estimations and measurements of quaternions might have “jumps” produced when their values are multiplied by -1. They still represent the same rotation, but the continuity of the signal “flips”, making it difficult to evaluate continuously.
To revert this, the “flipped” instances are identified and multiplied by -1 to “flip them back”. This function does that correction over all values of the attribute
array.Examples
>>> qts = np.tile([1., -2., 3., -4], (5, 1)) # Five equal arrays >>> v = np.random.randn(5, 4)*0.1 # Gaussian noise >>> Q = QuaternionArray(qts + v) >>> Q.view() QuaternionArray([[ 0.17614144, -0.39173347, 0.56303067, -0.70605634], [ 0.17607515, -0.3839024 , 0.52673809, -0.73767437], [ 0.16823806, -0.35898889, 0.53664261, -0.74487424], [ 0.17094453, -0.3723117 , 0.54109885, -0.73442086], [ 0.1862619 , -0.38421818, 0.5260265 , -0.73551276]]) >>> Q[1:3] *= -1 # 2nd and 3rd Quaternions "flip" >>> Q.view() QuaternionArray([[ 0.17614144, -0.39173347, 0.56303067, -0.70605634], [-0.17607515, 0.3839024 , -0.52673809, 0.73767437], [-0.16823806, 0.35898889, -0.53664261, 0.74487424], [ 0.17094453, -0.3723117 , 0.54109885, -0.73442086], [ 0.1862619 , -0.38421818, 0.5260265 , -0.73551276]]) >>> Q.remove_jumps() >>> Q.view() QuaternionArray([[ 0.17614144, -0.39173347, 0.56303067, -0.70605634], [ 0.17607515, -0.3839024 , 0.52673809, -0.73767437], [ 0.16823806, -0.35898889, 0.53664261, -0.74487424], [ 0.17094453, -0.3723117 , 0.54109885, -0.73442086], [ 0.1862619 , -0.38421818, 0.5260265 , -0.73551276]])