Kinematics X Dynamics
Kinematics
Kinematics Keyframing requires that the user supply the key frames For articulated figures, we need a way to define the key frames There are two ways to pose an articulated character forward and inverse kinematics
Forward vs. Inverse Kinematics Forward Kinematics Compute configuration (pose) given individual DOF values Inverse Kinematics Compute individual DOF values that result in specified end effector position
Forward Kinematics Hierarchical model - joints and links Joints - rotational or prismatic Joints - 1, 2, or 3 Degree of Freedom Links - displayable objects Pose - setting parameters for all joint DoFs Pose Vector - a complete set of joint parameters
Articulated Models Articulated models: rigid parts connected by joints They can be animated by specifying the joint angles (or other display parameters) as functions of time. q i q t i () t 1 t 2 t 1 t 2
Degrees of Freedom (DOFs) The variables that affect an object s orientation How many degrees of freedom when flying? So the kinematics of this airplane permit movement anywhere in three dimensions Six x, y, and z positions roll, pitch, and yaw
Degrees of Freedom How about this robot arm? Six again 2-base, 1-shoulder, 1-elbow, 2-wrist
Reachable Workspace The set of all possible positions (defined by kinematics) the end effector can reach Dextrous workspace
Example: 2-Link Structure
Forward Kinematics
Forward Kinematics
Forward Kinematics
Forward Kinematics
ιάσχιση δένδρων
Drawing Articulated Figures
Static Figure Transformations
Forward Kinematics Control
Hierarchy Representation Model bodies (links) as nodes of a tree All body frames are local (relative to parent) Transformations affecting root affect all children Transformations affecting any node affect all its children
Transformations at the arcs T0 T1.1 T2.1 R1.1 R2.1 T1.2 T2.2 R1.2 R2.2 User modifies Rotation (new pose vector ) Re-traverse tree To get new pose
Ροµποτικός βραχίονας Τρεις βαθµοί ελευθερίας: Γωνία περιστροφής της βάσης Γωνίες στις αρθρώσεις Μετρώνται στο σύστηµα συντεταγµένων (frame) του αντίστοιχου µέρους
Ροµποτικός βραχίονας Καθώς µεταβάλλονται οι γωνίες των βραχιόνων τα αντικείµενα ή τα frames τους βραχιόνων µετακινούνται ως προς τη βάση Έχει προηγηθεί τοποθέτηση στη σωστή σχετική θέση
Ροµποτικός βραχίονας Η κίνηση ενός µέρους πρέπει να µεταδοθεί στα µέρη άνωθεν αυτού Περιστροφή βάσης µε πίνακα περιστροφής R y (θ) Ο κάτω βραχίονας πρέπει να περιστραφεί, να τοποθετηθεί στην κορυφή της βάσης και να περιστραφεί µαζί της: R y (θ) T(0,h 1,0) R z (φ) Ο πάνω βραχίονας πρέπει να περιστραφεί κατά ψ και να τοποθετηθεί στην κορυφή του κάτω βραχίονα: R y (θ) T(0,h 1,0) R z (φ) T(0,h 2,0) R z (ψ)
Ροµποτικός βραχίονας glrotate() base() gltranslate() glrotate() lower_arm() gltranslate() glrotate() upper_arm()
Drawing Articulated Figure
Ροµποτικός βραχίονας Αποθήκευση της πληροφορίας στους κόµβους είκτης στη συνάρτηση σχεδίασης Πίνακας µετασχηµατισµού που τοποθετεί το µέρος σε σχέση µε τον πατέρα είκτες στα παιδιά Άλλες πληροφορίες (χρώµα, υλικό) Αλγόριθµος διάσχισης του δένδρου, από πατέρα προς παιδιά
ιάσχιση δένδρων ιάσχιση του δένδρου για την απεικόνιση του σύνθετου αντικειµένου Preorder διάσχιση: αναδροµική διάσχιση ρίζας, αριστερού υποδένδρου, δεξιού υποδένδρου Συνάρτηση που πραγµατοποιεί την διάσχιση Αναλυτικά µε κατάλληλη χρήση σωρών για αποθήκευση των απαιτούµενων µετασχηµατισµών Με αναδροµικό τρόπο
ιάσχιση δένδρων
ιάσχιση µε βάση σωρούς Χρήση push και pop για αποµόνωση των µετασχηµατισµών glpushmatrix() torso(); gltranslate(); glrotate; Head(); glpopmatrix(); glpushmatrix() gltranslate(); glrotate; Left_upper_leg(); gltranslate(); glrotate; Left_lower_leg();
ιάσχιση µε βάση τους σωρούς Η µέθοδος µε τους σωρούς απαιτεί κώδικα γραµµένο για το συγκεκριµένο αντικείµενο δεν δίνει µια γενική συνάρτηση διάσχισης δένδρου.
ενδρικές δοµές δεδοµένων Χρήση κατάλληλων δοµών δεδοµένων για την αναπαράσταση των δένδρων και ένα γενικό αλγόριθµο διάσχισης Αναπαράσταση δένδρου: left child, right sibling Κάθε κόµβος έχει δείκτη στο αριστερότερο παιδί και στον δεξιό αδερφό (κόµβος στο ίδιο επίπεδο, παιδί του ίδιου πατέρα)
ενδρικές δοµές δεδοµένων
ενδρικές δοµές δεδοµένων Σε κάθε κόµβο αποθηκεύουµε: είκτη σε συνάρτηση που ζωγραφίζει το αντικέιµενο Πίνακα µετασχηµατισµού που τοποθετεί το αντικείµενο σε σχέση µε τον πατέρα είκτες σε αριστερό παιδί, αδερφό typedef struct treenode{ GLfloat m[16]; void (*f)(); struct treenode *sibling; struct treenode *child; }treenode; ιαφορετική προσέγγιση από την προηγούµενη
ενδρικές δοµές δεδοµένων Κατά την απεικόνιση ο πίνακας m πολλαπλασιάζεται µε τον τρέχοντα πίνακα µετασχηµατισµού και καλείται η f Αρχικοποιούµε κατάλληλα τον κάθε κόµβο ίνουµε την αρχική θέση και την συσχέτιση µε τους υπόλοιπους κόµβους
ενδρικές δοµές δεδοµένων treenode torso_node, head_node, lua_node,.. glloadidentity(); glrotatef(theta[0], 0.0, 1.0, 0.0); //φτιάχνουµε κατάλληλο modelview και τον αποθηκεύουµε στον m glgetfloatv(gl_modelview_matrix,torso_node.m); torso_node.f = torso; torso_node.sibling = NULL; torso_node.child = &head_node; //Το theta είναι µεταβλητή που αλλάζει για να πετύχω την κίνηση
ενδρικές δοµές δεδοµένων glloadidentity(); gltranslatef(-(torso_radius+upper_arm_radius), 0.9*TORSO_HEIGHT, 0.0); //το µετακινώ στη σωστή θέση glrotatef(theta[3], 1.0, 0.0, 0.0); //µεταβλητή γωνία glgetfloatv(gl_modelview_matrix,lua_node.m); lua_node.f = left_upper_arm; lua_node.sibling = &rua_node; lua_node.child = &lla_node;
ενδρικές δοµές δεδοµένων Όταν µετακινούµαι σε αδερφό πρέπει να επαναφέρω τον modelview (popmatrix) Όταν πάω σε παιδί ο modelview του πατέρα κληρονοµείται όπως θα έπρεπε Αν αλλάξω τις γωνίες (DOF) ξαναδιασχίζω το δέντρο. Μπορούµε να προσθέσουµε / διαγράψουµε κόµβους δυναµικά. Αλλαγές στο αντικείµενο
ενδρικές δοµές δεδοµένων Αναδροµική συνάρτηση διάσχισης (preorder) Γενική, ανεξάρτητη από το συγκεκριµένο δέντρο void traverse(treenode* root){ if(root==null) return; glpushmatrix(); glmultmatrixf(root->m); root->f(); if(root->child!=null) traverse(root->child); glpopmatrix(); } if(root->sibling!=null) traverse(root->sibling);
Example: 2-Link Structure
Inverse Kinematics
What is Inverse Kinematics? Forward Kinematics? θ 1 θ 2 θ 3 End Effector Base r x = r f(θ)
What is Inverse Kinematics? Inverse Kinematics θ 1 θ2 θ3 End Effector Base r θ = r f 1 ( x)
Inverse Kinematics
Inverse Kinematics : When useful? Want character to push a button or take a step can give the animator a good first step that he/she can later fine tune
What Makes IK Hard? Goal of "natural looking" motion Singularities Redundancy
Inverse Kinematics
Analytical Solutions
r f(θ) What does looks like? l 1 l 2 θ 2 l 3? End Effector θ 1 Base θ 3 x y = = l l 1 1 cos( θ ) + 1 sin( θ ) + 1 l l 2 2 cos( θ ) + 2 2 sin( θ ) + l l 3 3 cos( θ ) sin( θ ) 3 3
Solution to r θ = r f 1 ( x) Our example x = l cos( θ ) + l cos( θ y = l 1 1 1 sin( θ ) + 1 l 2 2 2 2 ) + l sin( θ ) + l 3 3 cos( θ ) sin( θ ) Number of equations : 2 Unknown variables : 3 Infinite number of solutions! 3 3
Redundancy System DOF > End Effector DOF Our example x y = l = l 1 1 cos( θ ) + 1 sin( θ ) + System DOF = 3 1 l l 2 2 cos( θ ) + 2 2 sin( θ ) + End Effector DOF = 2 l l 3 3 cos( θ ) sin( θ ) 3 3
Redundancy A redundant system has infinite number of solutions Human skeleton has 70 DOF Ultra-super redundant How to solve highly redundant system?
IK Incremental Constructions Configurations too complex for analytical solution? Motion can be incrementally constructed At each time step, compute best way to change each joint angle to match the desired endpoint This computation forms the matrix of partial derivatives (Jacobian)
IK Incremental Constructions
IK -> Incremental Constructions w2 d2 End Effector q 2 w2 x d2 - Compute instantaneous effect of each joint - Find linear combination to take end effector towards goal position
IK -> Incremental Constructions
IK Incremental Constructions : Mathematics Unknowns End effector velocities Joint angles
IK Incremental Constructions : Mathematics V vector of linear and rotational velocities represents the desired change in the end effector Unknowns (joint angle velocities) Desired change difference between current position/orientation to that specified by the goal configuration
IK Incremental Constructions : Mathematics Jacobian: what is the effect of a specific joint angle change to a certain component of V
IK Incremental Constructions : Mathematics Rotational change ω at end effector: velocity of joint angle about the axis of revolution Linear change at end effector: cross product of axis of revolution and vector from joint to effector
Using the Jacobian
IK -> Incremental Constructions Solution only valid for an instantaneous step Once a step is taken, need to recompute solution
IK Incremental Constructions : Example Planar configuration We are not interested in the orientation of end effector! Axis of rotation of all joints: perpendicular to the figure
IK Incremental Constructions : Mathematics Jacobian: what is the effect of a specific joint angle change to a certain component of V
IK Incremental Constructions : Example V=g 1 θ 1 + g 2 θ 2 + g 3 θ 3
IK Incremental Constructions : Example No linear combination of g s will lead to the target