Skip to content

Commit

Permalink
Fix IMU report
Browse files Browse the repository at this point in the history
The order of acceleration and angular velocity fields are fixed so the
reported values are correct. The axis orientation is positive X pointing
right, positive Y pointing up, and positive Z pointing towards the user.

For the angular velocities, the following convention is used for the
names (following the right thumb rule):

Roll: rotation around X axis
Pitch: rotation around Y axis
Yaw: rotation around Z axis

The code has been tested by checking that the sign of the values are
consistent with the axis orientation when translating/rotating the
device.

References:
- https://gamedev.stackexchange.com/a/87178
- http://eleccelerator.com/wiki/index.php?title=DualShock_4#Report_Structure
  • Loading branch information
naoki-mizuno committed Aug 25, 2019
1 parent be7327f commit aa91813
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ds4drv/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ class DS4Report(object):
"button_options",
"button_trackpad",
"button_ps",
"motion_y",
"motion_x",
"motion_z",
"orientation_roll",
"orientation_yaw",
"orientation_pitch",
"orientation_yaw",
"motion_x",
"motion_y",
"motion_z",
"trackpad_touch0_id",
"trackpad_touch0_active",
"trackpad_touch0_x",
Expand Down Expand Up @@ -181,13 +181,13 @@ def parse_report(self, buf):
# Trackpad and PS buttons
(buf[7] & 2) != 0, (buf[7] & 1) != 0,

# Acceleration
# Orientation
S16LE.unpack_from(buf, 13)[0],
S16LE.unpack_from(buf, 15)[0],
S16LE.unpack_from(buf, 17)[0],

# Orientation
-(S16LE.unpack_from(buf, 19)[0]),
# Acceleration
S16LE.unpack_from(buf, 19)[0],
S16LE.unpack_from(buf, 21)[0],
S16LE.unpack_from(buf, 23)[0],

Expand Down

0 comments on commit aa91813

Please sign in to comment.