International Journal of Advanced Robotic Systems Inverse Kinematics of a Humanoid Robot with Non-spherical Hip: a Hybrid Algorithm Approach Regular Paper

This paper describes an approach to solve the inverse kinematics problem of humanoid robots whose construction shows a small but non negligible offset at the hip which prevents any purely analytical solution to be developed. Knowing that a purely numerical solution is not feasible due to variable efficiency problems, the proposed one first neglects the offset presence in order to obtain an approximate " solution " by means of an analytical algorithm based on screw theory, and then uses it as the initial condition of a numerical refining procedure based on the Levenberg‐Marquardt algorithm. In this way, few iterations are needed for any specified attitude, making it possible to implement the algorithm for real‐time applications. As a way to show the algorithm's implementation, one case of study is considered throughout the paper, represented by the SILO2 humanoid robot.


Introduction
The kinematic modeling of humanoid robots is in fact a more difficult problem when compared to the classical industry manipulators, due to the locomotion that these robots are expected to perform while maintaining, at the same time, their postural stability. It is a formidable computational challenge, especially for real-time applications, due to the high number of degrees of freedom, the complex kinematics configurations that may lead to non-analytical solutions and the constantly changing point of support that is not rigidly attached to the floor [1]. In order to control the motion of these humanoid robots, specific trajectories in task space are required; that is, a desired sequence of attitudes for the feet and the body are required for accomplishing the desired stable locomotion task.
In the context of rigid multi-body systems, as is the case of robots, task space is different from joint space where motor commands are issued. Hence, movement planning requires either a preset sequence generated with play-back techniques or a suitable coordinate transformation from task to joint space. The former method is very simple as it does not require a complex mathematical analysis; however, it is not systematic as it is based on empirical tests for each movement, which make it tedious and non practical. The latter one, based on coordinates transformation, is supposed to be found by solving the so called Inverse Kinematics (IK) problem, which arises from the fact that the inverse transformation is often complex and ill-posed [2].
It is known that the IK problem cannot be solved by means of systematic processes as it is highly dependent on the robot's kinematic structure, and that it also either yields to infinite, multiple, one or none solutions. Only in simple cases, as in the case when the kinematic chain has no more than 6 degrees-of-freedom (dof) and three joint axes intersect, the IK problem for position and orientation can be decoupled, as stated by the so popular method proposed by Pieper in his PhD thesis [3] [4]. This is the case of many industrial manipulators and some of the most popular humanoid robots, i.e. ASIMO of Honda, HRP-2 of AIST and Kawada Industries or HOAP-2 of Fujitsu [5]. However, even for singularity-free mechanisms, the presence of offsets prevents this fact. Therefore, closed-form solutions are difficult, if not impossible, to find [6]. Or if they exist, they are very specific for a given kinematic chain [7] [8] [9].
For this reason, numerical methods have been commonly used to solve the IK problem, by using the pseudoinverse of the Jacobian (or a modification of it) [2] [10], the Cyclic Coordinate Descent (CCD) method [11] [12] or a procedure based on iterative triangulation [13] [14]. Some authors also use neural approaches [15] [16] or computational approaches based on conformal geometric algebra [17] or symbolic preprocessing [18]. However, these ones cannot be as efficient as the analytical ones, as they may require several iterations (not known a priori) in order to reach a particular precision, leading in many cases to computationally expensive solutions, which can be numerically unstable [19] [20]. Not to mention that a numerical algorithm may converge to a local minima instead of the desired global one, represented by the desired solution [21].
This makes it even more difficult to develop real-time applications, as these ones require fast and efficient algorithms for computing the gait patterns required to achieve dynamical stability. Therefore, finding an analytical solution to the IK problem, or a solution that takes a minimum of iterations, makes it possible to develop controllers able to compensate dynamical effects by changing motion patterns in real-time.

