-
Notifications
You must be signed in to change notification settings - Fork 37
Lesson 10: Robot Inverse Kinematics Using Screw Theory ‐ Analytical and Numerical Approaches
Up to now, we have become familiar with forward and velocity kinematics. We saw that forward kinematics calculates the position and orientation of the robot end-effector from the joint coordinates q (FK:
Formally, the inverse kinematics problem can be stated as follows:
Given an
Inverse kinematics is a very important problem in the sense that here, we want to control the end-effector's configuration for it to be able to interact with the world. However, it is a more complicated problem to solve than the forward kinematics. In forward kinematics, we will have a unique end-effector configuration for a given set of joint values, but the inverse kinematics problem can have zero, one, or multiple solutions for the joint values q that can produce the given desired end-effector configuration.
There are two approaches to solving the inverse kinematics of an open-chain robot:
- Analytic approach to inverse kinematics in which closed-form solutions for the joint variables can be found. Here, geometric approaches to the problem are utilized. These analytic solutions may not always exist.
- Iterative numerical approach to inverse kinematics in which Jacobian is used to iteratively find a solution using the Newton-Raphson method. An initial guess for the solution should be made, and then this method iteratively pushes the initial guess towards a solution. This approach will only give us one solution and not all possible solutions.
As always, let's begin our discussion with a simple example.
Consider the 2R planar robot arm depicted in the figure below:
We want to determine the set of joint angles that can produce a desired end-effector position (x,y).
In order to first geometrically solve this and find an analytic solution, let's first intuitively take a look at the stated problem and possible solutions.
We first start by looking into the workspace of this 2R robot arm. Just a reminder that the workspace of a robot is a specification of the reachable configurations of the end-effector. If you are not familiar with the concept of workspace and its difference with the configuration space, you can read the lessons below first:
https://mecharithm.com/learning/lesson/task-space-and-workspace-for-robots-102 https://mecharithm.com/learning/lesson/configuration-space-topology-representation-robot-5
As you see in the simulation video below, the workspace of a 2R robot depends on the lengths of the links of the robot arm. If
2r.robot.arm.workspace.mp4
For now, let's assume that
2r.planar.robot.arm.inverse.kinematics.simulation.mp4
Let's now find a set of joint angles
From the figure above and using the law of cosines, we can write:
Also, by using the law of cosines again on another triangle, we can get a similar equation for
The angle
Start of the note on atan2(y,x)
atan2(y,x) is a two-argument function that is similar to arctangent, but the difference is that since
Arctangent does not differentiate between angles in the first and third quadrants as well as angles in the second and fourth quadrants (the first and the third quadrants are shown as an example), and in robotics, we prefer the four-quadrant arctangent to make the quadrant in which the angle lies clear.
End of the note on atan2(y,x)
With these angles, the elbow down solution is:
and the elbow up solution is:
Note that as we discussed earlier, if (x,y) is in the white region of the annulus, then no solution exists, and there is no set of joint angles that can provide the desired position. Furthermore, for the case where (x,y) is at the boundary of the workspace,
Question: Considering the inverse kinematics of the 2R planar robot arm, how many solutions do you think exist for the inverse kinematics problem of the 3R planar robot arm?
If the inverse kinematics equations cannot be solved analytically, iterative numerical techniques may be utilized. Moreover, numerical methods are frequently employed to enhance the precision of analytic solutions, even when such solutions are available. In this case, the analytic solution can be used as an initial guess for the iterative numerical approach. For this purpose, we will use Newton–Raphson method, which is an integral method in nonlinear root finding. In situations where there is no exact solution exists, we will need optimization methods to find the closest approximate solution. If the manipulator is redundant, there will be infinite solutions to the inverse kinematics problem. In this case, we need to find a solution that is optimal with respect to some criterion.
Now, let's start by providing a general algorithm for numerical inverse kinematics using the Newton-Raphson method. Note that I will not go over the details behind the Newton-Raphson method, as most engineering students have encountered it in their numerical analysis courses, and I will directly go to its application to find the numerical inverse kinematics for open chain robot arms.
Suppose that
Solving the inverse kinematics means that we need to find the set of joint angles that can take the end-effector frame {b} to the desired frame {d}. Before solving this problem, let's first take a brief look at the Newton-Raphson method for nonlinear root finding.
The Newton-Raphson method is a powerful technique for finding approximate solutions (roots) of a nonlinear equation of the form
Step 1. Start by selecting an initial guess
Step 2. Find the tangent line: At the current guess
Where,
Step 3. Now, we should solve for the next approximation. To find the next approximation,
From here, solve for
This is the core equation of the Newton-Raphson method. It calculates the next approximation based on the current one and the function's value and derivative at that point:
Step 4. Repeat steps 2 and 3 until you achieve the desired level of accuracy or until
Step 5. Now, we should check for convergence. Monitor the convergence of the method by calculating the absolute error at each iteration:
If this value becomes very small, you can stop the iterations since you've likely found a good approximation of the root.
As a very simple example, consider
newton_raphson_method_one_D_example.mp4
The above algorithm was for when f is a function that maps real numbers to real numbers (1D case):
Here
Summary:
- Start with an initial guess
$x_0 \in \mathbb{R}^n$ . - Apply the above update formula iteratively to find
$x_{k+1}$ . - Continue until a convergence criterion is met, e.g., when the norm
$||f(x_{k+1})||$ is less than a specified tolerance or when the next value is so close to the previous value.
Notes:
- The method requires that the Jacobian is invertible at each iteration.
- Convergence is not guaranteed and can be sensitive to the initial guess.
Now let's see how we can apply this algorithm to solve inverse kinematics in robotics.
Applying the Newton-Raphson method to solve inverse kinematics problem numerically involves using the method to find joint variables (angles or positions) that result in a desired end-effector position or orientation.
Let's first start with the coordinate vector case. Suppose, we express the end-effector frame using a coordinate vector
- Given
$x_d \in \mathbb{R}^m$ , start with an initial guess$q_0 \in \mathbb{R}^n$ . - Apply the update iteratively:
$q_{k+1} = q_k + J^{-1}(q_k)(x_d - f(q_k))$ . Here, J is the Jacobian matrix that represents the partial derivatives of the end-effector positions with respect to the joint variables (we know from the velocity kinematics lesson that this Jacobian is called the coordinate Jacobian of the robot). - Continue until the norm of the error,
$||x_d - f(q_k)||$ , is less than a specified tolerance, indicating that the end-effector is sufficiently close to the desired pose (or alternatively, you can continue until the next value of x is sufficiently close to the previous value of x).
Note that the initial guess,
Also, we should remember that the Jacobian is not always invertible (in fact, in most cases in robotics). We can address this computational problem by using the Moore–Penrose pseudoinverse
We can also use MATLAB or Python to calculate the pseudoinverse. The pinv function in MATLAB and the numpy.linalg.pinv function in Python can do this for you. Therefore, the update in the above algorithm can be rewritten as:
There's an issue with this first version, however, as it doesn't suit our approach that considers frames rather than coordinate points. Now, we need to go back to our frames at the beginning of this section and modify the above algorithm to work with frame transformations instead of coordinate points.
In the above algorithm, we could simply calculate the error by subtracting the forward kinematics solution at the specific joint position from the desired end-effector position since both were vectors. Now we have the frame
Like the concepts of position and velocity in physics, twist and screw motion are related to each other. If body twist
Where
Now, we can update our Newton-Raphson inverse kinematics algorithm for frame transformations:
- Given the desired end-effector frame transformation
$T_{sd}$ , start with an initial guess for the joint angles, denoted as$q_0 \in \mathbb{R}^n$ . - Define the "error" transformation matrix as
$T_{bd}(q_i) = T_{sb}^{-1}(q_i) T_{sd}$ , where$q_i$ is the current guess for the joint angles. - We seek to minimize the error between the current end-effector configuration
$T_{sb}(q_i)$ and the desired configuration$T_{sd}$ . We represent this error as a body twist$[\mathcal{V}_b]$ , which can be computed using the matrix logarithm:
- Update the joint angles
$q_{i+1}$ iteratively, we use the following equation:
Where
- Continue the iteration until the error (represented by
$[\mathcal{V}_b]$ ) is sufficiently small, indicating that the end-effector is close to the desired frame configuration; alternatively, until when the new joint angle is close enough to the previous calculated joint angle.
Using the numerical inverse kinematics algorithm that we learned above, write a MATLAB code that solves the inverse kinematics solution for the 2R planar robot arm depicted at the beginning of this lesson. Find the set of joint angles that can take the end-effector frame to the following desired pose:
Notes:
- Suppose
$L_1 = 2, L_2 = 1$ . - You also have
$T_{sb}$ from forward kinematics. You just need to evaluate it at the current guess in the for loop. - You already have the space Jacobian for this arm from the previous class activity. Use that and convert it to the body Jacobian using the adjoint transformation.
- The algorithm can be implemented by a simple for or while loop.
- It is easy to set the convergence criteria as when the previous calculated angles are close enough to the current calculated joint angles. abs function in MATLAB can help you with the norm
- pinv function calculates the pseudo-inverse in MATLAB.
- logm function calculates the matrix logarithm in MATLAB.
- Submit the code as it will be graded.
- Kevin, M.L. and Frank, C.P., 2017. Modern robotics: mechanics, planning, and control
- Murray, R.M., Li, Z. and Sastry, S.S., 2017. A mathematical introduction to robotic manipulation. CRC press.
- Corke, P., 2023. Robotics, Vision and Control: Fundamental Algorithms in Python (Vol. 146). Springer Nature
- https://www.wolfram.com/mathematica/