-
Notifications
You must be signed in to change notification settings - Fork 279
/
Copy pathagent_client.py
66 lines (50 loc) · 2.02 KB
/
agent_client.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'''In this file you need to implement remote procedure call (RPC) client
* The agent_server.py has to be implemented first (at least one function is implemented and exported)
* Please implement functions in ClientAgent first, which should request remote call directly
* The PostHandler can be implement in the last step, it provides non-blocking functions, e.g. agent.post.execute_keyframes
* Hints: [threading](https://docs.python.org/2/library/threading.html) may be needed for monitoring if the task is done
'''
import weakref
class PostHandler(object):
'''the post hander wraps function to be excuted in paralle
'''
def __init__(self, obj):
self.proxy = weakref.proxy(obj)
def execute_keyframes(self, keyframes):
'''non-blocking call of ClientAgent.execute_keyframes'''
# YOUR CODE HERE
def set_transform(self, effector_name, transform):
'''non-blocking call of ClientAgent.set_transform'''
# YOUR CODE HERE
class ClientAgent(object):
'''ClientAgent request RPC service from remote server
'''
# YOUR CODE HERE
def __init__(self):
self.post = PostHandler(self)
def get_angle(self, joint_name):
'''get sensor value of given joint'''
# YOUR CODE HERE
def set_angle(self, joint_name, angle):
'''set target angle of joint for PID controller
'''
# YOUR CODE HERE
def get_posture(self):
'''return current posture of robot'''
# YOUR CODE HERE
def execute_keyframes(self, keyframes):
'''excute keyframes, note this function is blocking call,
e.g. return until keyframes are executed
'''
# YOUR CODE HERE
def get_transform(self, name):
'''get transform with given name
'''
# YOUR CODE HERE
def set_transform(self, effector_name, transform):
'''solve the inverse kinematics and control joints use the results
'''
# YOUR CODE HERE
if __name__ == '__main__':
agent = ClientAgent()
# TEST CODE HERE