Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize IMU pitch/roll values to [-180, 180] #2171

Merged
merged 2 commits into from
Jul 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Normalize IMU pitch/roll values to [-180, 180]
  • Loading branch information
N-M-T committed Jul 28, 2021
commit b04c5bea7b1a4be832db9660709ae902baaa2d8c
11 changes: 9 additions & 2 deletions pupil_src/shared_modules/imu_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,17 @@ def update(self, accel, gyro): # 2-tuples (x, y, z) for accel, gyro

# These are modified to account for Invisible IMU coordinate system and positioning of
# the IMU within the invisible headset
self.roll = (
roll = (
np.degrees(
-np.arcsin(2.0 * (self.q[1] * self.q[3] - self.q[0] * self.q[2]))
)
+ 7
)
self.pitch = (
# bring to range [-180. 180)
roll = ((roll + 180) % 360) - 180
self.roll = roll
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
roll = ((roll + 180) % 360) - 180
self.roll = roll
self.roll = ((roll + 180) % 360) - 180


pitch = (
np.degrees(
np.arctan2(
2.0 * (self.q[0] * self.q[1] + self.q[2] * self.q[3]),
Expand All @@ -222,6 +226,9 @@ def update(self, accel, gyro): # 2-tuples (x, y, z) for accel, gyro
)
+ 90
)
# bring to range [-180. 180)
pitch = ((pitch + 180) % 360) - 180
self.pitch = pitch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pitch = ((pitch + 180) % 360) - 180
self.pitch = pitch
self.pitch = ((pitch + 180) % 360) - 180



class IMURecording:
Expand Down