SILO2 Humanoid Robot
SILO2 stands for Locomotion System based on two limbs. This humanoid robot belongs to a family of walking prototypes that have been developed in the Department of Automatic Control at the Institute of Industrial Automation in Madrid, Spain [22]. This one in particular is currently on development and it is planned to be upgraded until getting a complete humanoid kinematic structure of 23 dof. However, in the current stage only the locomotor unit has been entirely developed ( Figure 1).
As can be seen on this picture, this robot possesses 6 dof per leg: 3 at the hip, 1 at the knee, and 2 at the ankle. That is, each leg's mechanism is determined, so that each foot (or the body, depending on the basement link's election) can reach any desired attitude inside its workspace, defined by geometrical and mechanical constraints.
Joints are driven with two different types of actuators, as can be also noticed: Standard DC servomotors placed at the joint axis and non-linear transmission ratio actuators, used to improve the mechanical design by decreasing the energy consumption. The latter ones, patented as SMART (Special Mechatronic Actuator for Robot JoinTs) by the Department of Automatic Control at the Institute of Industrial Automation, are implemented as standard DC servomotors and four-bar linkages which provide the so called non-linear transmission ratio between the input angle driven by the servo and the output angle related to the joint variable.
Actually, three joints on each leg are driven by SMART actuators: One at the hip (abduction / adduction), one at the knee (flexion / extension), and one at the toe (flexion / extension), as can be seen on Figure 2a, 2b, and 2c.

Kinematic diagram
In order to build the kinematic diagram of this robot it is worth to notice that the presence of SMART actuators does not add complexity to the kinematic model, as could be thought in a first sight. The four-bar linkages are just transmission mechanisms placed between the servomotors and the actual joints, such that the joint variable is indeed a function of the corresponding servomotor's angle.  [23] Keeping this in mind, the kinematic structure of this robot can be represented with the diagram shown in Figure 3. In this diagram, joints are represented by cylinder-shaped icons, whose arrow represents its positive sense of motion. Link dimensions are displayed along with the corresponding constant denoted by i l , where side information is omitted due to symmetry reasons.
The body frame   D of the robot is oriented in such a way that the y axis points up and the x axis points in its movement direction. The z axis is then established to complete a right-hand frame.

Screw motion
Forward kinematics can be described in a more geometric way if a screw motion is associated to every joint [24]. A screw motion represents a rotation by an amount of  about an axis l followed by a translation by an amount d parallel to that axis, as can be seen on Figure 4. This axis is represented as a directed line  through a point ; q such that   .

      l q
The ratio h d /   is known as the pitch of the screw.  [24] In this way, if a point p is operated with the equivalent rigid motion transformation g, its final location ( Figure 4) is given by Where e   is the exponential matrix of the skew- The transformation g in (4) can also be represented as an exponential matrix, g e , In this way, a screw motion associated to a rotational joint

Product of exponentials formula
In the same way, we can fix every joint except s5 J , knowing that the foot's attitude has been modified by the s6 J 's action, then The expression in (9) is called the product of exponentials formula for the humanoid forward kinematics; that is, it describes the foot's attitude as a function of every joint in the kinematic chain [24].

Forward Kinematics parameters
As can be seen from expressions (9) and (6), in order to calculate the forward kinematics it is necessary to specify each exponential matrix si si e ;    that is, apart from the joint variable we need to define each axis direction si w and any point on each axis , si q as described in the body's reference From the kinematic diagram shown in Figure 3, each axis direction is defined as And a point on each axis is proposed as

Orientation coordinates
Consider the representation of the humanoid's foot (and its frame) as shown in Figure 5.
Such that, from an arbitrary rotation matrix these rotation coordinates can be calculated as

Humanoid Inverse Kinematics
By looking at the kinematic diagram shown in Figure 3, it is possible to notice that the implementation of the humanoid's hip is not spherical; that is, the first three axes do not intersect in one point. There is an offset represented by the link s2 L which prevents the usage of the kinematic decoupling method proposed by Pieper [3] to solve the IK problem. In this way, alternative geometric analytical solutions were also sought without success. However, a purely numerical solution is not feasible either due to the existence of a variable efficiency on its implementation.
For this reason, a hybrid approach is proposed. It consists on first finding an approximate analytical "solution" for the inverse kinematics problem by neglecting the presence of the offset at the hip, as it is small when compared to the actual size of the robot, and then to use this "solution" as the initial condition of a numerical method, so that the number of iterations needed be drastically reduced.
This idea is similar to the one proposed in [6]. However, the last one only deals with the case of a double universal joint placed at the wrist. On the other hand, the following procedure is not restricted to any particular kinematic configuration, as long as the offset is small compared to the size of the robot.

