Energy Consumption Prediction for 3-RRR PPM through Combining LSTM Neural Network with Whale Optimization Algorithm

In the process of minimizing the energy consumption of a 3-RRR planar parallel manipulator (3-RRR PPM) and even general parallel kinematic manipulators, obtaining optimal results usually depends on particular functional relation between the instantaneous position of the moving platform and the kinetic time, which is called a displacement model (DM). Nevertheless, it is likely that although themovement time and path of a moving platform are the same, different amounts of energy are consumed for different DMs of the moving platform. To address this, a method of using long short-term memory neural network (LSTM-NN) instead of a complex theoretical model to predict the energy consumption of a 3-RRR PPM was presented. Subsequently, inverse dynamic equations of 3-RRR PPM were established based on the Newton–Euler method and solved using QR decomposition. Meanwhile, energy consumption between any two points in workspace of the 3-RRR PPMwas programmed to provide the LSTMNN with abundant precise training data. In view of time-varying characteristics of energy consumption prediction, the network architecture was developed based on the principle of LSTM-NN, and root-mean-square error (RMSE) was taken as the loss function. After acquiring training data, the RMSE of the LSTM-NN reached 0.00041 using whale optimization algorithm (WOA) with no need for the gradient of the loss function, so the lack of solving precision in training LSTM-NN was effectively improved. Finally, two different DMs of a moving platform with the same path and movement time were chosen to compare the total energy consumption of the 3-RRR PPM from the simulations, predictions, and experiments. *e results showed that the relative error between predicted and experimental data was less than 2.50%.*erefore, the energy consumption prediction based on the LSTMNN will be useful for achieving the intelligent application of 3-RRR PPMs.


