Mathematical Foundation of Robotics, MFRO 14 (Use of Quaternion for Rotation ).
Transcript
okay so welcome back uh so we are trying to make you understand some basic uh principles of um orientation representation using quaternion and that is very important because uh this is not in robotics and any rigid body orientation this is widely being used nowadays thanks because of its programming is um and as i told you that a robot gripper orientation is very much prone to or in some cases very much prone to gimbal lock uh because of the construction itself three joint taxis are intersecting at a point and to follow piper's recommendation he says you know um robotics people know uh we've tried to follow industrial labor try to follow piper's recommendation so as to get um close from inverse kinematic solution and in doing so uh this is vulnerable so when a particular pose is given and your ripper is trying to orient itself with that pose so it is vulnerable for given long situation so it is better to program or represent pose using quarter name so quaternion as i told in the last class uh is nothing but vector representation in a four dimensional space where the three axis mutually perpendicular axis are all uh imaginary axis uh which are mutually perpendicular to a real axis okay and the quantity any quantity quaternion uh q1 is quoting actually can be represented by this one you see x i plus y j plus z k okay so another quantity can be represented by z1 so x2i plus y2 j plus z2 okay okay so on and so forth any any quantity can be represented uh in a generalized way i can write down q n equals to say w n plus x n i plus y n j plus j n k where i j k the fundamental rule which actually um hamiltonian wrote um is this one i squared equal to j square equal to k square equals to i j k equal to minus 1 this fundamental rule is followed everywhere in quadrant okay so as you know our i equals to j equals to k equals to the power of minus 1 the imaginary quantity okay now you know that i square there is very straightforward equal to minus 1 okay equal to j square equal to k square now how i j k equals to minus 1 for understanding that you will have to understand this one so this is my i this is j this is k orthogonal right handed coordinate system okay and they are representing the and then say somewhere down the line i cannot show you because there's a fourth dimension this is a real axis okay oriole axis which is representing these doubles now you see i they are iterate coordinate system so i j equals to k similarly you see i can write down so that i will not make any mistake i j k so i j will give you k j k will give you i i j j k will be given i and then ki k i will give you j okay and now say i j k i j so i can write uh now i j k right so i can write i j in place of i j i can write k so k into k equals to uh root over of minus 1 to the power of minus 1 equal to minus 1 so that's why i j k equals to minus 1 or maybe anyway okay i you have understood i think j k j k equals to i so i can write down instead of writing this j k i can write i so this is i square equal to minus 1 so in whatever way you can compute i j k equals to minus 1 okay so you should not try to confuse because i j k they are also orthogonal to each other so property of terminality has to be exploited and this is how the quaternion uh famous formula was given by hamiltonian okay for which he is very famous so understanding this that quaternion is nothing but representation of a complex number in four dimensional space where this is uh always valid this is that is i think it to understand any problem with quaternion now say if i would like to add sum to uh quantity okay it's two quartile right what will be the um so w1 plus w 2 plus x 1 plus x 2 i plus y 1 plus y 2 j plus z1 plus z2 okay so this will be another uh say composite quaternion will be of this nature okay so simply you need to you need to add the real numbers okay similarly minus q2 also you can do it now how about uh multiplication what will be the composite uh quaternion um um quaternion for q1 when i am multiplying them that is we are going to understand that okay that is very very important go to j plus z2 k okay and just algebra you can do okay on that w one over two plus w1 x2 i plus w1 y2 j plus w1 um z2 k plus so i am putting this sign to tell you that now multiplication of this quantity quaternion with this real number has been already taken place okay so now i am going to do this w 2 i plus x1 x2 i squared plus x1 y2 i j plus x1 z2 i okay 1 2 3 4 3 so 1 2 3 4 these are all done now multiply this quaternion by this quantity so then we are getting w2 y1 j plus y 1 x 2 j dot i plus y 1 by 2 j square plus y 1 j 2 j k so it's done very important that you should should not make any mistake and then remaining j 1 k to be multiplied with this quadrant z 1 w 2 k plus z1 x2 k dot i plus z1 y2 k dot j plus z1 z2 k square so this is very very important that the sequence i j because all we are going to do is apply this elegant formula here to make a simplified so simplification in fact all remain is simplification factorization which can be done very easily and will give you uh this uh product of the quadrant in this form which i am going to write ah you can do that okay for yourself q one dot q t equals to double w1 w3 minus x1 x2 minus y1 y2 minus z1 z2 plus so this is real part then w1 x2 plus w2 x1 plus y1 z2 minus z1 by 2 i plus w 1 y 2 plus y1 w2 plus plus z1 x2 minus x1 z2 [Music] w1 z2 plus z1 w2 plus x1 y2 minus y1 x2 okay and that actually symbolically now we write down okay uh this is all okay so this is real number part of the quaternion and these are all three complex um axis part so this real number is attached with uh axis i complex axis i this real number attacks with compression uh axis j j and this is complex uh k okay so this in actually the simplified form can be written as w1 x1 y1 j1 and w2 x2 by 2 j2 so p1 q2 equals to this okay and then this actually can be uh written in the following way w1w2 minus x1 x2 minus y1 y2 minus z1 z2 this is a real part this is fine but remember these are not the merely these three uh quantity i am writing they are little bit different double one x two plus next one w2 plus y1 plus z1 y2 minus y1 and z2 okay and y1 w1 y2 plus y1 w2 plus x1 z2 minus z1 x2 and w1 z2 plus z 1 w 2 plus y 1 uh x 2 minus x 1 by 2 okay so this we are concerning we are the imaginary portion and this is okay and this actually is written in this following form this is a standard form okay of product of two quadrant [Music] so now i am writing this you see this is a quotation this is a real part and this is a vector part imaginary part okay denoted by v 1 so v 1 is what v 1 is x 1 i plus y 1 j plus z 1 k okay and v 2 is x y plus y 2 j plus z to k that's all so this is actually in short form it is written like this this is actually is written like w1 w2 minus v1 dot v2 this is the real part and this is the imaginary part that is the imaginary part w 2 v 1 plus v2 cross v1 so this is a cross product so this is so called so this is you'll have to remember very important for uh programming perspective these are representing in this way is very very important and uh product of two part quarter nine uh is actually 49 is can be represented by this so this is real part okay so uh i think it is understand understandable to you and this is the uh complex part okay so you can easily verify you see a little bit careful so the here there are some sign changes and don't worry this is actually representing this so if you do this yourself so w1 w2 minus v1 dot v2 so you have 2 so this is perfect right what is this quantity this is v 1 dot v 2 isn't it because you have x 1 i plus y 1 j plus j 1 3 dot product nothing else plus so to the dot product x1 x2 x1 x2 and minus so this is minus x1 x2 and then y1 y2 that's it so this is done this is actually this okay and this is what this you will have to uh just calculate yourself very easy cross product how to calculate cross product between so v1 cross v2 as you know just recapitulation i j k you have x one y one z one x two y two z two so i y1 j2 minus z1 y2 minus j minus j x1 z2 minus z1 x2 plus k x 1 y 2 minus y 1 x 2 blah blah so you have got this and these two you can calculate so you put and you will get this okay so this is uh what quaternion product is all about and it has some uh very uh interesting properties we are going to it follows some properties of protein okay here in continents an important property a lot of those property it follow associated problem that means if i have q 1 q2 q3 this will be equals to q1 q2 q3 it is not commutative it is not commutative that is q1 q2 is not equal to q 2 q 1 and that represents that tells you that and it actually that's the reason it can perfectly calculate the orientation of rigid body okay so successive orientation in order you know they are order dependent can be captured this is also order dependent can be captured by quaternion magnitude magnitude of product q1 equals to say w1 equals to one dot q to equals to actually z1 by 2 minus y1 j2 square plus y1 w1 y2 plus y1 w2 plus x1 z2 minus z 1 x 2 square plus w 1 z 2 plus z 1 w 2 plus y 1 x 2 minus x 1 y 2 square so this is actually the magnitude of uh product of the quaternion and you will see that this magnitude is equals to just some simplification factorization will give you that uh w 1 square plus w 2 square plus sorry double square plus x1 squared plus y1 square plus z1 square okay times w2 plus x 2 square by 2 square j 2 square so what does it mean that means the two magnitude of the product of two quaternion is equals to you see what is this the magnitude of quaternion q1 squared times magnitude of the quaternion q2 square when come out from the square root so it is actually very important property for programmers right so actually uh magnitude of the product of quaternion is equals to the magnitude of the product of the individual quarter name right so is it clear and then some few more properties coordinate inverse what in an inverse of product this is also very useful a b inverse equals to b inverse a inverse this okay the quaternion follows this property uh if there are so many operations like uh quaternion q1 q2 up to qn so inversion of that will be equals to qn inversion q n minus 1 inversion dot dot q so in the reverse order you see this is the important property that got in an inverse of product okay is equals to in the reverse order the inversion of the individual quaternion so these useful properties uh are exploited uh extensively for capturing the orientation so after capturing the orientation of a rigid body now let us see how quaternion can be used for describing the rotation okay for that let us consider an orthogonal coordinate frame okay and let us consider a digit body um so this is a rigid body and say at any point p is a point on a digit body and this description is given by the position vector op and here is a uh here is my arbitrary um axis given by q of rotation and about that say we are rotating this rigid body by an angle theta so what will be the new description of p that can be directly obtained um from the quadrant in okay let us see q equals to w 0 plus x 0 i plus y 0 j plus z 1 okay then inversion of this will be equals to say minus okay okay and p is given by so next time okay so the new description which is given by a p after this rotation will be given by q p q inverse s and which of uh quaternion operation will be done on this and you get so extremely extremely simple for programmer computer can do very easily then x1 i plus y1 j plus k1 okay x zero high minus k2 okay okay so this is your cube this is a p and this is your inverse so very easily you can get the description of uh p after rotation so it is very useful uh quaternion is a huge field a lot of operations and research also going on because for create for describing homogeneous coordinate transformation uh get to be done by uh quaternion um because the description is not so compact uh like we want in robotics however for orientation um this is a very good tool and i hope that you have uh now understood basic of uh quoting in and how it can be used for rotation description so thank you for your attention stay safe bye