Disclosure of Invention
Aiming at the defects of the prior art, the invention provides a gait track prediction method based on an improved LightGBM, which extracts acceleration data of lower limb joints for off-line analysis through human body kinematics analysis, further calculates a joint control target track, and finally controls the motion through the track by a control system to realize human body gait motion of lower limb exoskeleton.
In order to achieve the purpose, the technical scheme of the invention comprises the following specific contents:
a LightGBM-based exoskeleton gait prediction method, the method comprising the steps of:
step (1), data acquisition stage
Respectively arranging 5 IMU sensors on the waist, the left thigh, the left calf, the right thigh and the right calf of a user; acquiring x and y axial acceleration values of 5 IMU sensors in real time;
step (2), data analysis and noise elimination smoothing processing
Constructing a matrix consisting of 10 xk acceleration components according to the x and y axial acceleration values of the 5 IMU sensors in the step (1), wherein the matrix is defined as:
R=[V1,V2,…,Vi,…,V10]Tt represents the transpose of the matrix
Wherein
Representing the acceleration value of the ith acceleration component at the moment t, wherein K is the total number of data sampling points;
to V
iPerforming moving average filtering and de-noising processing
Has a filtered value of
Then:
wherein L is the number of the original acceleration values obtained during the moving average filtering processing, and is an odd number, and M is (L-1)/2;
according to the formula (2.1), V is finally obtainediNoise-canceling data at all times t (t ═ 1,2, …, K):
step (3) acquiring real-time flexion and extension angles in gait data
According to the noise elimination data processed in the step (2), taking the left lower limb as an example, the hip joint flexion and extension angle of the left lower limb at a certain time t
And the flexion-extension angle of the knee joint
The following equations (3.1) and (3.2) respectively yield:
wherein a isx1,ay1The acceleration components, a, of the left thigh IMU sensor at the time t after the processing in step 2 are respectivelyx2,ax2Acceleration components of the left and right crus IMU sensors at the time t after the processing in the step 2 are respectively obtained;
finally obtaining the flexion and extension angle vector α of the hip joint and the knee joint of the left lower limb at all K momentsLeft side ofAnd βLeft side of:
Obtaining flexion and extension angle vectors of the hip joint and the knee joint of the right lower limb in the same way;
step (4), continuous target value real-time prediction of improved LightGBM method
At the hip flexion and extension angle α of the left lower limbLeft side ofFor example, the following steps are carried out:
4.1 predictive model training
Training a prediction model of the hip joint flexion and extension angle of the left lower limb by taking the vector data of the hip joint flexion and extension angle of the left lower limb obtained in the step 3 as a training set;
first using a sliding window from αLeft side ofExtracting angle values from the left lower limb hip joint flexion and extension angle matrix Aα left sideAs a feature matrix for training the prediction model, see formula 4.1;
wherein w is the window width of the sliding window, N is the number of the sliding windows, the predicted length pLen is taken as the step length of the sliding window, and pLen is more than 1; to ensure better construction of the target matrix, K- [ (N-1) × pLen + w needs to be satisfied]Not less than pLen, i.e. ensuring αLeft side ofFinally, enough angle values are provided to construct predicted values of the pLen predicted lengths;
then according to the predicted length and αLeft side ofConstructing a matrix D according to the future-time flexion-extension angle value of the current sliding windowα left sideAs a prediction target value matrix for training a prediction model, see formula 4.2;
wherein
A predicted value vector corresponding to the ith future moment of the hip joint flexion and extension angle of the left lower limb is obtained;
and (3) constructing a feature matrix of the left lower limb knee joint according to the formulas (4.1) and (4.2) and substituting the feature matrix into a formula (4.3) to obtain pLen prediction models:
where T () is the LightGBM training function,
a prediction model (function) corresponding to the ith future moment after the hip joint flexion and extension angle of the left lower limb is trained;
4.2 parallel prediction of prediction models
The feature vector in the current latest sliding window of the hip joint of the left lower limb is
The prediction of the hip joint flexion and extension angles of the left lower limb at future pLen moments is realized by connecting pLen trained prediction models in a parallel structure:
wherein,
predicting the hip joint flexion and extension angle of the left lower limb at the ith moment in the future;
the left lower limb hip joint flexion and extension angle prediction vector P can be obtained from the formula (4.4)Left side of:
Obtaining a flexion-extension angle parallel prediction model of the knee joint of the left lower limb, the hip joint of the right lower limb and the knee joint in the same way;
and (5) predicting the vector according to the step 4 to realize the gait prediction track.
The invention has the beneficial effects that:
the invention provides a brand-new lower limb movement gait track prediction method which can be applied to lower limb exoskeleton control, innovatively realizes parallel structure input to LightGBM, predicts the gait track of a continuous target value of a lower limb joint, has high accuracy and reduces training time.
Detailed Description
In order to make the objects, technical solutions and points of the present invention clearer, embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
A LightGBM-based exoskeleton gait prediction method comprises the following steps:
1. data acquisition phase
Respectively arranging 5 IMU sensors on the waist, the left thigh, the left calf, the right thigh and the right calf of a user; the lower limb model diagram shown in fig. 2 can be simplified according to the structure of the lower limb of the human body, 5 black points represent the positions of 5 IMU sensors, each IMU sensor provides an acceleration component on a two-dimensional plane corresponding to each leg in the walking process of the lower limb of the human body, the hip joint takes the anticlockwise direction as the positive direction, and the knee joint takes the clockwise direction as the positive direction, so that the x-axis and y-axis acceleration values of the 5 IMU sensors are obtained in real time.
The acquisition equipment is 5 IMU sensors which are respectively arranged on the right shank, the right thigh, the left shank, the left thigh and the waist, the sampling rate is 100Hz, and the testee walks linearly at the pace of 2 km/h.
2. Data analysis and noise cancellation smoothing
Constructing a matrix consisting of 10 xk acceleration components according to the x and y axial acceleration values of the 5 IMU sensors in the step (1), wherein the matrix is defined as:
R=[V1,V2,…,Vi,…,V10]Tt represents the transpose of the matrix
Wherein
Representing the acceleration value of the ith acceleration component at the moment t, wherein K is the total number of data sampling points;
to V
iPerforming moving average filtering and de-noising processing
Has a filtered value of
Then:
wherein L is the number of the original acceleration values obtained during the moving average filtering processing, and is an odd number, and M is (L-1)/2;
according to the formula (2.1), V is finally obtainediNoise-canceling data at all times t (t ═ 1,2, …, K):
in the actual operation process, if the calculation is carried out according to the formula (1)
Then N summation operations are required at each time, and the time complexity is high. In general, the moving average filter can be implemented by a recursive algorithm.
Applying the partial acceleration component data to the MAF algorithm, four raw data plots are plotted versus noise-canceled data, as shown in fig. 1.
3. Real-time joint angle calculation of gait data
According to the noise elimination data processed in the step (2), taking the left lower limb as an example, the hip joint flexion and extension angle of the left lower limb at a certain time t
And the flexion-extension angle of the knee joint
The following equations (3.1) and (3.2) respectively yield:
wherein a isx1,ay1The acceleration components, a, of the left thigh IMU sensor at the time t after the processing in step 2 are respectivelyx2,ax2Acceleration components of the left and right crus IMU sensors at the time t after the processing in the step 2 are respectively obtained;
finally obtaining the flexion and extension angle vector α of the hip joint and the knee joint of the left lower limb at all K momentsLeft side ofAnd βLeft side of:
And obtaining the flexion and extension angle vectors of the hip joint and the knee joint of the right lower limb in the same way:
wherein a isx3,ay3The acceleration components a of the right thigh IMU sensor at the time t after the processing in the step 2 are respectivelyx4,ax4The acceleration degrees of the IMU sensor of the right shank at the time t after the processing in the step 2 are respectivelyAn amount;
finally obtaining the flexion and extension angle vector α of the hip joint and the knee joint of the left lower limb at all K momentsRight sideAnd βRight side:
4. Continuous target value real-time prediction for improved LightGBM method
The input of the control signal of the exoskeleton control system directly influences the fluency of the exoskeleton movement, so that the higher the input frequency of the control signal is, the more continuous the signal value input at a single time is, the more natural the movement process of the actuating mechanism of the exoskeleton can be. Based on the principle, when the gait is predicted by using the known LightGBM algorithm, only one joint angle transformation can be predicted at a time, and the exoskeleton execution mechanism is stopped due to the time required for the prediction algorithm to calculate the prediction result and the delay problem of a control signal to the execution mechanism. The conventional LightGBM prediction model cannot meet the real-time prediction function of an actual exoskeleton, so that a gait prediction algorithm based on the LightGBM needs to be improved relatively to be more suitable for the operation of the exoskeleton.
4.1 predictive model training
Training a prediction model of the hip joint flexion and extension angle of the left lower limb by taking the vector data of the hip joint flexion and extension angle of the left lower limb obtained in the step 3 as a training set;
first using a sliding window from αLeft side ofExtracting angle values from the left lower limb hip joint flexion and extension angle matrix Aα left sideAs a feature matrix for training the prediction model, see formula 4.1;
wherein w is the window width of the sliding window, N is the number of the sliding windows, the predicted length pLen is taken as the step length of the sliding window, and pLen is more than 1; to ensure betterConstructing a target matrix according to the requirement of K- [ (N-1) x pLen + w]Not less than pLen, i.e. ensuring αLeft side ofFinally, enough angle values are provided to construct predicted values of the pLen predicted lengths;
then according to the predicted length and αLeft side ofConstructing a matrix D according to the future-time flexion-extension angle value of the current sliding windowα left sideAs a prediction target value matrix for training a prediction model, see formula 4.2;
wherein
A predicted value vector corresponding to the ith future moment of the hip joint flexion and extension angle of the left lower limb is obtained;
and (3) constructing a feature matrix of the left lower limb knee joint according to the formulas (4.1) and (4.2) and substituting the feature matrix into a formula (4.3) to obtain pLen prediction models:
where T () is the LightGBM training function,
a prediction model (function) corresponding to the ith future moment after the hip joint flexion and extension angle of the left lower limb is trained;
4.2 parallel prediction of prediction models
The feature vector in the current latest sliding window of the hip joint of the left lower limb is
The prediction of the hip joint flexion and extension angles of the left lower limb at future pLen moments is realized by connecting pLen trained prediction models in a parallel structure:
wherein,
predicting the hip joint flexion and extension angle of the left lower limb at the ith moment in the future;
the left lower limb hip joint flexion and extension angle prediction vector P can be obtained from the formula (4.4)Left side of:
4.3 according to the same principle of steps 4.1-4.2, the right lower limb hip joint flexion and extension angle parallel prediction model is constructed as follows:
and (3) outputting a model:
from the characteristic matrix A of the hip joint of the right lower limbα right side、Dα right sideAnalogy to equation (4.3), we derive the pLen prediction models:
the feature vector in the current latest sliding window of the hip joint of the right lower limb is
The prediction of the hip joint flexion and extension angles of the right lower limb at future pLen moments is realized by connecting pLen trained prediction models in a parallel structure:
wherein,
for the hip joint of the right lower limb at the ith moment in the futurePredicting a bending and stretching angle;
the right lower limb hip joint flexion and extension angle prediction vector P can be obtained from the formula (4.5)Right side:
Similarly, the left lower limb knee joint flexion and extension angle parallel prediction model is constructed as follows:
and (3) outputting a model:
from the characteristic matrix a of the knee joint of the left lower limbβ left side、Dβ left sideAnalogy to equation (4.3), we derive the pLen prediction models:
the feature vector in the current latest sliding window of the knee joint of the left lower limb is
The left lower limb knee joint flexion and extension angle prediction at future pLen moments is realized by connecting pLen trained prediction models in a parallel structure:
wherein,
predicting a bending and stretching angle of the knee joint of the left lower limb at the ith moment in the future;
the left lower limb knee joint flexion and extension angle prediction vector Q can be obtained from the formula (4.6)Left side of:
Similarly, the right lower limb knee joint flexion and extension angle parallel prediction model is constructed as follows:
and (3) outputting a model:
from the characteristic matrix a of the knee joint of the right lower limbβ right side、Dβ right sideAnalogy to equation (4.3), we derive the pLen prediction models:
the feature vector in the current latest sliding window of the knee joint of the right lower limb is
The prediction of the flexion and extension angles of the knee joints of the right lower limbs at future pLen moments is realized by connecting pLen trained prediction models in a parallel structure:
wherein,
predicting a bending and stretching angle of the knee joint of the right lower limb at the ith moment in the future;
the right lower limb knee joint flexion and extension angle prediction vector Q can be obtained from the formula (4.7)Right side:
The step length of each sliding of a sliding window constructed by a data set when gait data is applied to a machine learning algorithm is 1, and the set prediction step length is required to be larger than 1 in order to realize continuous prediction of a target value.
Fig. 3 is a histogram of the contrast between the three algorithms. Compared with the XGboost and LightGBM algorithm based on Gradient Boosting, the gait prediction RMSE of Kalman filtering is higher, but the SC is lower, so that the prediction precision of Kalman filtering is low, but the prediction result is smoother, and the Kalman filtering prediction algorithm does not need training; in both XGBoost and LightGBM based on Gradient Boosting, RMSE of the predicted result is roughly the same overall, but SC of the predicted result of LightGBM is smaller than XGBoost, and training time of LightGBM is significantly smaller than that of XGBoost of the same training set size. Therefore, in the actual application process, the LightGBM can more quickly train a prediction model with good prediction effect.
The inventive prediction model validation is shown in fig. 4.
Step (5) executing the prediction result by the execution mechanism
Obtaining hip joint flexion and extension angles and knee joint flexion and extension angles of the left and right lower limbs according to the step 4 to obtain a prediction track; the left and right lower limb exoskeleton executing mechanisms convert the predicted bending and stretching angle tracks into corresponding control signals through the prior art, and then control motors at corresponding joints to operate so as to realize the gait walking of the outer limbs.