Approximate analytical "solution"
First, suppose that the three axes at the hip intersect in just one point, represented by the actual intersection of the first two axes. Likewise, suppose that the length of the third link is not 3 l , but 2 3 l l ,  in order to diminish the error.
By doing this, a purely analytical "solution" exists, so that it can be found by using the so-called Paden-Kahan methodology [24], which is based on the product of exponentials formula shown in (9) To do that, let us propose the following four points based on the reference attitude of the robot shown in Figure 3:  A point H p located at the position of the supposed spherical hip; that is, at the intersection of the axes of the first two joints: A point A p located at the position of the ankle; that is, at the intersection of the axes of the two last joints: A point L p located on the axis of the first joint:  A point D p located at the origin of the body frame: Having done this, the joint variables can be calculated as it is explained in the following [24]: Calculation of s2 q and s3 q Let us reorder again (27) and apply both sides to the point .

L p
Remember that this point is located on the axis of s1 J , so that the joint has no effect on this point. In such a way that s1  can be finally found by recognizing the expression in (43) as the first Paden-Kahan sub problem (P-K-1), after the substitution of q [24]; that is, It is worth to remark that this procedure may lead to a maximum of eight different joint configurations, due to the multiple solutions of P-K-2 and P-K-3 for equations (35), (39), and (42) (each one has two different solutions). However, it is possible to get rid of four among these ones, as it is natural to pre-select the knee-front configuration, and then to notice that the remaining four are not all valid ones, as not every constraint is considered in every calculation (the procedure required to get rid of information on constraints in order to apply the Paden-Kahan sub-problems).
By choosing the knee-front configuration only two solutions are valid, which can be selected by calculating the four candidate joint configurations and measuring the attitude's error generated by each one. Ideally, the two valid ones must lead to a zero attitude error; but, as this method is based on an approximation, only a minimum error may be achieved. In this way, the joint configuration which lead to lowest error is then selected as the "solution" of the problem.

Numerical refining
The approximate "solution" obtained by supposing a spherical hip generates significant errors that can not be neglected when dealing with gait generation. However, these ones are small compared to the actual size of the robot. This fact can be depicted in Figure 6, where both the real kinematic structure and the supposed one are shown having the same joint values.
As can be seen, for s3 16.35    (which is actually the joint limit), there is an error of 2.787 cm with respect to the end-effector's position, whereas the robot's size is approximately 1 m. In this way, if such approximate "solution" is used as the initial condition of a numerical method, the algorithm will likely converge to the desired solution instead of getting trapped in a local minima. Furthermore, the number of iterations needed for accomplishing a negligible error can be drastically reduced in most of the cases. These statements rely in the fact that the convergence of any numerical method almost entirely depends on the selection of the initial values [20].

Numerical algorithms
A numerical algorithm for this problem basically increments (or decrements) the joint configuration q by means of an increment vector q, D in a certain number of iterations; that is, :  q q q D in each one. To compute this q D there are many available methods which primarily use the Jacobian J, by taking advantage of the fact that [19] J Where x D is an increment of the end-effector's attitude.
One way of doing this is using the Moore-Penrose's pseudoinverse of the Jacobian † J , such that † Where e is the error vector between the desired attitude and the actual one.
The pseudoinverse provides the "best fit" solution to a system of linear equations that lacks of unique solution. However, it is prone to be unstable in the neighborhood of singularities, as the singular values of † J are calculated from the inverse of the singular values of J, which are small in the neighborhood of singularities [19].
The Levenberg-Marquardt's method (also known as the damped least squares' method) improves the pseudoinvere's behavior near the singularities, resulting in a stable way for computing . q D This is done by including a damping factor ,  such that [19]   Recall that the Jacobian relates differential increments in position and orientation of the end-effector to the differential increments of joint variables. Position's differential increments are effectively vectors with differential magnitude pointing in the movement's direction. In the other hand, orientation's ones are also vectors with differential magnitude, but pointing in the direction of the axis of rotation (unitary angular velocity vector).
Numerical algorithms deal with finite increments (errors), instead of differential ones (as an approximation). In this way, position and orientation errors are vectors with a finite magnitude, that point in the direction of the increment in the case of the former ones or in the direction of the axis of rotation in the case of latter ones.
So, whereas position error's calculation is straightforward orientation error's one is not so obvious. This is because the chosen orientation coordinates are not the Cartesian components of a rotational increment vector.
In order to obtain the desired orientation error from the chosen orientation coordinates error, it is necessary first to obtain an expression that relates the rate of change of those coordinates   Having done this, the orientation error can be obtained by arbitrarily replacing the orientation coordinates rate of change with the corresponding error to build ; R e that is,

