Inverse Kinematics (IK) is defined as the problem of determining a set of appropriate joint configurations for which the end effectors move to desired positions as smoothly, rapidly, and as. Inverse Kinematics is a method to find the inverse mapping from W to Q: Q = F−1(W) 2. The inverse kinematics problem has a wide range of applications in robotics. Most of our high level problem solving about the physical world is posed in Cartesian space.
Modeling Inverse Kinematics in a Robotic Arm
The forward kinematics problem is to be contrasted with the inverse kinematics problem, which will be studied in the next chapter, and which is concerned with determining values for the joint variables that achieve a desired position and orientation for the end-effector of the robot.
This example shows how to use a fuzzy system to model the inverse kinematics in a two-joint robotic arm.
What Is Inverse Kinematics?
Kinematics is the science of motion. In a two-joint robotic arm, given the angles of the joints, the kinematics equations give the location of the tip of the arm. Inverse kinematics refers to the reverse process. Given a desired location for the tip of the robotic arm, what should the angles of the joints be so as to locate the tip of the arm at the desired location. There is usually more than one solution and can at times be a difficult problem to solve.
This is a typical problem in robotics that needs to be solved to control a robotic arm to perform tasks it is designated to do. In a 2-dimensional input space, with a two-joint robotic arm and given the desired coordinate, the problem reduces to finding the two angles involved. The first angle is between the first arm and the ground (or whatever it is attached to). The second angle is between the first arm and the second arm.
Figure 1: Illustration showing the two-joint robotic arm with the two angles, theta1
and theta2
Why Use Fuzzy Logic?
For simple structures like the two-joint robotic arm, it is possible to mathematically deduce the angles at the joints given the desired location of the tip of the arm. However with more complex structures (for example: n-joint robotic arms operating in a 3-dimensional input space) deducing a mathematical solution for the inverse kinematics may prove challenging.
Using fuzzy logic, we can construct a fuzzy inference system that deduces the inverse kinematics if the forward kinematics of the problem is known, hence sidestepping the need to develop an analytical solution. Also, the fuzzy solution is easily understandable and does not require special background knowledge to comprehend and evaluate it.
In the following section, a broad outline for developing such a solution is described, and later, the detailed steps are elaborated.
Overview of Fuzzy Solution
Since the forward kinematics formulae for the two-joint robotic arm are known, x and y coordinates of the tip of the arm are deduced for the entire range of angles of rotation of the two joints. The coordinates and the angles are saved to be used as training data to train an ANFIS (adaptive neuro-fuzzy inference system) network.
During training, the ANFIS network learns to map the coordinates (x
, y
) to the angles (theta1
, theta2
). The trained ANFIS network is then used as a part of a larger control system to control the robotic arm. Knowing the desired location of the robotic arm, the control system uses the trained ANFIS network to deduce the angular positions of the joints and applies force to the joints of the robotic arm accordingly to move it to the desired location.
What Is ANFIS?
ANFIS stands for adaptive neuro-fuzzy inference system. It is a hybrid neuro-fuzzy technique that brings learning capabilities of neural networks to fuzzy inference systems. The learning algorithm tunes the membership functions of a Sugeno-type fuzzy inference system using the training input/output data.
In this case, the input/output data refers to the 'coordinates/angles' dataset. The coordinates act as input to the ANFIS and the angles act as the output. The learning algorithm teaches the ANFIS to map the coordinates to the angles through a process called training. At the end of training, the trained ANFIS network would have learned the input-output map and be ready to be deployed into the larger control system solution.
Data Generation
Let theta1
be the angle between the first arm and the ground. Let theta2
be the angle between the second arm and the first arm (Refer to Figure 1 for illustration). Let the length of the first arm be l1
and that of the second arm be l2
.
Assume that the first joint has limited freedom to rotate and it can rotate between 0 and 90 degrees. Similarly, assume that the second joint has limited freedom to rotate and can rotate between 0 and 180 degrees. (This assumption takes away the need to handle some special cases which will confuse the discourse.) Hence, 0<=theta1<=pi/2
and 0<=theta2<=pi
.
Figure 2: Illustration showing all possible theta1
and theta2
values.
Now, for every combination of theta1
and theta2
values the x and y coordinates are deduced using forward kinematics formulae.
The following code snippet shows how data is generated for all combination of theta1
and theta2
values and saved into a matrix to be used as training data. The reason for saving the data in two matrices is explained in the following section.
The following plot shows all the X-Y data points generated by cycling through different combinations of theta1
and theta2
and deducing x and y coordinates for each. The plot can be generated by using the code-snippet shown below. The plot is illustrated further for easier understanding.
Figure 3: X-Y coordinates generated for all theta1
and theta2
combinations using forward kinematics formulae
Building ANFIS Networks
One approach to building an ANFIS solution for this problem, is to build two ANFIS networks, one to predict theta1
and the other to predict theta2
.
In order for the ANFIS networks to be able to predict the angles they have to be trained with sample input-output data. The first ANFIS network will be trained with X and Y coordinates as input and corresponding theta1
values as output. The matrix data1
contains the x-y-theta1
dataset required to train the first ANFIS network. Therefore data1
will be used as the dataset to train the first ANFIS network.
Similarly, the second ANFIS network will be trained with X and Y coordinates as input and corresponding theta2
values as output. The matrix data2
contains the x-y-theta2
dataset required to train the second ANFIS network. Therefore data2
will be used as the dataset to train the second ANFIS network.
To train an ANFIS network, first specify the training options using the anfisOptions
command. For this example, specify an FIS object with 7
membership functions for each input variable. Train the system for 150
epochs and suppress the Command Window display of training information.
Train an ANFIS system using the first set of training data, data1
.
Change the number of input membership functions and train an ANFIS system using the second set of training data, data2
.
For this example, the number of input membership functions and training epochs were selected based on experimentation with different potential values.
anfis1
and anfis2
represent the two trained ANFIS networks that will be deployed in the larger control system.
Once the training is complete, the two ANFIS networks have learned to approximate the angles (theta1
, theta2
) as a function of the coordinates (x
, y
). One advantage of using the fuzzy approach is that the ANFIS network can now approximate the angles for coordinates that are similar but not exactly the same as it was trained with. For example, the trained ANFIS networks are now capable of approximating the angles for coordinates that lie between two points that were included in the training dataset. This will allow the final controller to move the arm smoothly in the input space.
We now have two trained ANFIS networks which are ready to be deployed into the larger system that will utilize these networks to control the robotic arms.
Validating ANFIS Networks
Having trained the networks, an important follow up step is to validate the networks to determine how well the ANFIS networks would perform inside the larger control system.
Since this example problem deals with a two-joint robotic arm whose inverse kinematics formulae can be derived, it is possible to test the answers that the ANFIS networks produce with the answers from the derived formulae.
Assume that it is important for the ANFIS networks to have low errors within the operating range 0<x<2
and 8<y<10
.
The theta1
and theta2
values are deduced mathematically from the x and y coordinates using inverse kinematics formulae.
THETA1D
and THETA2D
are the variables that hold the values of theta1
and theta2
deduced using the inverse kinematics formulae.
Robot Inverse Kinematics
theta1
and theta2
values predicted by the trained ANFIS networks are obtained by using the command evalfis
which evaluates a FIS for the given inputs.
Here, evalfis
is used to find out the FIS outputs for the same x-y values used earlier in the inverse kinematics formulae.
Now, we can see how close the FIS outputs are with respect to the deduced values.
The errors are in the 1e-3
range which is a fairly good number for the application it is being used in. However this may not be acceptable for another application, in which case the parameters to the anfis
function may be tweaked until an acceptable solution is arrived at. Also, other techniques like input selection and alternate ways to model the problem may be explored.
Building a Solution Around the Trained ANFIS Networks
Now given a specific task, such as robots picking up an object in an assembly line, the larger control system will use the trained ANFIS networks as a reference, much like a lookup table, to determine what the angles of the arms must be, given a desired location for the tip of the arm. Knowing the desired angles and the current angles of the joints, the system will apply force appropriately on the joints of the arms to move them towards the desired location.
The invkine command launches a GUI that shows how the two trained ANFIS networks perform when asked to trace an ellipse.
Figure 4: GUI for Inverse Kinematics Modeling.
The two ANFIS networks used in the example have been pretrained and are deployed into a larger system that controls the tip of the two-joint robot arm to trace an ellipse in the input space.
The ellipse to be traced can be moved around. Move the ellipse to a slightly different location and observe how the system responds by moving the tip of the robotic arm from its current location to the closest point on the new location of the ellipse. Also observe that the system responds smoothly as long as the ellipse to be traced lies within the 'x' marked spots which represent the data grid that was used to train the networks. Once the ellipse is moved outside the range of data it was trained with, the ANFIS networks respond unpredictably. This emphasizes the importance of having relevant and representative data for training. Data must be generated based on the expected range of operation to avoid such unpredictability and instability issues.
See Also
anfis
| evalfis
Related Topics
Inverse kinematics is the mathematical process of recovering the movements of an object in the world from some other data, such as a film of those movements, or a film of the world as seen by a camera which is itself making those movements. This is useful in robotics and in film animation.
In robotics, inverse kinematics makes use of the kinematics equations to determine the joint parameters that provide a desired position for each of the robot's end-effectors.[1] Specification of the movement of a robot so that its end-effectors achieve the desired tasks is known as motion planning. Inverse kinematics transforms the motion plan into joint actuator trajectories for the robot. Similar formulae determine the positions of the skeleton of an animated character that is to move in a particular way in a film, or of a vehicle such as a car or boat containing the camera which is shooting a scene of a film. Once a vehicle's motions are known, they can be used to determine the constantly-changing viewpoint for computer-generated imagery of objects in the landscape such as buildings, so that these objects change in perspective while themselves not appearing to move as the vehicle-borne camera goes past them.
The movement of a kinematic chain, whether it is a robot or an animated character, is modeled by the kinematics equations of the chain. These equations define the configuration of the chain in terms of its joint parameters. Forward kinematics uses the joint parameters to compute the configuration of the chain, and inverse kinematics reverses this calculation to determine the joint parameters that achieve a desired configuration.[2][3][4]
- 4Approximating solutions to IK systems
Kinematic analysis[edit]
Kinematic analysis is one of the first steps in the design of most industrial robots. Kinematic analysis allows the designer to obtain information on the position of each component within the mechanical system. This information is necessary for subsequent dynamic analysis along with control paths.
Inverse kinematics is an example of the kinematic analysis of a constrained system of rigid bodies, or kinematic chain. The kinematic equations of a robot can be used to define the loop equations of a complex articulated system. These loop equations are non-linear constraints on the configuration parameters of the system. The independent parameters in these equations are known as the degrees of freedom of the system.
While analytical solutions to the inverse kinematics problem exist for a wide range of kinematic chains, computer modeling and animation tools often use Newton's method to solve the non-linear kinematics equations.
Other applications of inverse kinematic algorithms include interactive manipulation, animation control and collision avoidance.
Inverse kinematics and 3D animation[edit]
Inverse kinematics is important to game programming and 3D animation, where it is used to connect game characters physically to the world, such as feet landing firmly on top of terrain (see [5] for a comprehensive survey on Inverse Kinematics methods used in Computer Graphics).
An animated figure is modeled with a skeleton of rigid segments connected with joints, called a kinematic chain. The kinematics equations of the figure define the relationship between the joint angles of the figure and its pose or configuration. The forward kinematic animation problem uses the kinematics equations to determine the pose given the joint angles. The inverse kinematics problem computes the joint angles for a desired pose of the figure.
It is often easier for computer-based designers, artists, and animators to define the spatial configuration of an assembly or figure by moving parts, or arms and legs, rather than directly manipulating joint angles. Therefore, inverse kinematics is used in computer-aided design systems to animate assemblies and by computer-based artists and animators to position figures and characters.
The assembly is modeled as rigid links connected by joints that are defined as mates, or geometric constraints. Movement of one element requires the computation of the joint angles for the other elements to maintain the joint constraints. For example, inverse kinematics allows an artist to move the hand of a 3D human model to a desired position and orientation and have an algorithm select the proper angles of the wrist, elbow, and shoulder joints. Successful implementation of computer animation usually also requires that the figure move within reasonable anthropomorphic limits.
Analytical solutions to inverse kinematics[edit]
An analytic solution to an inverse kinematics problem is a closed-form expression that takes the end-effector pose as input and gives joint positions as output, . Analytical inverse kinematics solvers can be significantly faster than numerical solvers and provide more than one solution for a given end-effector pose.
The IKFast open-source program can solve for the complete analytical solutions of most common robot manipulators and generate C++ code for them. The generated solvers cover most degenerate cases and can finish in microseconds on recent computers.[promotional language]
Approximating solutions to IK systems[edit]
There are many methods of modelling and solving inverse kinematics problems. The most flexible of these methods typically rely on iterative optimization to seek out an approximate solution, due to the difficulty of inverting the forward kinematics equation and the possibility of an empty solution space. The core idea behind several of these methods is to model the forward kinematics equation using a Taylor series expansion, which can be simpler to invert and solve than the original system.
The Jacobian inverse technique[edit]
Inverse Kinematics Algorithm
The Jacobian inverse technique is a simple yet effective way of implementing inverse kinematics. Let there be variables that govern the forward-kinematics equation, i.e. the position function. These variables may be joint angles, lengths, or other arbitrary real values. If the IK system lives in a 3-dimensional space, the position function can be viewed as a mapping . Let give the initial position of the system, and
be the goal position of the system. The Jacobian inverse technique iteratively computes an estimate of that minimizes the error given by .
For small -vectors, the series expansion of the position function gives:
Inverse Kinematics Pdf Free
Where is the (3 x m) Jacobian matrix of the position function at .
Note that the (i, k)-th entry of the Jacobian matrix can be determined numerically:
Where gives the i-th component of the position function, is simply with a small delta added to its k-th component, and is a reasonably small positive value.
Taking the Moore-Penrose pseudoinverse of the Jacobian (computable using a singular value decomposition) and re-arranging terms results in:
Where .
Applying the inverse Jacobian method once will result in a very rough estimate of the desired -vector. A line search should be used to scale this to an acceptable value. The estimate for can be improved via the following algorithm (known as the Newton-Raphson method):
Once some -vector has caused the error to drop close to zero, the algorithm should terminate. Existing methods based on the Hessian matrix of the system have been reported to converge to desired values using fewer iterations, though, in some cases more computational resources.
Heuristic Methods[edit]
The Inverse Kinematics problem can also be approximated using heuristic methods. These methods perform simple, iterative operations to gradually lead to an approximation of the solution. The heuristic algorithms have low computational cost (return the final pose very quickly), and usually support joint constraints. The most popular heuristic algorithms are: Cyclic Coordinate Descent (CCD)[6], and Forward And Backward Reaching Inverse Kinematics (FABRIK)[7].
Inverse Kinematics Math
See also[edit]
Inverse Kinematics Example Pdf
References[edit]
- ^Paul, Richard (1981). Robot manipulators: mathematics, programming, and control : the computer control of robot manipulators. MIT Press, Cambridge, MA. ISBN978-0-262-16082-7.
- ^J. M. McCarthy, 1990, Introduction to Theoretical Kinematics, MIT Press, Cambridge, MA.
- ^J. J. Uicker, G. R. Pennock, and J. E. Shigley, 2003, Theory of Machines and Mechanisms, Oxford University Press, New York.
- ^J. M. McCarthy and G. S. Soh, 2010, Geometric Design of Linkages, Springer, New York.
- ^A. Aristidou, J. Lasenby, Y. Chrysanthou, A. Shamir. Inverse Kinematics Techniques in Computer Graphics: A Survey. Computer Graphics Forum, 37(6): 35-58, 2018.
- ^D. G. Luenberger. 1989. Linear and Nonlinear Programming. Addison Wesley.
- ^A. Aristidou, and J. Lasenby. 2011. FABRIK: A fast, iterative solver for the inverse kinematics problem. Graph. Models 73, 5, 243–260.
External links[edit]
- Robotics and 3D Animation in FreeBasic(in Spanish)
- Analytical Inverse Kinematics Solver - Given an OpenRAVE robot kinematics description, generates a C++ file that analytically solves for the complete IK.
- HowStuffWorks.com article How do the characters in video games move so fluidly? with an explanation of inverse kinematics