Dimensional synthesis of mechanical linkages using artificial neural networks and Fourier descriptors

Dimensional synthesis of mechanisms to trace given paths is an important problem with no exact solution. In this paper, the problem is divided into representation of curve shape and learning the relation between curve shape and mechanism dimensions. Curve shape is represented by Fourier descriptors of cumulative angular deviation of the curve, which do not depend on the position or scale of the curve. An artificial neural network (ANN) is trained to learn the (unknown) relation between the Fourier descriptors of a planar curve and the dimensions of the mechanism tracing that curve. Presented with any simple, closed, planar curve, the ANN suggests the dimensions of a four-bar whose coupler curve is similar in shape. A local optimization procedure further refines the results. Examples presented indicate the method is successful as long as the curve shape is such that the mechanism is able to trace it.


Introduction
Mechanical linkages are used extensively for transforming motion and transmitting power in industrial machinery, agriculture, construction, automobiles and household gadgets.The design of linkages involves determining dimensions of constituting links so that the linkage moves in a manner necessary to carry out the required task (Sandor and Erdman, 1988).
Figure 1 shows a common four-bar linkage whose tracer point P generates a path known as the coupler curve when the input link rotates.The problem of dimensional synthesis for path generation requires calculation of suitable dimensions for the linkage so that point P traces a desired continuous path.An exact solution for this problem is not possible because of the limited number of dimensions available, but various techniques have been used for approximate solutions.The most common techniques used include conventional optimization methods (Tomas, 1968;Sancibrian et al., 2004;Diab and Smaili, 2008), using atlases of mechanisms (Zhang et al., 1984), simulated annealing (Ullah and Kota, 1996), and genetic algorithms or evolutionary algorithms (Cabrera et al., 2002;Laribi et al., 2004;Starosta, 2008;Lin, 2010).
In this research, normalized Fourier descriptors are used to represent the shape of coupler curves and artificial neural networks (ANNs) are used for approximating the inverse relationship between curve shape and linkage dimensions.A brief introduction to Fourier descriptors is presented below, followed by review of the relevant research.
Fourier descriptors are functions used for description of shapes of object boundaries (or of any two-dimensional, simple closed curve).The boundary of a shape is represented by a periodic function that, when expanded in a Fourier series, yields a set of coefficients containing the shape information.Different types of Fourier descriptors have been proposed in the literature, including Fourier descriptors of the boundary (McGarva and Mullineux, 1993;Persoon and Fu, 1986) and Fourier descriptors of the angular orientation of the curve (Zahn and Roskies, 1972;Buskiewicz et al., 2009).The latter method is used here, which describes shape using the net amount of angular bend of the curve relative to the starting angle as a function of arc length φ(l) = θ(l) − θ (0), as shown in Fig. 2. The main advantage of using this formulation is invariance to translation, rotation and scaling of the curve so that the shape of a coupler curve is represented, independently of the position and size of the linkage producing it.The Fourier descriptors can also be normalized to Published by Copernicus Publications.remove dependence on starting point of the curve, direction of traversing the curve and to remove the difference between mirror image curves; these properties are irrelevant to synthesis of mechanisms.
After a change of variable to remove length dependence, t = 2πl L , and addition of a linear part to remove discontinuities, the function to be expanded in a Fourier series is given by Eq. (1).
where L is the total length of the curve.This periodic function is expanded in a Fourier series and the coefficients of the series are termed the Fourier descriptors.Work on linkage synthesis using ANNs is not extensive.Hoskins and Kramer (1993) used a radial basis function (RBF) ANN in combination with optimization techniques to construct an approximate inverse model of four-bar linkage.In that work, coupler curve shape is represented by power spectrum Fourier transform of curvature versus length.The RBF. ANN used consists of 50 input nodes, 50 to 750 nodes in the single hidden layer and 5 nodes in the output layer.A constrained local optimization technique is used to refine linkage parameters.Vasiliu and Yannou (2001) use normalized Fourier descriptors of the boundary to represent curve shape and then use an ANN with 17 input neurons, 2 hidden layers of 22 neurons each and 5 output neurons to synthesize four-bar mechanisms for path generation.Xie and Chen (2007) discuss motion synthesis of a crank-rocker based on neural networks.The angle of the coupler link and the position of the coupler point are first mapped onto a curve in image space, which is then described by a two-dimensional Fourier transform.A separate three-layered ANN is designed for relating each link dimension to the curve shape.It is not clear, however, how a network can model the relation of curve shape to one link dimension, without reference to other links.Galan-Marin et al. (2009) use wavelet descriptors and neural networks for linkage synthesis.Peñuñuri et al. (2011) propose combined synthesis for function, path, and motion generation by combining the objective functions of all three.Kim and Yoo (2012) demonstrate simultaneous number and dimension synthesis for function generation problems.Ebrahimi and Payvandy (2015) use the structural error objective function but add a penalty for violation of workspace limits.They demonstrate the use of the imperial competitive algorithm, a variation of genetic algorithms, to solve the problem.
In the next section, the methodology of the work is outlined, including the equations used.Section 3 presents the design of the ANN, including the structure of network and details of training and testing, followed by some example problems.Finally, a discussion of the results is presented and conclusions drawn in Sect. 4.