Workspace
Let us consider two types of workspace: the ideal one, i W , defined by geometrical constraints; that is, by considering non-limited joints, and the real one, r W , which takes into account the joint limits, so that r i W W .  By having an analytical algorithm for the IK problem, it is possible to check a priori if a given attitude is inside the ideal workspace or not, in order to assure that a "solution" exists and avoid failures at the time of calculation. In this case, an approximate workspace can be found by noticing that only the solution for P-K-3 considers a restricted-domain function, represented by the arccosine, arccos(.) : 1,1 0, .
   So that if an unreachable attitude is specified, the argument of the arccosine function   D will be a number outside its domain. In this way, if 1 < D < 1  an approximate analytical "solution" exists.

Simulation results
In order to visually validate the algorithm proposed in this paper, a kinematic simulator was developed under the name of ARMS (Advanced Robot Motion Simulator) (Figure 7) [7]. This simulator uses a VRML (Virtual Reality Modeling Language) model of the humanoid robot, which is driven by specifying its joint coordinates. These ones are directly specified by the user, or calculated from a desired attitude which is specified in task space.
For testing purposes a series of attitudes were specified for each foot, by considering the body as the base link. Some attitudes were proposed as lying inside the real workspace and others, outside, or as lying only inside the ideal workspace but not inside the real one, in order to test the algorithm's behavior. One example of each case is reported, along with some screenshots of the corresponding results. Figure 8 shows the attitude reached by the model of the robot (frontal and sagittal views) after specifying that the right foot's sole should be located 75 cm below with respect to the pelvis and 20 cm just in front of it, while maintaining the reference attitude's distance between this foot and the sagittal plane of symmetry (17.3 cm). The right foot's orientation is also specified with a pitch angle of −20°. In the other hand, the location of the left foot's sole is specified to be 80 cm below with respect to the pelvis, 10 cm in front of it and 17.3 cm away from the sagittal plane of symmetry, while its orientation is specified with a roll angle of −10°, followed by a yaw angle of 30°. As can be seen with the aid of superimposed labels and the screenshot of the specified attitude and the obtained one ( Figure 9) the virtual robot not only reaches the desired goal, but it can be achieved with only 2 iterations.  Figure 10 shows again an attitude reached by the model of the robot. In this case, the right foot's sole was specified to be located 75 cm below with respect to the pelvis and 20 cm just in front of it as before, but now it is also desired a distance of 30 cm between this foot and the sagittal plane of symmetry. In the other hand, the left foot's location is specified to be a the same height but 20 cm behind the pelvis, at a distance of 5 cm from the sagittal plane of symmetry. Both feet are expected to maintain the reference orientation; that is, 0° for all the orientation coordinates.

Attitude inside the ideal workspace, but outside the real one defined by mechanical constraints
However, the desired attitude cannot be reached as it can be confirmed by noticing that the right foot's sole is a little below of the desired one (marked with the aid of superimposed labels), and because the orientation of the left foot is not the reference one. This can also be confirmed in Figure 11, where the difference between the desired attitude and the obtained one is noticeable, due to the saturation of joint's values. The process needed 3 iterations in this case.

Attitude outside the ideal workspace
Consider now the case when a desired attitude is outside the ideal workspace, represented by the case when the feet are specified to reach a distance impossible to achieve, even at full extension of the legs. In this case the kinematic simulator performs no action at all, as indicated by the label "Ideally impossible attitude" ( Figure  12).

