A quaternion-based lower limb posture detection method and system
By using a quaternion-based Kalman filter method, the problems of noise error and high computational cost in posture detection are solved, achieving accurate and real-time detection of lower limb posture and providing data support for rehabilitation training.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- QILU CHILDRENS HOSPITAL OF SHANDONG UNIV
- Filing Date
- 2022-11-30
- Publication Date
- 2026-06-23
AI Technical Summary
In the existing technology, traditional attitude filtering methods such as Euler angles have problems such as large noise error, gimbal lock-up and large computational load when calculating lower limb attitude, resulting in inaccurate attitude detection and poor system response.
A quaternion-based Kalman filtering method is adopted. By establishing state equations and observation equations with attitude quaternions as state variables, attitude updates are performed using Kalman gain, which avoids gimbal deadlock and reduces computational load.
It achieves accurate posture detection and real-time system response, and can accurately predict the lower limb posture data of children, providing data support for rehabilitation training.
Smart Images

Figure CN115844380B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of rehabilitation training technology, and in particular to a method and system for detecting lower limb posture based on quaternions. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] Many children with cerebral palsy are unable to walk independently and ultimately can only walk with an abnormal, staggering gait. Wearable lower limb rehabilitation training devices for children can help them walk better and are now widely used. These devices use skeletal mechanical legs to support and move the child's lower limbs during walking training. The training progress is then assessed by monitoring lower limb movement data to determine the effectiveness of the training.
[0004] Therefore, accurate detection of lower limb posture data is a prerequisite for effective evaluation of training. Current technologies often employ posture filtering to calculate posture, capture lower limb movement data, and then evaluate the movement. Traditional filtering methods utilize the outputs of accelerometers, gyroscopes, and magnetometers to construct posture states and observation equations, and then filter the posture, such as using Kalman filtering. Because accelerometers / magnetometers have high-frequency noise, treating their signals as audio signals results in many "glitch" signals, meaning their instantaneous values are not precise enough, leading to oscillating posture calculations. Gyroscopes, on the other hand, have low-frequency noise, meaning the angular velocity obtained at each moment is relatively accurate. Integrating these angular velocities yields the rotational posture, but integration accumulates errors, causing the posture to become incorrect towards the end—a phenomenon known as drift.
[0005] To overcome the errors caused by noise, existing technologies use Kalman filters based on Euler angles for leg motion capture. However, when the pitch angle of the capture node is 90 degrees, gimbal lock occurs, leading to abnormal capture actions. Moreover, the Euler angle method is computationally intensive, requiring a large number of matrix inversion operations, which degrades the dynamic response of the system. Summary of the Invention
[0006] To address the aforementioned issues, this invention proposes a lower limb posture detection method and system based on quaternions. This method makes the physical meaning of the posture description more direct and the posture detection results more accurate.
[0007] In some implementations, the following technical solutions are adopted:
[0008] A quaternion-based lower limb posture detection method includes:
[0009] Establish a state equation with attitude quaternions as state variables, and establish an observation equation with the positional coordinate difference between the knee joint and the hip joint, and the positional coordinate difference between the ankle joint and the hip joint as observation quantities.
[0010] Obtain the quaternion of the human lower limb at the initial moment. Based on the quaternion of the human lower limb at time n-1 and the angular velocity, predict its quaternion at time n in one step.
[0011] The error covariance of the state variables is predicted based on the state transition matrix; the Kalman gain equation is constructed based on the predicted error covariance and the measurement matrix, and the Kalman gain is calculated.
[0012] Based on the one-step predicted attitude quaternion, Kalman gain, and the measured and estimated values of the observations, the estimated attitude quaternion is updated to obtain the lower limb attitude data;
[0013] Update the error covariance and estimate the attitude quaternion for the next time step.
[0014] As a further option, the state equation and the observation equation are respectively:
[0015]
[0016] in, and Let Ω1 and Ω2 represent the quaternions of the thigh and lower leg postures at time n and time n-1, respectively; Ω1 and Ω2 are the extended matrices of the angular velocities output by the thigh and lower leg sensors, respectively; T represents the sampling period of the sensor; Lp and Ld represent the lengths of the thigh and lower leg, respectively. The first column represents the rotation matrix from the knee coordinate system k to the navigation coordinate system n. The first column represents the rotation matrix from the ankle coordinate system a to the navigation coordinate system n. This represents the rotation matrix from the reference coordinate system c to the navigation coordinate system n.
[0017] As a further approach, based on the attitude quaternion and angular velocity of the human lower limb at time n-1, the attitude quaternion at time n is predicted in one step, specifically:
[0018]
[0019] Among them, F n-1 Here is the state transition matrix. Let be the quaternion representing the posture of the thigh and calf at time n-1.
[0020] As a further approach, the error covariance of the state variables is predicted based on the state transition matrix, specifically as follows:
[0021] P n|n-1 =Fn-1 P n-1 F n-1 T +Q
[0022] Among them, P n|n-1 Let F be the error covariance matrix at time n in the prediction. n-1 Let P be the state transition matrix. n-1 Let be the error covariance matrix at time n-1, and Q be the noise processing matrix.
[0023] As a further approach, a Kalman gain equation is constructed based on the predicted error covariance and the measurement matrix, and the Kalman gain is calculated as follows:
[0024] K n =P n|n-1 H n T (H n P n|n-1 H n T +R)
[0025] Among them, K n Let P be the Kalman gain at time n. n|n-1 H is the error covariance matrix at time n of the prediction. n R is the measurement matrix, which is the Jacobian matrix of the partial derivative of the estimated observations with respect to the predicted state variables at one step, and R is the measurement noise matrix.
[0026] As a further embodiment, the updated estimated attitude quaternion is specifically as follows:
[0027]
[0028] in, Let K be the attitude quaternion at time n predicted in one step. n Z is the Kalman gain at time n. n h is the measured value of the observed quantity at time n. n The estimated observation is represented by a one-step prediction of the state variable.
[0029] As a further solution, the updated error covariance is specifically as follows:
[0030] P n =(I 8×8 -K n H n )P n|n-1
[0031] Among them, P n|n-1 To predict the covariance of the error, K n H is the Kalman gain at time n. nThis is the measurement matrix.
[0032] In other embodiments, the following technical solutions are adopted:
[0033] A quaternion-based lower limb posture detection system includes:
[0034] The equation building module is used to establish state equations with attitude quaternions as state variables and observation equations with the positional coordinate difference between the knee and hip joints and the positional coordinate difference between the ankle and hip joints as observation quantities.
[0035] The one-step prediction module is used to obtain the attitude quaternion of the human lower limb at the initial moment. Based on the attitude quaternion and angular velocity of the human lower limb at time n-1, it predicts the attitude quaternion at time n in one step.
[0036] The attitude prediction module is used to predict the error covariance of state variables based on the state transition matrix; construct the Kalman gain equation based on the predicted error covariance and the measurement matrix, and calculate the Kalman gain; update the estimated attitude quaternion based on the one-step predicted attitude quaternion, Kalman gain, and the measured and estimated values of the observations to obtain the lower limb attitude data.
[0037] The error covariance update module is used to update the error covariance and estimate the attitude quaternion for the next time step.
[0038] In other embodiments, the following technical solutions are adopted:
[0039] A terminal device includes a processor and a memory, wherein the processor is used to implement various instructions; and the memory is used to store multiple instructions adapted to be loaded and executed by the processor for the aforementioned quaternion-based lower limb posture detection method.
[0040] In other embodiments, the following technical solutions are adopted:
[0041] A computer-readable storage medium storing a plurality of instructions adapted for loading and execution by a processor of a terminal device of the aforementioned quaternion-based lower limb posture detection method.
[0042] Compared with the prior art, the beneficial effects of the present invention are:
[0043] (1) The lower limb posture detection method based on quaternions of the present invention has a small amount of computation, which is convenient for computers or controllers to process a large number of calculations in real time and can ensure the real-time performance of the system.
[0044] (2) Compared with the Euler angle and direction cosine methods in the prior art, the present invention uses a quaternion-based attitude filtering algorithm, which can effectively avoid gimbal lock-up, has low computational cost, and high accuracy. It can accurately predict the lower limb posture data of the child, and by comparing it with the standard data in the standard training database, it can accurately understand the quality of the child's rehabilitation training, providing data support for doctors to formulate the next rehabilitation training plan.
[0045] Other features and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0046] Figure 1 This is a flowchart of the lower limb posture detection method based on quaternions in an embodiment of the present invention;
[0047] Figure 2 This is a schematic diagram of the sensor installation position and coordinate system in an embodiment of the present invention;
[0048] Figure 3 This is a schematic diagram showing the positions and coordinate systems of reference points and key points in an embodiment of the present invention. Detailed Implementation
[0049] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.
[0050] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0051] Example 1
[0052] In one or more embodiments, a quaternion-based lower limb posture detection method is disclosed. This method can predict the current posture based on the posture at the previous moment and can measure the lower limb joints to obtain the measured posture. Then, combining the previous prediction and measurement of the current posture, a Kalman gain is constructed, and the current posture is estimated a second time using the Kalman gain to obtain the filtered posture quaternion. This quaternion-based lower limb posture detection method can achieve accurate prediction of the movement posture of children with lower limb functional impairment. The predicted lower limb posture is compared with the standard posture in the standard training library, thereby providing data support for doctors to accurately understand the patient's current training quality and formulate the next training plan.
[0053] In this embodiment, the sensor device used for human lower limb posture capture is XsensDot. XsensDot is small, lightweight, easy to carry, and quick and simple to set up. The sensors are placed at the midpoint of the chest, left and right thighs, and left and right calves, respectively. The two sensors on the thighs and calves are kept parallel, with the X-axis direction parallel to the limb and pointing downwards. Under the control of the host computer, data is transmitted via Bluetooth to obtain posture quaternion and angular velocity information, using the chest sensor's position coordinate system as the reference coordinate system. The sensor's installation position and coordinate system are as follows... Figure 2 As shown. In addition, the following data also need to be measured: the coordinates of the hip joint in the reference frame and the limb length.
[0054] Combination Figure 1 The method in this embodiment specifically includes the following processes:
[0055] (1) Establish a state equation with attitude quaternions as state variables, and establish an observation equation with the positional coordinate difference between the knee joint and the hip joint and the positional coordinate difference between the ankle joint and the hip joint as observation quantities.
[0056] Quaternions, as the name suggests, are numbers consisting of four elements:
[0057] Q(q0,q1,q2,q3)=q0+q1i+q2j+q3k
[0058] Where q0, q1, q2, q3 are real numbers, and i, j, k are both mutually orthogonal unit vectors and imaginary units.
[0059] Quaternions can be expressed in several ways, among which the most commonly used are:
[0060] The complex number Q = q0 + q1i + q2j + q3k can be considered as a hypercomplex number.
[0061] The complex conjugate of Q is denoted as: Q * =q0-q1i-q2j-q3k;
[0062] Triangle form: In the formula, θ is a real number and u is a unit vector.
[0063] Matrix form:
[0064] Given a differential equation involving quaternions:
[0065]
[0066] in This represents the angular velocity in the carrier coordinate system, i.e., the gyroscope output value. The differential equation can be written as:
[0067]
[0068] Based on the principles of kinematics, the state value q at time n can be derived from the state at time n-1. n ,Right now:
[0069]
[0070] Where T represents the sampling period of the sensor.
[0071] In this embodiment, the spatial coordinates of the joint points in the reference coordinate system can be derived using attitude quaternions. The derivation process is as follows:
[0072] The magnitude of a quaternion is represented by its norm: If ||Q|| = 1, then Q is called a normalized quaternion.
[0073] Quaternion This describes the fixed-point rotation of a rigid body. Specifically, when only the angular position of the b-frame relative to the n-frame is of concern, the b-frame can be considered to be formed by a single, equivalent rotation of the n-frame without intermediate steps. Q contains all the information about this equivalent rotation: u is the rotation axis and direction, and θ is the angle rotated. The attitude rotation matrix from the n-frame to the b-frame can be determined using quaternions.
[0074]
[0075] because therefore:
[0076]
[0077] If ||Q||=1, then the rotation matrix is represented as:
[0078]
[0079] After calculating the postural changes during lower limb movement, the coordinates of the knee and ankle joints can be calculated based on limb dimensions and the relative positions of reference points. The specific calculation process is as follows:
[0080] First, we establish the reference frame as C, and all calculated joint coordinates are position coordinates within this reference frame. Taking the right leg joint as an example, we assume the right hip joint coordinate system is aligned with the reference frame, and the knee and ankle joint coordinate systems are aligned with the coordinates of the sensors mounted on the thigh and calf. Lp represents the thigh length; Ld represents the calf length.
[0081] The rotation matrix from the right knee joint coordinate system (k-frame) to the reference coordinate system (C-frame) can be expressed as:
[0082]
[0083] The rotation matrix from the right ankle joint (a-frame) to the reference coordinate system (C-frame) can be expressed as:
[0084]
[0085] Through actual measurement, the coordinates of the hip joint were obtained as follows:
[0086] P h =(x h ,y h ,z h )
[0087] Since the X-axis of the knee joint coordinate system is parallel to the leg direction, the knee joint is only relative to the reference point P along the X-axis direction. h If there are components, then the coordinate position of the right knee joint in the reference coordinate system (C system) is:
[0088]
[0089] In the formula, Coordinate transformation matrix The first column vector.
[0090] Similarly, the coordinate position of the right ankle joint in the reference frame (C frame) is obtained as follows:
[0091]
[0092] In the formula, Coordinate transformation matrix The first column vector.
[0093] The above are the steps for calculating the joint coordinates of the lower limbs. The method for calculating the joint coordinates of the left leg is the same as that for the right leg.
[0094] Based on this, a state equation is established with attitude quaternions as the state variables; an observation equation is established with the difference in position coordinates between the knee, ankle, and hip joints as the observed quantities; specifically:
[0095]
[0096] in, Let Ω1 and Ω2 be the extended matrices of the angular velocities of the thigh and lower leg at time n; Ω is represented as: The angular velocity in the carrier coordinate system represents the gyroscope output value; T represents the sensor's sampling period; the observed value h... n The positional coordinate differences between the knee and hip joints, and between the ankle and hip joints, can be expressed as follows: P k P a P h Lp and Ld represent the position coordinates of the knee and ankle joints in the reference coordinate system, respectively; Lp and Ld represent the lengths of the thigh and lower leg, respectively. The first column of the rotation matrix represents the rotation from the knee coordinate system k to the navigation coordinate system n (i.e., the northeast-sky coordinate system). The first column represents the rotation matrix from the ankle coordinate system a to the navigation coordinate system n. The rotation matrix from the reference coordinate system c to the navigation coordinate system n is expressed as:
[0097]
[0098] (2) Obtain the quaternion of the human lower limb at the initial moment, and predict its quaternion at time n based on the quaternion and angular velocity of the human lower limb at time n-1.
[0099] In this embodiment, when predicting the attitude quaternion in one step using the attitude quaternion and angular velocity at time n-1, it is determined whether time n-1 is the initial time. If it is the initial time, the attitude quaternion after filtering in the historical data cannot be obtained directly. In this case, the attitude quaternion and angular velocity value directly measured by the sensor at the initial time are used to estimate the predicted attitude at the next time. If it is any time other than the initial time, the attitude quaternion at time n-1 (the second time) can be obtained recursively from the attitude quaternion and angular velocity measurement value at the initial time based on the recursive formula. The attitude quaternion at time n can be predicted in one step using the attitude quaternion and angular velocity measurement value at time n-1.
[0100] The pose quaternion predicted in one step at time n is:
[0101]
[0102] Among them, F n-1 The state transition matrix is expressed as: This represents a one-step prediction of the quaternion of the thigh and lower leg posture at the current moment. It represents the filtered value of the thigh and lower leg posture quaternion at the previous time step.
[0103] (3) Predict the error covariance of the state variables based on the state transition matrix; construct the Kalman gain equation based on the predicted error covariance and the measurement matrix, and calculate the Kalman gain;
[0104] In this embodiment, the prediction error covariance is expressed by the following formula:
[0105] P n|n-1 =F n-1 P n-1 F n-1 T +Q;
[0106] Among them, P n|n-1 P represents the prediction error covariance at time n. n-1 F represents the updated value of the error covariance from the previous time step; n-1 is the state transition matrix in the state equation; Q represents the noise handling matrix, which describes the uncertainty introduced by the prediction model. The larger the value, the less reliable the prediction value is, and the closer the final result of the algorithm is to the measured value.
[0107] In this embodiment, the expression for the Kalman gain equation is:
[0108] K n =P n|n-1 H n T (H n P n|n-1 H n T +R);
[0109] H n Let be the measurement matrix, which is the Jacobian matrix of the partial derivatives of the estimated observations with respect to the predicted state variables at one step. R represents the measurement noise matrix, which describes the uncertainty introduced during the measurement process. The larger the value, the more unreliable the measurement, and the closer the algorithm will be to the predicted value.
[0110] The measurement posture at time n involves accurately measuring the joint's coordinates in a reference coordinate system. The difference between the joint coordinates and the fixed hip joint coordinates is used as the observation value. Where P k P represents the coordinates of the knee joint in the reference coordinate system. aP represents the coordinates of the ankle joint in the reference coordinate system. h This represents the coordinates of the hip joint in the reference coordinate system. A schematic diagram of the reference point, joint points, and coordinate system is shown below. Figure 3 As shown.
[0111] Based on the physical meaning of the observed quantity, an estimated value for the observed quantity is derived, namely:
[0112]
[0113] in, The first column represents the rotation matrix from the knee coordinate system to the navigation coordinate system; Let the first column of the rotation matrix from the ankle coordinate system to the navigation coordinate system be represented. Taking the partial derivative of h with respect to the state variables, we obtain the Jacobian matrix H, which can be expressed as:
[0114]
[0115] (4) Based on the one-step predicted attitude quaternion, Kalman gain, and the measured and estimated values of the observations, update the estimated attitude quaternion to obtain lower limb attitude data, such as the spatial coordinates of the joints in the reference coordinate system.
[0116] In this embodiment, the expression for updating the estimated state value attitude quaternion is:
[0117]
[0118] Among them, Z n This represents the measured value of the observed quantity at time n, i.e. The measured value, h n Let n represent the estimated observation represented by the one-step prediction of the state variables at time n, i.e.
[0119] (5) Update the error covariance and estimate the attitude quaternion for the next time step.
[0120] In this embodiment, the expression for updating the error covariance is:
[0121] P n =(I 8×8 -K n H n )P n|n-1 ;
[0122] Among them, P n|n-1 To predict the error covariance, after updating the error covariance, the filtering of the state variables is completed, and the loop proceeds to the next iteration.
[0123] The method in this embodiment can realize human lower limb posture filtering based on quaternions, and can be effectively used for filtering and solving human lower limb posture. Compared with the existing technology that uses accelerometers and magnetometers for calculation, this method makes the physical meaning it describes clear, has a small amount of calculation, and can effectively suppress oscillations.
[0124] Example 2
[0125] In one or more embodiments, a quaternion-based lower limb posture detection system is disclosed, comprising:
[0126] The equation building module is used to establish state equations with attitude quaternions as state variables and observation equations with the positional coordinate difference between the knee and hip joints and the positional coordinate difference between the ankle and hip joints as observation quantities.
[0127] The one-step prediction module is used to obtain the attitude quaternion of the human lower limb at the initial moment. Based on the attitude quaternion and angular velocity of the human lower limb at time n-1, it predicts the attitude quaternion at time n in one step.
[0128] The attitude prediction module is used to predict the error covariance of state variables based on the state transition matrix; construct the Kalman gain equation based on the predicted error covariance and the measurement matrix, and calculate the Kalman gain; update the estimated attitude quaternion based on the one-step predicted attitude quaternion, Kalman gain, and the measured and estimated values of the observations to obtain lower limb attitude data.
[0129] The error covariance update module is used to update the error covariance and estimate the attitude quaternion for the next time step.
[0130] It should be noted that the specific implementation methods of the above modules are the same as those in Embodiment 1, and will not be described in detail here.
[0131] Example 3
[0132] In one or more embodiments, a terminal device is disclosed, including a server. The server includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the quaternion-based lower limb posture detection method of Embodiment 1. For simplicity, further details are omitted here.
[0133] It should be understood that in this embodiment, the processor can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0134] Memory may include read-only memory and random access memory, and provides instructions and data to the processor. A portion of memory may also include non-volatile random access memory. For example, memory may also store information about the device type.
[0135] In the implementation process, each step of the above method can be completed by the integrated logic circuits in the processor hardware or by software instructions.
[0136] Example 4
[0137] In one or more embodiments, a computer-readable storage medium is disclosed, wherein a plurality of instructions are stored, the instructions being adapted to be loaded by a processor of a terminal device and executed by the quaternion-based lower limb posture detection method described in Embodiment 1.
[0138] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A lower limb posture detection method based on quaternions, characterized in that, include: Establish a state equation with attitude quaternions as state variables, and establish an observation equation with the positional coordinate difference between the knee joint and the hip joint, and the positional coordinate difference between the ankle joint and the hip joint as observation quantities. The observation The positional coordinate differences between the knee and hip joints, and between the ankle and hip joints, are expressed as... P k P a P h These represent the position coordinates of the knee, ankle, and hip joints in the reference coordinate system, respectively. The state equation and the observation equation are as follows: in, and Let n and n-1 represent the quaternions of the thigh and lower leg postures, respectively. , These are the extended matrices of the angular velocities output by the thigh and calf sensors, respectively; T represents the sensor sampling period; Lp and Ld represent the lengths of the thigh and calf, respectively. The first column represents the rotation matrix from the knee coordinate system k to the navigation coordinate system n. The first column represents the rotation matrix from the ankle coordinate system a to the navigation coordinate system n. This represents the rotation matrix from the reference coordinate system c to the navigation coordinate system n; Obtain the quaternion of the human lower limb at the initial moment. Based on the quaternion of the human lower limb at time n-1 and the angular velocity, predict its quaternion at time n in one step. The error covariance of the state variables is predicted based on the state transition matrix; the Kalman gain equation is constructed based on the predicted error covariance and the measurement matrix, and the Kalman gain is calculated. Based on the one-step predicted attitude quaternion, Kalman gain, and the measured and estimated values of the observations, the estimated attitude quaternion is updated to obtain the lower limb attitude data; Update the error covariance and estimate the attitude quaternion for the next time step.
2. The lower limb posture detection method based on quaternions as described in claim 1, characterized in that, Based on the attitude quaternion and angular velocity of the human lower limb at time n-1, the attitude quaternion at time n is predicted in one step, specifically as follows: in, Here is the state transition matrix. ; Let be the quaternion representing the posture of the thigh and calf at time n-1.
3. The lower limb posture detection method based on quaternions as described in claim 1, characterized in that, The error covariance of the state variables is predicted based on the state transition matrix, specifically as follows: in, Let n be the error covariance matrix at time n. Here is the state transition matrix. Let be the error covariance matrix at time n-1, and Q be the noise processing matrix.
4. The lower limb posture detection method based on quaternions as described in claim 1, characterized in that, The Kalman gain equation is constructed based on the predicted error covariance and the measurement matrix, and the Kalman gain is calculated as follows: in, Let n be the Kalman gain. Let n be the error covariance matrix at time n. R is the measurement matrix, which is the Jacobian matrix of the partial derivative of the estimated observations with respect to the predicted state variables at one step, and R is the measurement noise matrix.
5. The lower limb posture detection method based on quaternions as described in claim 1, characterized in that, The updated estimated attitude quaternion is specifically as follows: in, Let be the attitude quaternion at time n predicted in one step. Z is the Kalman gain at time n. n h is the measured value of the observed quantity at time n. n The estimated observation is represented by a one-step prediction of the state variable.
6. The lower limb posture detection method based on quaternions as described in claim 1, characterized in that, The updated error covariance is specifically as follows: in, Let n be the error covariance matrix at time n. Let n be the Kalman gain. This is the measurement matrix.
7. A quaternion-based lower limb posture detection system, employing the quaternion-based lower limb posture detection method as described in any one of claims 1-6, characterized in that, include: The equation building module is used to establish state equations with attitude quaternions as state variables and observation equations with the positional coordinate difference between the knee and hip joints and the positional coordinate difference between the ankle and hip joints as observation quantities. The one-step prediction module is used to obtain the attitude quaternion of the human lower limb at the initial moment. Based on the attitude quaternion and angular velocity of the human lower limb at time n-1, it predicts the attitude quaternion at time n in one step. The attitude prediction module is used to predict the error covariance of state variables based on the state transition matrix; construct the Kalman gain equation based on the predicted error covariance and the measurement matrix, and calculate the Kalman gain; update the estimated attitude quaternion based on the one-step predicted attitude quaternion, Kalman gain, and the measured and estimated values of the observations to obtain the lower limb attitude data. The error covariance update module is used to update the error covariance and estimate the attitude quaternion for the next time step.
8. A terminal device comprising a processor and a memory, the processor for implementing instructions; the memory for storing multiple instructions, characterized in that, The instructions are adapted to be loaded by a processor and executed by the quaternion-based lower limb posture detection method according to any one of claims 1-6.
9. A computer-readable storage medium storing a plurality of instructions, characterized in that, The instructions are adapted to be loaded by the processor of a terminal device and executed as described in any one of claims 1-6, which is a quaternion-based lower limb posture detection method.