Introduction
e use of 3-RRR planar parallel manipulators (PPMs) has grown recently. For example, when micron or even nanoscale accuracy is required, micromotion platforms using 3-RRR PPMs are widely employed as microforce sensors for the positioning of samples in a scanning electron microscope. Moreover, PPMs can be applied as parallel robots to conduct operations such as pick-and-place operations and precision machining [1,2].
In one report [20], electromechanical models were derived for serial or parallel pick-and-place manipulators, and the energy-optimal trajectories were reasonably calculated. In another study [21], the optimization problem of the consumed energy for a 3-RRR PPM was examined, and the link and platform masses were treated as variables. e actuator power consumption was used as the objective function to examine the effects of kinematic, geometric, and dynamic constraints. e particle swarm optimization (PSO) method was proposed to minimize the energy consumption efficiently. In fact, for any parallel kinematic manipulator (PKM), to accomplish the assigned task and minimize the consumed time and expended energy simultaneously, trajectory planning is a very complex problem involving functional optimization. In one study [22], the objective function and constraint conditions of this optimization problem were modeled based on the dynamics of a general motor-driven PKM, and a novel constrained multiobjective genetic algorithm (MOGA) was presented to solve the multiobjective optimization problem.
However, when the optimization problem was solved by the PSO method, spiral-shaped Cartesian trajectories were used for the positional motion of the moving platform [21]. Although the optimal results minimized the expended energy, the instantaneous position of the moving platform was restricted by the curvilinear equation. us, the instantaneous velocities and accelerations of the moving platform and the optimal energy consumption of a 3-RRR PPM were under the restrictions of these curvilinear equations. Similarly, a B-spline function was applied to generate the path function between the defined points [22]. Although the optimal results minimized the expended energy at μ � 0, the instantaneous position of the moving platform was under the restrictions of the B-spline function, and the instantaneous velocities and accelerations of the moving platform and optimal energy consumption of the PKM were restricted. For example, when two walkers travel along the same path, even if the total time they take is equal, the energy consumption is different because of their different instantaneous velocities.
In this paper, the relationship between the instantaneous position of a moving platform and the kinetic time was defined as a displacement model (DM), and the relationship between the instantaneous velocity of the moving platform and kinetic time was defined as a velocity model (VM). e optimal energy consumption under a particular DM and VM was then cleverly derived [21,22]. However, it could not be guaranteed that smaller energy consumption could be obtained for the same motion time and path when the DM or VM of the moving platform was changed. erefore, it is necessary to predict the energy consumed when the 3-RRR PPM passes through a given path (or planned path) with different DMs or VMs for the same travel time. Recently, with the development of artificial intelligence, supervised learning methods, such as back propagation neural network (BPNN), recurrent neural networks (RNN), and LSTM-NN, have been widely used for the energy consumption prediction of mobile robots or unmanned aerial vehicles (UAVs) [23][24][25], gait generation [26], cycle time forecasting of wafer lots during the wafer manufacturing [27], welding process prediction [28,29], in the medical field [30][31][32][33], human activity detection from untrimmed videos [34], advertising viewability prediction [35], and prediction of sea surface temperature (SST) [36].
To address the scarcity of empirical data and relying on kinematics models, a dynamic power model to evaluate the power consumption of skid-steer mobile robots (SSMRs) was demonstrated based on the slip parameters of the solved differential equations [23]. For UAV surveillance systems, on the one hand, the energy consumption was efficiently predicted via an elastic net regression using Sklearn [24]. On the other hand, an adaptive neural network (ANN) controller was developed using a K-agglomerative clustering method with adaptive weights and varied learning rates to tackle the optimal path planning and disturbance rejection control [25]. e architecture of a fully connected recurrent neural network (FCRNN) was used to address the gait generation problem of a three-dimensional biped robot, and a novel weight optimization approach called the advanced multiobjective continuous ant colony optimization (AMO-CACO) was presented [26]. To forecast the short-term cycle time of wafer lots during wafer manufacturing, a bilateral LSTM-NN was proposed [27]. A Gaussian process regression (GPR) method was proposed to predict the real-time welding process [28], and to apply experiences and skills of human welders to intelligent control and to better maintain desired precision and consistency, an intelligent controller using the neurofuzzy model was designed in automated gas tungsten arc welding process [29]. Because an LSTM-NN is capable of learning long-term dependencies [30], for the past few years, LSTM-NN applied in the medical domain have achieved fairly good results. For example, a semantic-containing double-level embedded Bi-LSTM model (SCDE-Bi-LSTM) was presented for the semantic matching of questions and answers in the Chinese medical field [31]. In one study [32], the problem of clinical relation extraction was examined. First, the features in the sentence sequence were captured through a bidirectional LSTM network. Second, the syntactic context for the target entities was captured through a convolutional neural network and Bi-LSTM network. Finally, the relationships between target entities were classified through a fully connected layer. A bidirectional LSTM network-based method was proposed to extract drug-drug interactions from a large amount of valuable biomedical literature [33]. Two different convolutional neural networks were combined with a BLSTM, and a bidirectional recurrent neural network model was used to efficiently solve the problems of human activity detection from untrimmed videos [34]. Bidirectional LSTM networks, an encoder-decoder structure, and residual connections were combined to tackle the prediction problem of advertising viewability [35].
However, in the process of training supervised networks such as BPNN and RNN, the gradient disappearance or gradient explosion probably occurs due to calculation of the loss function's gradient. Further, LSTM-NN is propitious to modeling long-term dependencies, in which there is overfitting, while strong prediction capability and low likelihood of overfitting are characteristic of Adaptive Boosting (AdaBoost). erefore, a method to combine LSTM-NN and AdaBoost was presented to predict the short and midterm daily SST [36]. Actually, the overfitting in LSTM-NN is the problem, which makes it difficult to satisfy the required solving precision in essence. In optimizing LSTM-NN's loss function through conventional gradient descent method, the lack of solving precision is also the bottleneck problem of LSTM-NN prediction. Although the lack of precision had varying degrees of improvement by the some improved gradient methods such as Adagrad, AdaDelta, Adam, and RMSProp, the gradient of loss function was still calculated in these methods [37]. In other words, to calculate the gradient of loss function, the partial derivatives of loss function to each independent variable (i.e., the weights of LSTM-NN) are needed, so the calculation is extremely complicated due to the numerous weights, and the running efficiency and solving precision of the corresponding solving program still need to be further improved. On the contrary, WOA as a metaheuristic optimization algorithm does not involve in calculating the gradient of loss function in optimizing LSTM-NN's loss function and has been proven to be an effective method with wonderful convergence for solving optimization problems [38][39][40]. For this purpose, WOA was proposed to train LSTM-NN.
In summary, during optimization of the energy consumption of 3-RRR PPMs, to prevent the omission of smaller energy consumption by depending on a particular DM of a moving platform as described above, it is necessary to use trained supervised learning networks instead of complex theoretical models to predict the energy consumption of 3-RRR PPMs. In view of the time-varying characteristics of the energy consumption prediction and to avoid the inherent weaknesses of lack of solving precision in training LSTM-NN, a method for the energy consumption prediction of 3-RRR PPMs through combining principle of LSTM-NN with WOA is proposed in this paper.
In the following, the inverse dynamics of the 3-RRR PPM are modeled by Newton-Euler method and solved using QR decomposition; additionally, the energy consumption between any two points in workspace of the 3-RRR PPM is programmed in Section 2. en, in Section 3, the architecture of LSTM-NN is designed and the RMSE is taken as the loss function; after that, the LSTM-NN is trained by the WOA. In Section 4, after the equipment of energy consumption experiment for the 3-RRR PPM is introduced, two different DMs of a moving platform under the same path and movement time are chosen to compare total energy consumption of the 3-RRR PPM under circumstance of simulation, prediction, and experiment, respectively. Finally, the conclusion is provided in Section 5.