Evaluation
The performance of the proposed hybrid algorithm was evaluated with respect to the number of iterations needed to accomplish a desired precision by means of statistical comparison with a purely numerical solution, as well as with respect to the mean time required for performing the requested computations in both cases, as a way to measure the achieved improvement of performance.
This evaluation was carried out over different sets of data consisting on 1000 random 6-tuples of joint variables The leg was also chosen in a random manner. Figure 12. The attitude is not inside the ideal workspace Each 6-tuple, along with the leg's choice, was used to obtain the corresponding foot's attitude by means of applying the forward kinematics algorithm. The resulting attitude was then taken as the input of the IK algorithm. In this way, it was assured that this input would lead to a solution, which was already known for testing and comparison purposes.
When testing the proposed algorithm, the foot's attitude was used as the input of the approximate analytical algorithm in such a way that the approximate "solution" was taken as the initial condition of the Levenberg-Marquardt method.
When testing the purely numerical solution, the initial condition of the Levenberg-Marquardt method was set arbitrarily as 0.  s q In both cases, an error vector magnitude less than 0.1 or a maximum of 1500 iterations were used as stop conditions. The maximum value for the parameter max  was also set to 0.01 (as this value led to the best performance through a set of tests). Then, the error between the desired attitude and the obtained one was computed and recorded, as well as the number of iterations required and the mean computation time.
This evaluation consisted on two different statistical populations described as follows: 1. The first one considered randomly generated attitudes inside the ideal workspace, but not necessarily inside the real one. These ones were obtained by constraining the random joint variables' values to −90° and 90°. 2. The second one considered randomly generated attitudes only inside the real workspace. In this case, the joint variables' values were constrained to the actual joint limits of the robot (Table 1).
This evaluation tests were implemented in Matlab R2012a, and performed on a Laptop Dell XPS L702X, which has an Intel(R) Core(TM) i7-2670QM CPU @ 2.20 GHz, 8 GB in RAM, and a 64-bit Operating System (Windows 7 Utimate).
6.1 Random attitudes generated inside the ideal workspace, but not necessarily inside the real one Figure 13a shows the histogram generated by the purely numerical approach, whereas Figure 13b shows the one generated by the proposed hybrid algorithm, obtained by constraining the random joint variables' values to −90° and 90°. In both cases, the histogram's range is set to 1 -50 or more iterations (samples over 50 iterations are accumulated over 50 in the histogram).  Table 2 also shows some numerical data associated with the evaluation; that is, the percentage of samples that succeeded to converge (within the specified precision) in 1500, 50, and 10 iterations, as well as the average error in position and orientation between the desired attitude and the obtained one (taking into account only the samples that succeeded to converge) and the mean time required per sample in both cases. As can be seen, the proposed algorithm shows an outstanding performance over the purely numerical one used in [19] or [21], as more than 91.4% of the samples are able to converge in 10 or less iterations, in contrast with the latter one which may need 50, 100, 1000 or more iterations to converge. In addition, the proposed algorithm is able to achieve a lower average error (with respect to position or orientation) while being almost 4 times faster.

Random attitudes generated inside the real workspace only
By taking into account the actual joint limits of the robot, both algorithms were compared once again. Figure 14a shows the histogram generated by the purely numerical approach, whereas Figure 14b shows the one generated by the proposed hybrid algorithm. The histogram's range is set again to 1 -50 or more iterations. Table 2 shows the corresponding numerical data associated with this evaluation.
Surprisingly, the proposed algorithm not only shows an outstanding performance over the purely numerical one, but a very good one feasible for implementation on realtime, as 99.5% of the samples converged in less than 10 iterations (in fact, 97.2% did it within 2 iterations). Notice that the average error is also lower than the previous case, and that the hybrid algorithm performs almost 5 times faster.  Table 3. Performance comparison of both algorithms considering randomly-generated attitudes inside the real workspace This paper proposed a semi-analytical algorithm for computing the IK of humanoid robots whose construction shows a small but non negligible offset at the hip (compared to its actual height) which prevents any purely analytical solution to be developed.
As a case of study, a robot with a non-typical kinematic structure, as it is the SILO2 prototype, is analyzed. However, the algorithm can be applied to any structure that possesses negligible offsets, so that an approximate analytical "solution" can be found after neglecting them, and then be used as the initial condition of a stable numerical method, ensuring in this way that the number of iterations needed will be drastically reduced (compared with the required ones if an arbitrary initial condition is proposed).
Besides that, as the approximate analytical "solution" is in the neighborhood of the desired target in the joint configuration space, it will be more likely that the numerical method reaches the desired solution, as the right minima is very near to the initial condition. So, this method will be as efficient as desired so long as the concerned offsets are small enough. This fact was also evaluated, as this algorithm needed only very few iterations: Less than 10 in most of the cases, or a maximum of 2 if the desired attitudes belonged to a typical gait; that is, attitudes that do not require big joint ranges to be performed. However, even non-typical motions can be achieved in an affordable computation time.
Concerning to the SILO2 robot, this method effectively solved its IK problem, so that it was possible to calculate precise gaits in real-time, as they were required by the control laws that had been previously developed by the team work at the Institute of Industrial Automation. Furthermore, the kinematic simulator developed during this work represented a useful tool for testing desired attitudes on a virtual model before doing it on the real prototype, avoiding in this way failures that may cause severe damages to the robot if it falls down. The simulator was very useful to test attitudes in this way, as many of them cannot be realized due to mechanical constraints, even when they were feasible during a certain gait. By recognizing these attitudes, the gait could be modified until getting a realizable and useful one, or they may also be used to provide guidelines for modifying the SMART actuators, by redesigning the size of the crank and the connecting road in every four-link mechanism, in order to improve the design of the humanoid.