forked from DAInamite/programming-humanoid-robot-in-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_sensor_data.py
32 lines (23 loc) · 918 Bytes
/
get_sensor_data.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
'''
In this exercise you need to know how to get sensor data.
* Task: get the current joint angle and temperature of joint HeadYaw
* Hint: The current sensor data of robot are store in perception (class Perception in spark_agent.py)
'''
# add PYTHONPATH
import os
import sys
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', 'software_installation'))
from spark_agent import SparkAgent
class MyAgent(SparkAgent):
def think(self, perception):
angle = 0
temperature = 0
# YOUR CODE HERE
# get angle and temperature to current data of joint HeadYaw
temperature = perception.joint_temperature['HeadYaw']
angle = perception.joint
print('HeadYaw angle: ' + str(angle) + ' temperature: ' + str(temperature))
return super(MyAgent, self).think(perception)
if '__main__' == __name__:
agent = MyAgent()
agent.run()