# E91 Assignment 2

### Task 1: Update software.

The starter code has been updated with minor bugfixes and a major revamp to inverse kinematics. I've also added code to compute the overall center of mass (COM) for a system in the KinModel class -- all you need to do is provide mass information when you create the bodies.

You can get the software from this link (once again, I hope to get Git up and running before too much longer).

### Task 2: Model a humanoid in profile.

Modify the kintest.py example code to develop a model of a human figure in profile (side view). It doesn't have to look as pretty as the example below, but you should do your best to get the link lengths and masses correct. Make sure that you can visualize at least the position of each rigid body's center of mass (light red outlined circles below), as well as the position of the overall center of mass of the system (red filled circle below).

I've also visualized the supporting line segment (horizontal blue line) and the projection of the overall COM onto the support (vertical blue line). You can tell this position is statically stable because the blue lines overlap.

### Task 3: Generate random poses.

Pose your humanoid model in a few random poses to convince yourself you have gotten the kinematics correct. Here are two random poses from my model:

Clearly, these poses are not statically stable.

How were they generated? I start with a random set of joint angles for the entire body, and then transform everything so that the left foot is at the origin, like this:

```self.xforms = self.model.transforms(self.jvalues)
footXform = self.model.manipulatorFK(self.xforms, self.l_foot_manip)
self.baseXform = footXform.inverse()
self.xforms = [ self.baseXform * x for x in self.xforms ]```

This way, you don't need to worry about inverse kinematics, nor do you need to root the entire kinematic tree from the foot link.

### Task 4: Generate stable poses

Once your random poses are looking reasonable, modify your program to collect at least 100 of them. Here are a couple samples from my program:

Produce a webpage demonstrating your program. Provide images of your humanoid model in a neutral pose, several (at least 2) random unstable poses, and several (at least 10) random stable poses. Comment on the performance of your system. How long does it take to generate stable poses? Can you think of ways to make it faster?

We will review all of the assignments in class on Monday the 4th. Be prepared to show your webpage and/or demonstrate your software in action.