Methodology
The methodology used in this work comprises the following steps: 1. Dimensions for a large number of four-bar mechanisms were generated at random, keeping link length ratios within a reasonable limit and ensuring all mechanisms are crank-rockers so that the coupler curves produced are closed curves.
2. Coupler curves of the generated mechanisms were obtained, each as a set of points in the plane.
3. Each coupler curve was transformed into its Fourier descriptors and descriptors were normalized.
4. An ANN was designed to take Fourier descriptors of the generated curves as the input and corresponding mechanism dimensions as the output or target values.The ANN was trained using the data generated.5.The trained network was tested by presenting new data to it.Results were confirmed by numerical as well as visual comparison of desired and proposed curves.
6. To determine the four-bar mechanism that will reproduce any desired curve, the curve is first converted to its Fourier descriptors, which are then presented as input to the trained ANN.The mechanism dimensions produced by the ANN are further refined by using a local optimization procedure.
Each step is explained below in some detail.

Generation of crank-rockers
With reference to Fig. 3, a four-bar linkage can be represented by the lengths of its four links plus two variables for locating the coupler point P, the path tracing point, on link 3.For scale independence, the length of link 2 is taken as unity and limits are imposed on the lengths of other links to obtain a practical linkage.The five variables selected to represent a four-bar are as given in Eq. (2).
-Choose l at random such that p ≤ l ≤ 5.
-Choose q at random such that s + l ≤ p + q ≤ p + l, where s = r 2 to ensure a crank-rocker.
-The three lengths p, q, and l are arbitrarily assigned to r 1 , r 3 , and r 4 .
The other two variables are generated at random between chosen limits.Five thousand random crank-rocker linkages were generated using this procedure.

Calculation of coupler curves
As shown in Fig. 3, the positions of various links are represented as variables in the complex plane.All link lengths are known, as well as angles of r 1 (taken as zero) and r 2 .The following calculations (Eqs.3-8) determine the position of the coupler point P.
arg(r 5 ) = arg(r 3 ) + θ c (7) Repeating the calculations by varying the crank angle in the range ≤ θ 2 ≤ 2π , a set of complex numbers, V i , are obtained, which are the vertices of the coupler curve.

Calculation of Fourier descriptors
The curve is converted from vertices to length-angle representation, using Eqs.( 9)-( 11).
where l i is the ith side of the polygonal curve, l i is the length from the first to the ith vertex, and ∅ i is the change in angle at the ith vertex.The Fourier descriptors of the curve, 2m + 1 in number, are then calculated from Eqs. ( 12)-( 16) (Zahn and Roskies, 1972).The polar form of Fourier descriptors was selected as it is easier to normalize.
The amplitudes A k are already normalized, while the phase angles α k are normalized as follows to remove dependence on starting point, direction of curve traversal and mirroring (Buskiewicz et al., 2009).α = α j j , where j is the index of the first non-zero harmonic.

