From b3f193ad2dc87dd3eee6c40f2b7e7520b2d3710b Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Wed, 24 Jan 2024 00:44:08 -0800 Subject: [PATCH] sensors: Read Euler angles instead of quaternions from WebDriver As a result of https://github.com/w3c/deviceorientation/pull/124 and https://github.com/w3c/orientation-sensor/pull/83. The reading format is alpha-beta-gamma as described in the spec. They are measured in degrees and must fall within certain ranges. Internally, however, we always perform the Euler angles to quaternions conversion at the edges (i.e. in ChromeDriver and the Internals implementation used by content_shell), so that the the CDP and //services layers remain unchanged and continue to support only quaternions and the {ABSOLUTE,RELATIVE}_ORIENTATION_QUATERNION types for simplicity. The code to convert Euler angles to quaternions was copied from SensorInspectorAgent in Blink and is available for use by any callers that need to validate Euler angles and convert them. The original code remains in place because the entirety of the SensorInspectorAgent will be removed soon due to the work on bug 1506995. The test values for the orientation-sensor web tests had to be adapted: we now provide the inputs as Euler angles. The expected values have changed slightly as we had to find Euler _and_ quaternion values that were easy enough to read. Written in collaboration with Juha Vainio Bug: 1506995, 1520912, 1520919 Validate-Test-Flakiness: skip Change-Id: I047f41f172f0bbcf30c7462926cec7ae0a66d4e5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5229177 Commit-Queue: Raphael Kubo Da Costa Reviewed-by: danakj Reviewed-by: Vladimir Nechaev Reviewed-by: Reilly Grant Cr-Commit-Position: refs/heads/main@{#1251287} --- orientation-sensor/resources/sensor-data.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/orientation-sensor/resources/sensor-data.js b/orientation-sensor/resources/sensor-data.js index d0b280fa6c4371..a2886e7553bd0e 100644 --- a/orientation-sensor/resources/sensor-data.js +++ b/orientation-sensor/resources/sensor-data.js @@ -15,9 +15,13 @@ const kRelativeOrientationSensorData = { }; const kOrientationReadings = { - readings: [{quaternion: [1, 0, 0, 0]}], - expectedReadings: [{quaternion: [1, 0, 0, 0]}], - expectedRemappedReadings: [{quaternion: [-0.70710678, 0.70710678, 0, 0]}] + // WebDriver input data must be given in Euler angles according to + // https://w3c.github.io/deviceorientation/#parse-orientation-data-reading-algorithm + // and converted to quaternions via + // https://w3c.github.io/orientation-sensor/#create-a-quaternion-from-euler-angles. + readings: [{alpha: 0, beta: -180, gamma: 0}], + expectedReadings: [{quaternion: [-1, 0, 0, 0]}], + expectedRemappedReadings: [{quaternion: [0.70710678, -0.70710678, 0, 0]}] }; const kRotationMatrix = [1, 0, 0, 0,