ARKit Changing X and Z axis - arkit

I made an OpenVR Driver for ARKit but ARKit changes my X and Z axis when i change Yaw axis. I tried changing axis for all possibilities for yaw axis(180-90, 90-0, 0-(-90),-90-(-180) but when i did this all old position changing. Can anyone help me about algorithm.

Related

Orientation problem from inertial module LSM9DS1 Arduino

I am working on a project where i have to determine position and rotation of an IoT object with accelerometer, gyroscope and magnetometer. The goal is to show this object in a Unity3D virtual world.
To do this, i have an Arduino Nano 33 BLE that include a LSM9DS1 as inertial module.
So, i started to determine the rotation of my object. This link was very usefull : http://gilles.thebault.free.fr/spip.php?article32
That's the line for get the Y axis :
angle=0.98*(angle+float(gy)0.01/131) + 0.02atan2((double)ax,(double)az)*180/PI;
With this one, i can get X, Y and Z angles. When i try one by one axis orientation, all axis rotation are fine. The problem is when i use 2 axis or more at same time. For example, i use only X and Y axis. When i turn only X axis of 90°, Y axis turn of 90° too. This video will explain more accurately than words : https://www.youtube.com/watch?v=IeuIuEcjUBc&feature=youtu.be
I searched lot of things to fix it but now, i have no more idea. Can anyone guide me?

Unity3D relative rotation of objects on an axis

In the project I am using IMU sensors to track real player's hand and apply the transformation values onto 3D hand inside Unity.
As IMU sets the Y axis orientation relative to magnetic north of the earth, in the game, hand initializes on specific direction.
What I want is to calculate the offset of IMU's given Y values and 3D hand's original Y rotation, so that I can subtract that value to the 3D model's Y rotation (that will seem like player's initial Y Rotation is the same as 3D hand's). Code would be: transform.Rotate(Vector3.up, offset, Space.World);
IMU sends Euler angles (does it well, as I wasn't able to get Gimbal lock)
As I understand, I need to find out angle difference between 3D Hand's initial rotation and IMU's given initial rotation on XZ plane (or through Y Axis)
How do I calculate the offset?
You can use Quaternion.FromToRotation to calculate offset, something like:
var offset = Quaternion.FromToRotation(Vector3.up, imuUp);
transform.rotation *= offset;

Ther axis of Imported FBX from 3ds Max into Uity 3D is not matching because of which object is not moving desired direction

I have created 3d model in 3DS Max and imported in Unity 3D.
In Unity 3D i m moving object in -Z axis direction.
While exporting object from 3ds max axis are x0, y0, z0 and in FBX settings y-axis up.
When model imported in the Unity 3D object appear as rotated in x-axis 90 degree
code is working fine its moving the object in -z zxis but object is rotated in X90.
And when I rotate my FBX object in required position then object is moving downwards in -y axis direction.
Hey I just figured out the problem.
In 3DS MAX, change the pivot point of the object then export.
First, Y - axis was facing Front view and Z - axis top [image 1]
Rotate X - Axis with 90 degree
Now Y - axis id pointing top and Z - axis is pointing back [image 2]
You can use this very useful max script
http://www.strichnet.com/improving-the-fbx-workflow-between-3ds-max-and-unity3d/
or my tweaked version (ui fix, success alert disabled)
https://yadi.sk/d/HKMDxakf3a3zHq
may not work with animation and rigged models
example of settings

device motion in constrained environment

I am trying to solve a seemingly easy problem related to device motion but couldn't figure out how to solve it. I have a situation where iPhone will move in a circle in the x-y plane. I need to find the angle between the iPhone's x and y axes relative to the center of rotation. The iPhone may be in portrait mode or landscape mode or in any angle in between relative to the line connecting iphone to the center of rotation. See the attached picture that explains the scenario.
The yaw change for a given rotation is the same regardless of this angle, so that doesn't really help. I am hoping that there would be some relationship that I can calculate for every small rotation and then find the best fit for the entire motion - but can't figure out that yet.
I appreciate any help or pointers.
(I am writing in pseudo-code since I don't know the API you are using, sorry.)
Here is how to get the axis and angle of the rotation.
Get the rotation matrices R1 and R2 at the beginning and end of your rotation directly from the API (see CMAttitude and CMRotationMatrix). Then, determine the angle and axis of the rotation R that brings R1 to align with R2. You get R as follows:
R = R1 * transpose(R2)
The angle of rotation R is
angle = acos((trace(R)-1)/2)
and its axis is
axis = { R[3][2]-R[2][3], R[1][3]-R[3][1], R[2][1]-R[1][2] }
For further details, please check Rotation matrix to axis angle and also Axis-angle.
I am not sure how to get the angle you are interested in. Nevertheless, I hope that the above helps.
Please don't use roll, pitch and yaw anything other than display. And don't try to integrate them, nothing good will come out.
Anyways, behind the rotation matrices there is integration. In other words, somebody already did the integration for you.

Detecting the direction of the accelerometer movement on the y axis

I currently detect movement on the y axis. How does one calculate the direction it moved on the axis?
I get the same values when moving up or down.
Is the Gyro needed for this?
Do remember that the accelerometer will reflect the force of gravity. So movement up and down will generally be reflected as 9.81 m/s2 plus or minus the actual acceleration of the device relative to the Earth.