MASTER's THESIS Inverse Kinematics
Total Page:16
File Type:pdf, Size:1020Kb
2009:142 CIV MASTER'S THESIS Inverse Kinematics Rickard Nilsson Luleå University of Technology MSc Programmes in Engineering Computer Science and Engineering Department of Computer Science and Electrical Engineering Division of Computer Science 2009:142 CIV - ISSN: 1402-1617 - ISRN: LTU-EX--09/142--SE Preface The work for this thesis was conducted under the fall of 2007 at Agency9 AB in Luleºafor LuleºaUniversity of technology - Computer Sciene and Engineering. Agency9 wanted an evaluation for some of the most used methods that can solve inverse kinematics. I would like to thank all the guys at the o±ce, Tomas, Khashayar, Thomas, Lasse, Johan, Martin and Richard at Agency9 in Luleºa,who have listened and answered many questions. 1 Abstract The computer is getting more powerful every day and creating animations for a 3D model "on the fly” rather than pre-made animations is getting more feasible. A 3D model that is composed by segments and joints, formed for example like a human, can also be viewed as a kinematic model, the joints can be modi¯ed such that di®erent postures can be achieved for the model. A kinematic model have a hierarchic tree structure with a parent-child relationship. A change made to a parent propagates to its children. Interacting with a kinematic model can be done in two distinct ways, forward kinematics and inverse kinematics. The most common way of interacting with a kinematic model is by using forward kinematics, which works by changing each joint until a desirable posture is achieved. The other way, known as inverse kinematics is more complex and needs more computer resources, only need a direction or a position for any joint of where it should be. The inverse kinematic methods are all using a matrix called Jacobian matrix, which consists of all ¯rst-order partial derivates derived from a kinematic model. The main goal of this thesis is to evaluate current methods solving Inverse Kinematics and to see if it possible to create animations "on the fly” for a model. Contents 1 Introduction 3 1.1 Agency9 and AgentFX . 3 1.2 Problem formulation . 4 1.3 Delimitations . 4 2 Theory 5 2.1 Kinematics . 5 2.1.1 Degree of Freedom . 6 2.1.2 Constraints . 6 2.2 Forward Kinematics . 6 2.3 Inverse Kinematics . 7 2.3.1 Analytical Solver . 8 2.3.2 Iterative Solver . 9 2.3.3 Creating the Jacobian . 10 2.3.4 Using the Jacobian . 11 2.4 Solvers of inverse kinematics . 12 2.4.1 Transpose . 13 2.4.2 Pseudoinverse . 13 2.4.3 Damped Least Squares . 15 2.4.4 Singular Value Decomposition . 16 2.4.5 Full and Half Jacobian . 17 2.5 Scene Graph . 17 3 Implementation 19 3.1 COLLADA . 19 3.1.1 COLLADA Libraries . 20 3.1.2 Animation Library . 20 3.1.3 Visual Scene Library . 21 3.2 COLLADA and IK . 21 3.3 Deriving the Jacobian . 22 3.4 Mathematic Tools . 23 3.5 Animation . 23 1 CONTENTS CONTENTS 4 Evaluation 24 4.1 Constants . 24 4.1.1 Transpose . 24 4.1.2 Modi¯ed Transpose . 24 4.1.3 Damped Least Square . 25 4.1.4 Pseudoinverse with null space . 25 4.1.5 Constants linear relationship . 25 4.2 Models . 25 4.3 Tests . 26 4.4 Summary . 29 5 Conclusions 31 5.1 Future work . 32 Bibliography 34 2 Chapter 1 Introduction The performance of a computer is increasing every year and game producers have the ability to use it more extensively, not only for plain graphic improvements but also for other algorithms. Algorithms for creating animations "on the fly” that look natural for an animal or human with the ability to freely interact with the surrounding environment is hard to do with current animation techniques. Currently, most animations are pre-generated with few possibilities of beeing able to alter it. Special problems arises when there are dynamical changes in the enivronment. For instance if there is a pre made animation of a human arm reaching a door knob, the animation has to be made in consideration of exactly where the objects are positioned. If the door shrunk to half its size or just were moved further away the given animation would not change it self accordingly. To compensate for the dynamical changes in the environment a di®rent ap- proach is needed. Given a human arm model, which consists of a segments and joints connected to each other. By calculating the angular scalars for each joint such that the palm of the hand is as close it can get to the door knob would compensate for moving the door knob. This method is called Inverse Kinemat- ics (IK) and it is a way of making articulated models, for example a human or an animal model, to move more freely within its boundaries and be able to interact in a very di®erent manner. 1.1 Agency9 and AgentFX Agency9 AB1 was founded in 2003 with the vision to "make high-performance three dimensional visualization, 3D, available to everone and everywhere". At that time an advanced platform for real-time rendering of 3D graphics called AgentFX had been developed. AgentFX is basically a platform-independet 3D engine written in Java using OpenGL, which also supports loading the open 1www.agency9.se 3 1.2. PROBLEM FORMULATION CHAPTER 1. INTRODUCTION schema for digital-asset, known as COLLADA (see section 3.1), for creating scene-graphs. The AgentFX engine is tightly connected to the COLLADA- structure [14]. 1.2 Problem formulation There are two distinct methods of solving inverse kinematics, analytical and iterative. The iterative method gives the solution by solving an approximation of the system, and by updating the system with the output from the solver each iteration until it converges. The analytical method solves the whole system at once. The major part of this thesis will examine and evaluate several methods of solving inverse kinematics for articulated models and the possibility to use it together with AgentFX. It will mainly be focused on iterative methods, but also give a short survey of the analytical approach. An other large part of this thesis will be to create a scene-graph-like structure for the IK and to understand the properties of a scene-graph, such as how transformations of rotation and translation works with inverse kinematics. The ¯nal implemented solution must be general and dynamic in regard to the variety of models it shall be able to handle. A major problem to consider is that the system has to be robust since it's known that some methods that solves inverse kinematics becomes instable in some situations. The instability will be reflected in the articulated model as fast and undesirable movements. The system also has to be fast enough such that slower computers will be able to handle the algorithm, which can be very complex. Another important thing to point out is that the inverse kinematic applica- tion shall not be integrated within the AgentFX 3D-engine, it should only have the ability to control it. 1.3 Delimitations Since the IK solution shall not be integrated within the AgentFX 3D-engine it has to have its own tree structure much like a scene graph with node properties as translation and rotation transformations. Content created by the IK application can never be stored in a COLLADA ¯le since it is not de¯ned in its standard. As the algorithms of inverse kinematics are rather complex in nature, only a few algorithms using the Jacobian matrix will be implemented and tested. 4 Chapter 2 Theory This chapter introduces the fundamental principles of kinematics and how for- ward and inverse kinematics are de¯ned. Further will it present di®erent meth- ods for solving inverse kinematics. 2.1 Kinematics Kinematics is de¯ned as "study of motion: a branch of physics that deals with the motion of system without reference to force and mass" [1]. A kinematic model is built with segments and joints in a hierarchic structure with a parent- child relationship. Segments are considered as rigid bodies and joints are the link between the segments. By rotating a joint around an arbitrary axis that coinside within the joint, all its children will also rotate around the same axis since their relationship is set in that way that it inherits all its parents transformations. This can be seen in Figure 2.1 and Figure 2.2. Figure 2.1: A kinematic model, where Figure 2.2: Rotation around the axis the small spheres are joints. marked black that coincide within the grey joint. 5 2.2. FORWARD KINEMATICS CHAPTER 2. THEORY Joints can be given the ability to rotate and translate, if a joint can rotate around one axis it is said to have one degree of freedom. The same is for translations. 2.1.1 Degree of Freedom The number of degrees of freedom a joint can have is directly related to how many dimensions the joint is in. In three dimensions the joint can have at most three rotational and three transitional degrees of freedom, where the rotational and transitional axises are orthogonal sets. In short the degree of freedom explains how a joint can move in their space. Typcial joints in three dimensions are: hinge, pivot, universal and ball joints. Hinge and pivot joints have one degree of freedom, pivot joints are restricted to rotate along an axis towards its child. Universal joints are based on two hinge joints with 90 degree displacement of eachother, which means that it can bend in any direction.