Dynamics and Energy Consumption of 3-RRR PPM
2.1. Inverse Kinematic Modeling. A 3-RRR PPM, as depicted in Figure 1, is composed of a base, active bars, passive bars, and a moving platform. e base and the moving platform are two triangles with the vertices A i and C i , respectively, and the active bars A i B i are linked to the base at point A i through hinges. Furthermore, one end of each passive bar B i C i is linked to the active bar at point B i through hinges, and the other end is linked to the moving platform at point C i through hinges. In this paper, i � 1, 2, and 3.
Taking the intersection point o of the three medians of the triangle A 1 A 2 A 3 as the origin of the coordinates, a global coordinate system oxy is established such that the x-axis is parallel to A 2 A 3 . Taking the intersection point G 7 of the three medians of the triangle C 1 C 2 C 3 as the origin, the local coordinate system G 7 x′y′, which is fixed to the moving platform C 1 C 2 C 3 , is established such that the x′-axis is parallel to C 2 C 3 . θ denotes the rotation angle of the x-axis relative to the x′-axis (anticlockwise is defined as the positive direction). a, b, and c denote the lengths of the three sides A 1 A 2 , A 2 A 3 , and Likewise, the lengths of the three sides C 1 C 2 , C 2 C 3 , and C 3 C 1 of triangle C 1 C 2 C 3 were denoted as d, e, and f, respectively.
In Figure 2, the mass distribution of each bar is assumed to be homogenous, and the centers of mass are G i and G i+3 . e moving platform's center of mass is G 7 . G 7 (x, y) denotes the coordinates of point G 7 in the global coordinate system. It is supposed that the moving platform's position point G 7 moves with time t ∈ [t 0 , t n ] in workspace of the 3-RRR PPM, expressed as follows: x (1) e acceleration of the centroid point of the moving platform is then expressed as follows: and the moving platform's angular acceleration is as follows: In the global coordinate system oxy, the coordinates of points A i and C i are (x Ai , y Ai ) and (x Ci , y Ci ), respectively. e local coordinates of points Cα G7 � € θ i in the local coordinate system G 7 x′y′ are (x Ci ′, y Ci ′). e transformation formulas of the moving and static coordinates of the spatial mechanism for the points C i in the global coordinate system are as follows: e lengths of bars A i B i are l i , and the lengths of bars B i C i are l 4 , l 5 , and l 6 . Furthermore, the rotation angles of the active bars A i B i relative to the positive x-axis are θ i . erefore, point B i 's coordinates (x Bi , y Bi ) in the global coordinate system can be calculated as follows: e coordinates of the centroid point G i are e coordinates of centroid point G i+3 are Figure 1: Details of kinematic parameters for 3-RRR PPM. Figure 2: Schematic representation of dynamic modeling of 3-RRR PPM.
Based on vector algebra, the following equation can be obtained by the connection relation of the 3-RRR PPM's bars: Likewise, e angular velocities of the passive bars B i C i are e angular accelerations of the passive bars B i C i are Likewise, e kinematic equation of the 3-RRR PPM can be achieved based on (14): where Meanwhile, the condition that (15) has real solutions is as follows: erefore, the angular velocities of the active bars A i B i are and the angular acceleration of the active bars A i B i is

