Goal: Use a phone's built-in orientation (via the deviceorientation
HTML API) to manipulate a Napari 3D transform
Signal comes through end to end. Using the Vispy Quaternion class did the trick.
However, something weird still seems to be happening between the Flask redis-set and the reading on the other end. I thought smoothing was going to fix things but in the end, it only helped minorly. There's still a large amount of 'jank' when I rotate my phone.
I suspect its something to do with the sample rate.
Upstream bug. POST is not guarenteed sequential. Switching to a Websocket solved the 'jank', which was actually just out-of-order orientations.
Rotations are still weird. According to device rotation docs and this stack exchange post
𝛼: An angle can range between 0 and 360 degrees
𝛽: An Angle between −180 and 180 degrees
𝛾: An Angle between −90 to 90 degrees
For sanity sake:
alpha = z = yaw
beta = x = pitch
gamma = y = roll
-
Generate the certificates (first time)
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
-
Install dependencies
poetry install
-
Run Flask app
poetry run python yaw/app.py
-
Run Redis server (installation)
redis-server
-
Open napari
poetry run python nap.py