Cookies

We use cookies to improve your browsing experience on our site, show personalized content and analyze site traffic. By choosing "I Accept", you consent to our use of cookies and other tracking technologies.

To the top
Close
Zengo - Forward Kinematics (FK) and Inverse Kinematics(IK)
Category:

Forward Kinematics (FK) and Inverse Kinematics(IK)

Zengo - óra7 minutes reading time
2024. 07. 22.

FK and IK models, in reality and beyond

IK (Inverse Kinematics) and FK (Forward Kinematics) are two fundamental methodologies used in robotics and animation to determine movements and positions. These techniques help ensure that robots and animated characters move in a natural and precise manner.

Imagine a simple everyday situation: a hand reaching out for a glass on the table. If we describe this movement using the FK method, we need to determine the angles of the shoulder, elbow, and wrist joints to make the hand reach the glass. In contrast, with the IK method, we simply specify the desired position of the hand's endpoint (grasping the glass), and the system calculates the necessary joint angles to achieve this position. Let's see how these two methods work.

Forward Kinematics (FK)

FK is a method used to calculate the movement of robot arms. With FK, the position and orientation of the robot arm's end-effector can be determined based on the robot's joint variables (such as angles or displacements). Using the movement and positioning defined by the joints, we can calculate the end-effector's position in space.

100%

How do we calculate FK?

Mathematically, FK involves a series of matrix multiplications. If we have a robot arm with 'n' degrees of freedom, each joint has a transformation matrix that describes its position. The end-effector's position and orientation are obtained by multiplying these transformation matrices.

Advantages

  • Simple calculation: FK requires simpler mathematical operations than IK, as it only involves matrix multiplications.
  • Determined result: The given joint angles and displacements always clearly define the end-effector's position and orientation.
  • Fast: FK can be calculated quickly, which is advantageous for real-time applications like robot control.

Disadvantages

  • Not target-position-based: FK is not suitable for determining the joint variables needed to reach a specific target position. This is the task of IK.
  • Limited application: FK is mainly used in situations where the joint angles are known and the end-effector's position needs to be determined.

Inverse Kinematics (IK)

Inverse Kinematics (IK) is a method used to determine the joint variables required for the robot arm's end-effector to reach the desired position and orientation. IK starts from the target position and calculates the necessary joint angles and displacements.

How do we calculate IK?

Calculating IK typically requires iterative methods since most cases lack a closed-form solution. One of the most commonly used methods is the Newton-Raphson method, which iteratively approximates the solution. The Jacobian matrix, containing the partial derivatives of the end-effector's position with respect to the joint variables, is used during the iterations.

Iterative methods

With iterative methods, we start with the initial joint variables and update them in each iteration as follows:

  1. Calculate the current position and orientation: Based on the current joint variables, calculate the end-effector's position and orientation using FK.
  2. Calculate the error:: Determine the displacement between the desired and current position/orientation.
  3. Calculate the Jacobian matrix: Based on the current joint variables, calculate the Jacobian matrix, which contains the change in the end-effector's position as a function of small changes in the joint variables.
  4. Update the joint variables: Use the pseudoinverse of the Jacobian matrix and the error vector to update the joint variables.
  5. Repeat the iteration: Repeat the process with the new joint variables until the error becomes sufficiently small.