Condition of Singularity
Avoidance. e following equation can be obtained by differentiating both ends of (14) [2]: where the diagonal matrix Φ z is as follows: e coefficient matrix Φ y , which is also called a discriminant matrix of the singularity, is defined as follows:

Mathematical Problems in Engineering
If the determinant det (Φ y ) of matrix Φ y is 0, it is called a II-type singularity [2]. is paper is only concerned with IItype singularities, and the conditions for which a singularity will not occur are defined as follows: e inverse dynamics problem can be described as follows. When the dimensional parameters of the 3-RRR PPM, the movement rule of the position and orientation of the moving platform with time, the principal vector F e , and the main torque M e are known, the change of the driving torque τ i with time can be derived.
Based on the Newton-Euler method, the inverse dynamics modeling process of the 3-RRR PPM is described as follows. e internal forces acting on the points C i and B i are decomposed into F cix , F ciy , F Bix , and F Biy along the x-and yaxes of the global coordinate system.
As shown in Figure 2, taking the moving platform C 1 C 2 C 3 , the passive bars B i C i , and the active bars A i B i as the research objects, the dynamics of the 3-RRR PPM based on the Newton-Euler method are modeled as follows.
Equation (24) can be deduced for the moving platform F G7 is the inertial force of the moving platform, defined as follows: where [a G7x , a G7y ] T is given by (2) and m G7 and M G7 are the mass and moment of inertia of the moving platform. M G7 is defined as follows: where α G7 is given by (3) and J G7 is the rotational inertia of the moving platform relative to the center of mass: In a similar way, (28) can be deduced for the passive bars B i C i : F G(i+3) represents the inertial forces of the passive bars B i C i : where [a G(i+3)x , a G(i+3)y ] T is given by (9) and m G(i+3) and M G(i+3) are the masses and moments of inertia of the passive bars B i C i . M G(i+3) are defined as follows: where α G(i+3) is given by (13) and J G(i+3) denotes the rotational inertia of the passive bars B i C i relative to their own centers of mass: Finally, the following equation can be deduced for the active bars A i B i : F Gi represents the inertial forces of the active bars A i B i : where [a Gix , a Giy ] T is given by (7) and m Gi and M Gi are the masses and the moments of inertia of the active bars A i B i . M Gi is defined as follows: where α i is given by (19) and J Gi denotes the rotational inertia of the active bars A i B i relative to their own centers of mass: ere are 15 unknown variables: F cix , F ciy , F Bix , F Biy , and τ i and 21 equations including (24), (28), and (32). ese are represented as follows: x � Finally, the 21 equations mentioned above can be transformed into a matrix equation: where the matrices A and B are presented in Appendix. QR decomposition [41], which was performed in MATLAB using the function "mldivide" (matrix left division), can be used to solve for x ∈ R 15×1 in (37).

Energy Consumption between Any Two Points in Workspace of 3-RRR PPM.
ere are infinite trajectory curves that correspond to (1) between any two points in the workspace of the 3-RRR PPM. e energy consumption in the time interval [t 0 , t n ] from t 0 to t n is calculated as follows: in which ω i can be obtained by the inverse kinematic equation (see (15)) of the 3-RRR PPM and is given in detail in (18). Furthermore, τ i can be obtained by solving (37). erefore, the energy consumption for the 3-RRR PPM can be calculated by a numerical method. Different singularity-free paths, which satisfy (17) and (23), are selected in the workspace of 3-RRR PPM, assuming that each path corresponded to a running time t ∈ [t 0 , t n ] of the moving platform and e interval [t 0 , t n ] is divided into n equal parts, with each time interval Δt � T/n. Different values of the n + 1 groups can be obtained from the solution of (37), and the program flowchart to calculate the energy consumption of the 3-RRR PPM is shown in Figure 3.
(48) f tk , i tk , and o tk are the outputs of the forget gate, input gate, and output gate at timestep t k (k � 1, 2, . . ., n−1); are the corresponding weight matrices; and b f ∈ R 6 , b i ∈ R 6 , b C ∈ R 6 , and b O ∈ R 6 are the corresponding bias weights. σ (·) and tanh (·) are the elementwise sigmoid and tanh functions, respectively, defined as follows:

