CS 551 / CS 651: Computer Animation

Fall 2003

Professor Brogan

 

Assignment 2: Inverse Kinematics

 

Due: 5:00 Wednesday, Oct. 22nd

 

Corrections

 

(Oct 15th) I made a mistake in describing the ray/plane intersection that will define the point in three-space where the end effector should go.  As you can see from my original description below, the intersection point would always be on the x-y plane, regardless of how the user had rotated the scene.  My clarified instructions are indicated in red below.

 

5) User interface (15 points): Acquire the three-dimensional goal point interactively from the user's mouse and keyboard.  Naturally, it's difficult to acquire three values from the two-dimensional position of the mouse's pointer on the screen.  When the user clicks the left mouse button, compute the intersection between the x-y plane (keeping track of how the user's keyboard input may have rotated it) and the ray from the camera to the mouse pointer.  First, determine how much the user has rotated the world about the y axis and call this theta.  Compute the equation of the plane that results from rotating the x-y plane about the y axis by an amount equal to (-theta).  When the user clicks the left mouse button, compute the intersection between this rotated plane and the ray from the camera to the mouse pointer.  The ray that goes through the camera and the mouse point can be computed through calls to gluUnProject, demonstrated on p. 152 of the Red Book.  If the user clicks the left mouse button and drags the mouse, the goal point should follow accordingly. 

 

Introduction

 

You will write a program that implements inverse kinematics on a multi-link chain of rigid bodies, an arm, connected by rotational and translational joints.  Your program will read the description of the arm from a state file and compute the joint angles that place the end effector as near as possible to the goal point controlled by the user.  The user will move the goal point interactively using the mouse and the arm will interactively move to track the goal point.

 

Details

 

1) Load the state file (10 points):  The syntax of the state file is defined in this document and your program must parse the state file in order to define the architecture of the arm (limb lengths, joint types) and initial configuration of the arm (joint values).

 

2) Compute the Jacobian (15 points): The work space of this arm is R3, a three-dimensional space we'll represent by {x, y, z}.  We're only concerned about meeting the goal position prescribed by the user (we do not care about the orientation of the end effector) so you will need to construct a Jacobian mapping the joint degrees of freedom to the three dimensions of the output variables we care about.  You may analytically compute the elements of the Jacobian (you can deduce the geometric relationship between each DOF and the end effector's position) or you can use a forward kinematic algorithm to empirically determine the relationship between small changes in DOFs to end effector position.

 

3) Invert the Jacobian (15 points): In order to perform IK, you'll have to invert the Jacobian matrix.  To do this, you'll likely have to invert a non-square matrix that may have singularities.  You do not have to write special routines to detect and avoid singularities.

 

4) Render the scene (10 points): Use the state file to render arm parts (gluQuadrics is a quick technique - see p. 487of the OpenGL Programming Guide, the Red Book) of the right length and initial configuration.  Your program should use the 'h' key to rotate the world counter-clockwise about the y-axis (y == up) and 'l' (lower-case L)  will rotate the world clockwise.

 

5) User interface (15 points): Acquire the three-dimensional goal point interactively from the user's mouse and keyboard.  Naturally, it's difficult to acquire three values from the two-dimensional position of the mouse's pointer on the screen.  When the user clicks the left mouse button, compute the intersection between the x-y plane (keeping track of how the user's keyboard input may have rotated it) and the ray from the camera to the mouse pointer.  First, determine how much the user has rotated the world about the y axis and call this theta.  Compute the equation of the plane that results from rotating the x-y plane about the y axis by an amount equal to (-theta).  When the user clicks the left mouse button, compute the intersection between this rotated plane and the ray from the camera to the mouse pointer.  The ray that goes through the camera and the mouse point can be computed through calls to gluUnProject, demonstrated on p. 152 of the Red Book.  If the user clicks the left mouse button and drags the mouse, the goal point should follow accordingly. 

 

6) Perform IK (35 points):  Given an error between the end effector's position and the goal point, perform IK to determine the joint values that best eliminate the error (and other goals like joint stiffness if you are a graduate student or an undergrad doing extra credit).  Joint limits must be obeyed.  Note that large errors may lead to instability in the incremental IK algorithm we're using because of the reliance on the Jacobian, which is only a linear approximation to the relationship between joint angles and end effector positions.  If the user clicks the left mouse button and describes a goal point far from the current end effector position, subdivision of the error and incremental computation may be necessary.  If the user drags the mouse, the end effector should follow.

 

Optional for those taking CS 551, but required for those taking CS 651 (the graduate version):

 

7) Implement joint stiffnesses (15 points):  To permit the user to specify preferred arm configurations, the input file encodes joint stiffnesses and rest positions.  Use the joint stiffnesses and desired rest positions to compute an IK solution that minimizes H = sum_over_all_joints (ai * (qi - qrest)2).  Use LU decomposition (Numerical Recipes section 2.3) to solve for intermediate matrix inverses.  Note that if all stiffnesses are 0, this results in exactly the same solution as the pseudo-inverse.

 

Optional for all:

 

8) Real robotic arms and humanoid systems must attend to the location of the arm's center of mass and ensure that the IK solution maintains balance.  Determine a mass amount and center of mass for each limb and compute the center of mass for the entire arm.  Constrain the IK solution to keep the arm's COM within a rectangular region of support.

 

File Format

 

    Example:

2

 

upperarm 1.0 3

T   0.0 1.0 0.0    0.0 1.0    0.5    1.0

R   0.0 1.0 0.0    0.0 0.0    0.0    0.5

R   0.0 0.0 1.0    0.0 0.0    1.57   2.0

 

lowerarm 0.5 1

R   0.0 0.0 1.0    0.0 0.0    0.0    0.5

 

 

Turnin and Grading

 

Send an email to the TA including the zipped version of your code.

 

The TA will arrange grading sessions when each student will be granted a block of time to conduct a demo of the full functionality of his or her system.  The TA reserves the right to test specific scenarios of his design.  He will have a PC outfitted with Windows Visual Studio.net and Linux to run you code.  Please make sure your code is able to execute on such a machine.  If you desire to bring in a laptop on which your demo runs, please feel free.  

 

Late policy: You have five late days to use during the semester.  Each late day you use will provide you with a 24 hour extension. 

 

Outside Resources

 

You may not use any inverse kinematics source code that you find in any books, the web, etc.  You can use books and the web to learn about inverse kinematics in general.  You may also use books and the web to acquire graphics interface libraries and matrix manipulation code.