Advantages

  • Target-oriented: IK allows us to determine the joint angles and other parameters needed for the end-effector (e.g., the robot's hand or tool) to reach the desired target in space.
  • Flexibility: IK can find solutions for various targets and orientations, making it suitable for diverse tasks and operations.
  • Mobility: It enables the planning and execution of complex movements and manipulations that would be difficult or impossible with the FK method.
  • Real-time applications: In certain implementations, IK can be applied quickly and efficiently in real-time systems operating in dynamic environments.

Disadvantages

  • Iterative solution: IK often requires iterative methods to find the solution, which may demand more computational resources and time, especially for more complex and multidimensional systems.
  • Singular points and multiple solutions: IK does not always find an evident solution, especially at singular points or within a limited range of motion. This can be problematic when the robot or manipulator cannot operate stably in certain positions.
  • Accuracy and stability: IK does not always ensure perfect accuracy and stability, particularly if the Jacobian matrix is not handled properly, or if the system faces computational errors, sensor errors, or mechanical faults.
  • Computational costs: IK's computational demands can be high, especially for systems with a large number of joints or more complex geometries.

FK and IK in Unreal Engine

FK and IK models are not only used in robotics but also appear in games. When performing an animation, the skeleton of the object is moved based on FK or IK.

In Unreal Engine, we have a particularly strong toolkit to build an IK skeleton, which has been further expanded in the current 5.4 version. Before diving into creating such a skeleton, let's look at an example of what the above-described mathematics results in reality.

100%

If we use the Mannequin character provided by the Engine, it already includes a full-body IK. This looks as shown in the picture. The yellow blocks are called IK targets. These serve as targets that the character will follow if possible. The mathematical calculations described above are behind this. This IK target is assigned to a specific joint. When moved, unlike FK, it also calculates the position of the joints located further back. When the wrist is moved, the entire arm will move. We can also set constraints for different joints. These constraints limit the maximum angle or displacement. Thus, an IK skeleton will be able to avoid taking on unnatural positions during movement. For example, we can't twist the Mannequin's elbow backward. This is demonstrated in the image below.

100%

With FK, if we change the wrist's position, the joints backward will not change. To make the arm take the position shown in the picture, we need to change all other points as well.

Control Rig

In Unreal Engine,Control Rig is a system that allows for creating and editing animations and movements in real-time. It is a tool that combines animation controllers, scripts, and various effects to create complex movements and interactions with characters or other elements. Control Rig enables dynamic adjustment of the character's movement or animation without pre-recording separate animation sequences.

In such a Control Rig, we decide whether to use the FK or IK model for animation and movement.

Modular Control Rig

A notable innovation in Unreal Engine 5.4 is that the otherwise non-trivial and often lengthy creation of a Control Rig can be done modularly. We can build such a Control Rig from predefined blocks. Later, we can decide whether the specific joints, ankle, and neck points move with FK or IK when we want to modify them.

The following image shows such a skeleton. The original skeleton did not have a Control Rig and the methodology needed for IK movement was not implemented. However, with this new, modular Control Rig, such a skeleton can be created in minutes.

100%

After this, we can decide with a single move whether we want to move the specific joints with IK or FK. To achieve this, we need a Sequencer. Here, we can choose the model that best suits the task.

100%

IK? FK? VR? Stewart platform? Yes!

We can see that both IK and FK models are indispensable in robotics and game development. Today's technology allows us to use these two methods together. We need to expand these two applications with virtual reality.

Stewart platform

But before diving into what such an ecosystem looks like, let's briefly and simply explain what a Stewart platform is.

100%

A Stewart platform is a parallel manipulator with six prismatic actuators, typically hydraulic lifters or electric linear actuators, fixed in pairs to three points on the platform's base plate and extending to three attachment points on the top plate. All 12 connections are made with universal joints. The devices located on the top plate can move in six degrees of freedom, which a freely suspended body can move in. Also known as 6-DoF due to its possible movements, it has many applications, such as in simulations. Therefore, we can use this technology for virtual reality.

VR simulation

Let's see what this looks like in reality. Take a VR application, like a flight simulator, as an example. The pilot in VR first assumes the correct posture to position themselves properly in the cockpit. At this time, the Stewart platform keeps the user level. Then the virtual takeoff begins. The VR headset measures the upward movement, and the pilot perceives moving up in the cockpit, seeing a bit more above the dashboard. Then the pilot rises, and the Stewart platform also starts to rise. Again, the VR headset measures the upward movement, but this time the upward movement experienced in the cockpit is undesirable. It would be very distracting for the pilot if their head went through the cockpit roof during every takeoff or shot out of the car's side during a turn. Therefore, the Stewart platform's movements must be subtracted from the VR headset's measured movements so that only the pilot's movements appear.

Direct kinematics (FK) is crucial for performing this task. The position of the actuators, which are typically measured very precisely, can be quickly used to calculate the platform's movement, which can then be subtracted from the measured headset movement. Sometimes external sensors, such as accelerometers, are placed on the platform to help subtract the movement. A direct kinematics model not only replaces these sensors but also, if done correctly, can improve latency, vibration resistance, and consistency. This results in an extremely immersive experience, where the control of the airplane in VR is detected not only by our brain but also by our body. This directly implies that motion sickness often occurring during VR sessions may be alleviated. Due to the real movement, our body—the inner ear—will experience similar motion as our brain.

Closing thoughts: The Role of Kinematics in Future Technologies

FK and IK play fundamental roles in both robotics and video game development. FK allows simpler, faster calculations that can be used in real-time applications like robot control and animations. On the other hand, IK provides the ability for robots and characters to move purposefully and naturally, solving complex positioning and orientation challenges.

The tools offered by Unreal Engine, especially the Control Rig and the modular approach, allow us to easily combine FK and IK models in game development. This way, we can create richer, more realistic animations that enhance the gaming experience.

The combination of VR and the Stewart platform further expands the possibilities, enabling fully immersive simulations that are not only spectacular but also provide physically tangible experiences for users. The use of such technologies can alleviate the common motion sickness experienced in VR, enhancing user comfort and satisfaction.

Therefore, the methods of kinematics are not only indispensable in the current technological world but also crucial elements for future development. The integration and development of FK and IK models contribute to making both robots and virtual characters increasingly intelligent and lifelike, opening up new horizons in technological innovations.

Article written by F. Tamás - Unreal Engine Developer

Article translated by F. Flóra