I am trying derive the angle of rotation based on Gyroscope readings in my android application. I tried using rotation matrix for orientation values but they are unreliable. Is there a way that I can figure out the angle of rotation based on Gyro readings?
Related
I wrote an app that writes gravity, userAcceleration, and attitude quaternion to CSV while driving in a vehicle. The intent is to capture the dynamics of the vehicle (e.g. braking, accelerating, cornering) in the earth frame using an iPhone.
Then, I sum gravity and userAcceleration, and rotate the resulting raw acceleration vector by the quaternion provided by CMAttitude to get the acceleration in the earth frame. In about 60% of recording sessions, the average z values are not +9.81m/s^2 and jump to varying magnitudes besides +9.81m/s^2. For example (each tick mark in the y-axis represents 5m/s^2):
But, I expect a plot with a consistent average value for acceleration in the z axis like the following:
When I start device motion updates, I use the xMagneticNorthZVertical attitude reference frame, like so:
motionManager.startDeviceMotionUpdates(using: .xMagneticNorthZVertical, to: OperationQueue(), withHandler: didUpdateDeviceMotion)
The following computes raw acceleration in the global frame using the attitude quaternion:
let accel = CMAcceleration(x: (motion.userAcceleration.x+motion.gravity.x), y: (motion.userAcceleration.y+motion.gravity.y), z: (motion.userAcceleration.z+motion.gravity.z))
let a = SIMD3<Double>(accel.x, accel.y, accel.z)
let a_vehicle = simd_act(attitude.quaternion, a)
I also have written the equivalent in MATLAB resulting with the same problem.
xMagneticNorthZVertical should result in an attitude that computes the direction of gravity. The direction of X or Y does not matter to me.
I do not have any magnets in the vicinity to skew the computed attitude.
In contrast: Android's rotationVector consistently rotates the accelerometer readings to the earth frame. Surely the quality of iPhone is better than Android.
What might be the cause of the attitude quaternion to not always rotate the device frame to the earth frame such that Z is in the direction of gravity?
I'm trying to make simple VR HMD that can track user's head movement in 6 DoF(Forward and Backward, Left and Right, Up and Down, Pitch, Yaw, Roll). Applying 6 DoF Accelerometer and Gyroscope(GY-521, MPU-6050) made me can track user's rotation, but I still can not track positional differences.
I have googled if there is a way to calculate its spatial velocity or acceleration with accelerometer, but there weren't. Because output values of accelerometer mean not linear acceleration, but angular acceleration.
I wonder what kind of sensor or model can measure rotation and linear motion at the same time. Also, How standalone HMD can measure user's motion with its IMU?
I am trying to detect a free fall scenario. I have accelerometer and gyroscope.
A simple fall I can detect by inspecting a total acceleration of 0g
However, my problem is when the IMU falls and rotates at the same time (centrifugal force). Any idea how to distinguish this scenario?
I don't have the solution, but let me state 2 points:
if the IMU is near the center of mass of your hardware, the centrifugal acceleration should be negligible
If you have a constant rotation you should read a constant rate on the gyroscope, and a constant acceleration too ( if the IMU is not in the center of mass). Morover, the constant rotation should be on an axis perpendicular to that of the constant rotation
How can i use the yaw/pitch/roll to estimate the tilt angle of a motorbike, assuming the iphone is in the pocket. I'm thinking along the lines of storing the baseline yaw/pitch/roll when the user begins riding in the upright position then any deviation from that will give me rotations about all 3 axis, but how do i use this to figure out the lateral tilt angle of a motorbike? Thanks.
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.