forked from DAInamite/programming-humanoid-robot-in-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_sensor_data.py
More file actions
27 lines (19 loc) · 781 Bytes
/
get_sensor_data.py
File metadata and controls
27 lines (19 loc) · 781 Bytes
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
'''
In this exercise you need to know how to get sensor data.
* Task: get the current joint angle and tempeture of joint HeadYaw
* Hint: The current sensor data of robot are store in perception (class Perception in spark_agent.py)
'''
from spark_agent import SparkAgent
class MyAgent(SparkAgent):
def think(self, perception):
angle = 0
temperature = 0
# YOUR CODE HERE
# set angle and tempeture to current data of joint HeadYaw
angle = perception.joint['HeadYaw']
temperature = perception.joint_temperature['HeadYaw']
print 'HeadYaw angle: ' + str(angle) + ' temperature: ' + str(temperature)
return super(MyAgent, self).think(perception)
if '__main__' == __name__:
agent = MyAgent()
agent.run()