-
Notifications
You must be signed in to change notification settings - Fork 279
/
Copy pathinverse_kinematics.py
42 lines (34 loc) · 1.44 KB
/
inverse_kinematics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'''In this exercise you need to implement inverse kinematics for NAO's legs
* Tasks:
1. solve inverse kinematics for NAO's legs by using analytical or numerical method.
You may need documentation of NAO's leg:
http://doc.aldebaran.com/2-1/family/nao_h21/joints_h21.html
http://doc.aldebaran.com/2-1/family/nao_h21/links_h21.html
2. use the results of inverse kinematics to control NAO's legs (in InverseKinematicsAgent.set_transforms)
and test your inverse kinematics implementation.
'''
from forward_kinematics import ForwardKinematicsAgent
from numpy.matlib import identity
class InverseKinematicsAgent(ForwardKinematicsAgent):
def inverse_kinematics(self, effector_name, transform):
'''solve the inverse kinematics
:param str effector_name: name of end effector, e.g. LLeg, RLeg
:param transform: 4x4 transform matrix
:return: list of joint angles
'''
joint_angles = []
# YOUR CODE HERE
return joint_angles
def set_transforms(self, effector_name, transform):
'''solve the inverse kinematics and control joints use the results
'''
# YOUR CODE HERE
self.keyframes = ([], [], []) # the result joint angles have to fill in
if __name__ == '__main__':
agent = InverseKinematicsAgent()
# test inverse kinematics
T = identity(4)
T[-1, 1] = 0.05
T[-1, 2] = -0.26
agent.set_transforms('LLeg', T)
agent.run()