Design of artificial neural network
An artificial neural network (ANN) is a mathematical structure that takes a vector of inputs (22 normalized Fourier descriptors of a curve) and produces a set of outputs (the five dimensions of a four-bar mechanism).To train the network, it is provided with a large set of inputs and corresponding outputs so that it "learns" the relationship between inputs and outputs.After the network has been trained and tested, it can be used by providing an input (Fourier descriptors of a desired curve) and obtaining the output (dimensions of the mechanism that will produce a curve shaped like the desired curve).
A multilayer feed-forward neural network was selected and trained using back propagation.After some experimentation, m = 11 was selected in the above equations so that a total of 22 Fourier descriptors were generated for each curve.Accordingly, the neural network had 22 neurons in the input layer.The output layer had 5 neurons, representing linkage dimensions.The number of hidden layers and the number of neurons in each layer were varied until satisfactory performance was obtained.Specifications of the final network architecture are shown in Table 1.The functions named in that table are Matlab Neural Network Toolbox ™ functions.
It is useful to scale the inputs and outputs before training the neural network so that they fall within a specific range.This allows for efficient training but requires keeping track of scaled and unscaled values.Matlab mapping function mapminmax was used to provide linear scaling in the range [−1, 1].Training was carried out using the Broyden- Fletcher-Goldfarb-Shanno algorithm to reduce the performance function msereg, which is the average squared error between actual output and the desired output of the network.

Simulation and testing
After designing and training the neural network using 5000 cases, it was tested for a new set of 50 coupler curves not used in training.The dimensions of 50 four-bar linkages output by the network were then used to construct coupler curves.Checking of results was carried out by comparing dimensions of linkages and values of Fourier descriptors as well as visual comparison of the shapes of curves.

Example problems
In the first two example problems, a four-bar was chosen at random, the Fourier descriptors of its coupler curve calculated and supplied as input to the trained ANN.The ANN output dimensions of a four-bar were then optimized to minimize the difference between Fourier descriptors of input and output curves.Table 2 shows the comparison of linkage dimensions for the original four-bar, the output of ANN, and the final, optimized four-bar for each example.Figure 4 shows the comparison of the curve shapes in each case.For comparison, the output curves were superposed on the original curve as follows (Buskiewicz et al., 2009): the output curve is translated so that its centroid is positioned over the centroid of the original curve.The curve is then rotated about the centroid so that the orientations of the principal axes of the two curves match and finally the curve is scaled so that the lengths of the two curves match.
In the third example, a general desired curve was chosen rather than a coupler curve, as shown in Fig. 5  (20)

Discussion and conclusions
In the first two examples presented, the desired curve was a coupler curve obtained from a known four-bar mechanism.
The algorithm was able to find the same four-bar mechanism in the first case but converged to a different four-bar having similar coupler curve.This was observed in other example cases also.Sometimes the curve obtained is a mirror image of the original curve; however, that problem is easily corrected by "flipping" the four-bar.
In the third example, a general desired curve (not being a coupler curve) was used to determine the dimensions of a four-bar that will produce a coupler curve similar in shape.The results show that although the algorithm gets close, a significant difference remains in curve shape.This is most likely due to the limitations of available coupler curves that a four-bar can generate, rather than problems in the algorithm.
In conclusion, a new method for approximate dimensional synthesis of planar linkages has been proposed and examples of application presented.The method is seen to be successful provided the desired path is close to the type of curves the mechanism is able to create.Although four-bar coupler curves have wide-ranging shapes, it should be noted that the method is limited to simple, closed curves; open curves (such as those produced by double-rocker mechanisms) and curves with crunodes are excluded.Edited by: L. Birglen Reviewed by: two anonymous referees

Figure 2 .
Figure 2. Net angular bend of curve boundary as a function of curve length.

Figure 4 .
Figure 4. Example 1 (top row) and 2 (bottom row).On the left, the ANN output and on the right the optimized curve, both superposed on the original curve.

Figure 5 .
Figure 5. Example 3. (Left panel) The original curve, and (right panel) the original and the final curves compared.

Table 1 .
Structure of ANN used.

Table 2 .
Results for examples 1 and 2.