Loss Function and Training of LSTM-NN Based on WOA.
e root-mean-square error between the predicted and target values is expressed by the loss function e loss ( w → ), whose arguments are W f ∈ R 6 × (6+6) , W i ∈ R 6 × (6+6) , W C ∈ R 6 × (6+6) , W O ∈ R 6 × (6+6) , b f ∈ R 6 , b i ∈ R 6 , b C ∈ R 6 , and b O ∈ R 6 . ese arguments are expressed as a vector w → with 312 elements: in which h t(j−1) is the prediction vector calculated through the input value x t(j−1) (j � 1, 2, . . ., n + 1) based on (42)-(47), and h t(j−1) is the target vector. In 2016, the WOA was proposed [38], and it has since been widely used [39,40]. e WOA was used to optimize (52), which is also called the fitness function. e WOA is a mathematical model of the whale hunting process based on three different strategies: encircling the prey, the bubble-net attacking method, and searching for prey, and the iterative algorithm can be classified into three strategies depending on the conditions [38][39][40]. e first strategy is called encircling prey when p < 0.5 and | A → |< 1, in which p ∈ [0, 1] is a random number, and the corresponding iterative equations are as follows [38,39]: Here, t is the current iteration, A → and C → are coefficient vectors, w → is the position vector in (52), w * ��→ is the best position vector detected so far, | | is the absolute value, is the elementwise multiplication, a → is linearly decreased from 2 to 0 throughout the iterative process, and r → is a vector whose values are randomly generated in [0, 1]. e second strategy is called the bubble-net attacking method when p > 0.5, and the corresponding iterative equations are as follows [38,40]: in which b is a constant that defines a logarithmic spiral shape, and l ∈ [−1, 1] is a random number. e third strategy is called searching for prey when p < 0.5 and | A → | ≥ 1, and the corresponding iterative equations are as follows [38]: in which w rand ����→ is a random position vector chosen from the current population. e iterative termination condition is as follows due to the nonnegative loss function of (52): in which I max is the maximum number of iterations. Letting I max � 150, b � 1, a program based on the flowchart in Figure 5 was run, and the minimum of the loss function e loss ( w → ) was 0.00041 when the number of iterations was 97.

Experimental System to Test the Energy Consumption of 3-RRR PPM.
As depicted in Figure 6, the testing system based on the field bus technology mainly included a 3-RRR PPM, a servo control system, and a signal detection system. In the Windows operating system, the linkage of the three servo motors was achieved using Visual C++. e servo control system was mainly composed of a computer, central control unit (i.e., center control board-PCI bus, I/O board-local I/O board, and servo control board), three servo motor drivers, an encoder, and three servo motors. e RS-485 serial bus standard was adopted.
e servo motors and matched drivers were a TSC06401C2NL/TSTA20C type. Furthermore, the center control board and torque/speed sensor were PPCI-L112 and JN338-2VE types, respectively. To add an external force to the moving platform, the point G 8 with coordinates (q 1 , q 2 ) was taken on the base, a spring with elastic coefficient K and free length l 0 was connected between point G 8 on the base and point G 7 on the moving platform, and the main torque M e was equal to zero. According to Hooke's law, the principal vector F e through the center of mass of the moving platform can be expressed as follows (G 7 G 8 > l 0 ):    Figure 11: Comparison of simulated, experimental, and predicted data for three active bars' angular velocities ω i for the DM shown in Figure 10 e orientation angle θ of the moving platform was equal to −0.1047 rad, and the trajectory of the moving platform's center was a semiellipse:

Examples and
x � 0.01 cos(ωt), Letting T �10 s, based on the relationship between the moving platform displacement and time t expressed in (58), the angular velocities and torques of the active bars Predicted data Experimental data Simulated data Figure 12: Comparison of the simulated, experimental, and predicted data for three active bars' driving torques τ i for the DM shown in Figure 10(b).

