# How can you estimate the final position of a gyroscope graphically?

A Smartphone is initially in the position indicated as follow

We move it, and get the next gyro reading.

How can you estimate your final position graphically?

• Looks like homework to me. What do you know already about the workings of a gyroscope? – Elliot Alderson Aug 12 at 21:48

Here's a copy of your image:

This must be rotational accelerations, it can't be rotational speed because you don't get that information from a gyroscope.

Assuming it is actually rotational acceleration and not rotational speed then along the Y axis you rotate slowly, then faster and faster. At T=1 you stop rotating faster and just keep rotating as if your object is in space for one second. And as it is rotating along its Y axis, it begins to ramp up its rotation in Z axis. I made an animation for this because it hurts my brain to visualize this. Blender is your friend.

Integrating acceleration to get speed and then again to get position works... if you use quaternions, so doing it individually as I've shown it in the animation is a lie. But lies makes it easier to think.

Here are the values for the angles, I eyeballed it.

Y angle is in green, Z angle is in blue.

• From T=0 to T=1 Y angle behaves like y=x2, Z angle is 0
• From T=1 to T=2 Y angle behaves like y=x, Z angle behaves like y=x2
• From T=2 to T=3 Y angle behaves like y=x2, Z angle behaves like y=x

Because the inputs you gave are simply 1 for some time (or some other constant, I don't care, I'll call it 1), and during that time you get $$\\int 1~dx=x+c\$$ which gives you the rotational speed, and then you do $$\\int (x+c)~dx=\frac{x^2}{2}+cx+d\$$ to get rotational angle. Notice how sensitive it is to errors, it will drift easily if you try to compute it.

According to comments it might actually be a rate gyro that outputs speed and not acceleration, meaning that it is not just a gyroscope, there is a gyroscope and some extra parts already integrating the acceleration to give you the speed. I'll keep the first half because there are still gyroscopes out there that gives rotational acceleration.

So assuming that the output is rotational speed, then we get the rotational position simply by integrating once. I don't know what the amplitude of those square waves are, but let's call their height for k. Then we acquire the rotational position with this equation: $$\\int k~dx=kx+c\$$, it is a straight line.

Here's an animation where I've set kx to be equal to 90° after one square, it could be some other angle, it depends on the time and the value of k, both of which are unknown to me.

Here are the local angles:

Y angle is in green, Z angle is in blue.

Local information:

• From T=0 to T=1 Y angle behaves like y=x, Z angle is 0
• From T=1 to T=2 Y angle behaves like y=0, has the value of 90°, Z angle behaves like y=x
• From T=2 to T=3 Y angle behaves like y=x, Z angle behaves like y=0, has the value of 90°

I actually didn't use this data because Blender uses global angles, but locally this is what happens.

Global information:

At T=1 to T=2 the phone doesn't rotate along the global Z axis, it actually rotates along the global X axis. And now it depends on what rotation system you are in, XYZ, XZY, YXZ, YZX, ZXY, ZYX, the order matters. XYZ is pretty common which means that first you rotate some angle around X, then some angle around Y, and last some angle around Z.

Now it gets tricky, because first you rotate along Y axis and then X axis, if it would've been X axis first and then Y axis it would've been very simple because then it's XYZ. But we're rotating in Y axis afterwards anyways so XYZ or ZYX is equally annoying. This smells very much like a homework problem.

This is the format for the text below (rotational x position, rotational y position, rotational z position).

But okay, at T=1, global angle of the phone (0°, 90° 0°) becomes (90°, 90° 90°) which doesn't change the orientation of the phone at all. But this global change aligns the axis so when you rotate along the local Z axis you are actually rotating along the global Y axis and get to (90°, 0° 90°) at T=2. And then from T=2 the local Y axis is now aligned with the global Z axis, and this ends up with (90°, 0° 180°) at T=3.

The local angles doesn't tell you anything really. Given the local rotation position of (0°, 180° 90°) I can't work out anything. Because I can't tell from this information that there was a gap between where we rotated in the local Z axis.

However, given the global angles of (90°, 0° 180°) AND knowing that the order of rotations are XYZ, then I can tell exactly what orientation the phone is in. First you rotate the phone 90° in the global X axis, then 0° in the global Y axis, and finally 180° in the global Z axis.

It gets much easier if you just hand off the problem to the computer and let it compute everything with quaternions. Then you won't get a headache.

• The curves green and blue starts at (0,0)? – jsuarezbaron Aug 13 at 0:47
• "This must be rotational accelerations, it can't be rotational speed because you don't get that information from a gyroscope." Huh? Then what is a rate gyro? most gyros output angular velocity, even if they use coriolis acceleration to figure it out. – DKNguyen Aug 13 at 1:27
• Or are you referring to the infinite acceleration implied by the square velocity waveform? That is probably just what the professor gave to simplify the work rather than a reflection of real world movement. – DKNguyen Aug 13 at 1:32
• A gyroscope is a device used for measuring or maintaining orientation and angular velocity. en.wikipedia.org/wiki/Gyroscope#cite_note-1 – jsuarezbaron Aug 13 at 3:28
• @jsuarezbaron yes, both start at 0,0, it's the black line that is a 0 angle. I forgot about the two green lines obscuring it - Yes, a gyroscope is used for measuring and maintaining orientation and angular velocity, but the output of a gyroscope is still the acceleration. If you do get angular velocity then something has already integrated the acceleration giving you the speed readily available. But then you don't have a gyroscope, then you have a gyroscope and something between it and you that integrates the acceleration and gives you the speed, then you have a rate gyro. – Harry Svensson Aug 13 at 9:44

You integrate angular velocity over time to get angular displacement. But then you run into the issue of the order of rotations. After all, readings are coming in on all three axis simultaneously so how do you know which order to apply the rotations in? Luckily, as time intervals decrease towards zero, angular velocities on each axis approach being applied simultaneously. But your waveforms were not constructed for that complication to ever be an issue.

• I think the gyroscope coordinate system will be as right hand rule. X(pitch), Y(roll) and Z(yaw). – jsuarezbaron Aug 12 at 23:59
• it is whatever you want it to be, as long a you are consistent. – DKNguyen Aug 13 at 1:25