dilevin / computer-graphics-kinematics

Computer Graphics Assignment about Kinematics
3 stars 4 forks source link

IK: Why lambdas? #45

Open AlekseyPanas opened 10 months ago

AlekseyPanas commented 10 months ago

Im a little lost as to the purpose of using lambdas. It seems to me we can simply have a function which takes as input a current skeleton and a list of target positions for a subset of bones (end effectors). Then that function would simply modify all the xzx attributes in the skeleton by performing gradient descend.

I am a bit lost as to the given structure of the code, with the f, grad_f, and proj lambdas. What is their purpose?

I should also add that I am generally confused with how the last 5 task files fit together.

EDIT: Also, what are the Z values in projected_gradient_descent? Arent we modifying the xzx of the skeleton? It isnt even passed into the function.

Zhecheng-Wang commented 10 months ago

The purposes of f, grad_f, proj_z are stated in tutorial notes.

You need to implement all last 5 files to get Inverse Kinematics working.

Please read the header file and function definition, z is passed for reference. Yes, we are essentially modifying the xzx of the skeleton. The passed in z is a matrix form of joints xzx. Again, it was remarked in tutorial and written in tutorial notes, Bone class defines the maximum/minimum allowed angle for joints, you can enforce the angle constraint by clipping current xzx.

AlekseyPanas commented 10 months ago

Thank you! I didnt realize there were tutorial notes

Zhecheng-Wang commented 10 months ago

To elaborate on the IK call hierarchy:

  1. copy_skeleton_at.cpp for grad_f in end_effectors_objective_and_gradient.cpp and finite differencing kinematics_jacobian.cpp.
  2. kinematics_jacobian.cpp for grad_f chain rule in end_effectors_objective_and_gradient.cpp.
  3. end_effectors_objective_and_gradient.cpp defines f, grad_f, proj_z for projected_gradient_descent.cpp.
  4. projected_gradient_descent.cpp needs line_search.cpp to converge.