×10 -5
Predicted data Experimental data Simulated data  Figure 10(b). and the energy consumption of the 3-RRR PPM were compared between the simulation, prediction, and experiment. e simulation curves, which are colored blue, were obtained using the program flowchart to calculate the energy consumption of the 3-RRR PPM described in Section 2.3.2. e prediction curves, which are colored green, were obtained from the training and forecasting based on the LSTM-NN described in Section 3. Finally, the experimental data, which are colored red, were obtained as described in Section 4.1. At the beginning of the experiment, the initial angular displacements of the three active bars were 0.4896, 0.2212, and 0.4081 rad. e three active bars' angular velocities ω i and driving torques τ i and the 3-RRR PPM's energy consumption E(t) for t ∈ [0, 10] from the simulation, experiments, and predictions are shown in Figures 7, 8, and 9, respectively.

Example 2.
According to the definition of the displacement model (DM) for the moving platform of the 3-RRR PPM in Section 1, the DM of the moving platform corresponding to (58) is shown in Figure 10(a). For the same movement time and path, another DM of the moving platform is shown in Figure 10(b).
Letting T �10 s, the semielliptical path of the moving platform's center and the other conditions, such as the dimensional parameters of 3-RRR PPM, the cross-sectional size of each bar, the bar material, and the orientation angle of the moving platform, were the same as those in Example 1. Only x(t) and y(t) of the moving platform's center changed with time t ∈ [0, T], as depicted in Figure 10(b).
Similarly, in the beginning of the experiment, the initial angular displacements of three active bars were still 0.4896, 0.2212, and 0.4081 rad. e three active bars' angular velocities ω i and driving torques τ i and the 3-RRR PPM's energy consumption E(t) with t ∈ [0, 10] were considered under the moving platform's DM, as depicted in Figure 10(b). e simulation, experiment, and prediction results were compared, and the corresponding graphs are shown in Figures 11, 12, and 13.

Discussion.
By integrating the data shown in Figure 9, the total energy consumption of the 3-RRR PPM from the simulation, experiment, and prediction was determined to be 7.6652 × 10 −4 , 8.1086 × 10 −4 , and 7.9228 × 10 −4 J, respectively. e relative error between the predicted and simulated data was 3.36%, and that between the predicted and experimental data was 2.29%.
Likewise, by integrating the data in Figure 13 and using the moving platform's DM depicted in Figure 10(b), for the same movement time and path, the total energy consumption for the simulation, experiment, and prediction of the 3-RRR PPM was determined to be 7.4845 × 10 −4 , 8.0186 × 10 −4 , and 7.8695 × 10 −4 J, respectively. e relative error between the predicted and simulated data was 5.14%, and that between the predicted and experimental data was 1.86%.
By comparing the DM of (58) with the DM of Figure 10(b), the total energy consumption of the latter was slightly lower. erefore, when the motion time and path were the same, different DMs of the moving platform resulted in different energy consumption.

Conclusions
In the research and development of a new type of robot, a prototype is developed until the industrial application of the new type robot is fully realized. e data derived using the theoretical modeling combined with numerical solutions of the theoretical model can also train a supervised learning network, because field data sources are scarce. e trained neural network can be applied to the online intelligent control of a new type of robot.
Combining an LSTM-NN with the WOA can help to avoid the inherent weaknesses of gradient disappearance or gradient explosion in other supervised networks, such as BPNN and RNN, when solving time-varying prediction problems. In addition, this approach can also replace theoretical complex dynamics models. In this paper, the RMSE of the trained LSTM-NN was 0.00041, and the relative error between predicted and experimental data was less than 2.50%. e results showed that the energy consumption prediction based on the LSTM-NN can meet the requirements of engineering applications. For the same movement time and path, different DMs of the moving platform resulted in different VMs and energy consumption. a 11 � a 12 � a 13 � 1; a 24 � a 25 � a 26 � 1; a 31 � − y − y C1 , a 32 � y − y C2 , a 33 � y − y C3 , a 34 � x − x C1 , a 35  in which all elements are enumerated as follows:

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that there are no conflicts of interest regarding the publication of this paper.
Mathematical Problems in Engineering 15