回答編集履歴
1
修正
answer
CHANGED
@@ -138,8 +138,8 @@
|
|
138
138
|
gx, gy, gz = getGyro()
|
139
139
|
|
140
140
|
#print ('{0:4.3f}, {0:4.3f}, {0:4.3f}, {0:4.3f}, {0:4.3f}, {0:4.3f},' .format(gx, gy, gz, ax, ay, az))
|
141
|
-
Roll = math.atan2(ay
|
141
|
+
Roll = math.atan2(ay,az) * 57.324 #57.324 = 360/2π であり、rad から ° に変換
|
142
|
-
Pitch = math.atan2(-ax
|
142
|
+
Pitch = math.atan2(-ax , math.sqrt( ay* ay+ az*az ) ) * 57.324
|
143
143
|
|
144
144
|
#pitch = math.atan(-ax / (ay*math.sin(roll) + az*math.cos(roll)))
|
145
145
|
|