-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathaccelerometer.py
More file actions
33 lines (28 loc) · 965 Bytes
/
accelerometer.py
File metadata and controls
33 lines (28 loc) · 965 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
28
29
30
31
32
33
import sys
import WonderPy.core.wwMain
class MyClass(object):
def on_sensors(self, robot):
"""
Print the raw accelerometer data along each axis.
Also the convenience rotation data.
See the comments in wwSensorAccelerometer.py for details.
"""
sensor = robot.sensors.accelerometer
things = [
("x" , sensor.x),
("y" , sensor.y),
("z" , sensor.z),
("z_yz", sensor.degrees_z_yz()),
("y_yz", sensor.degrees_y_yz()),
("z_xz", sensor.degrees_z_xz()),
("x_xz", sensor.degrees_x_xz()),
("x_xy", sensor.degrees_x_xy()),
("y_xy", sensor.degrees_y_xy()),
]
s = ""
for thing in things:
s += "%s: %7.2f " % (thing[0], thing[1])
sys.stdout.write('\r%s' % (s))
sys.stdout.flush()
if __name__ == "__main__":
WonderPy.core.wwMain.start(MyClass())