Struggling with lerp on gyroscope.attitude

I’m new to Unity and scripting in general, and I’m trying to make a simple game where there’s a circle on screen, that as you turn your phone around the Z axis the circle turns proportionally (testing using Unity Remote with a Samsung Galaxy S3). So I began with gyroscope input, something like this;

void Update () 
{ 
	Vector3 controlRot = new Vector3(0.0f, 0.0f, -(gyros.rotationRateUnbiased.z));
	powerup.transform.eulerAngles += controlRot;
}

Simple enough (aside from the fact that I shouldn’t be initializing my vector3 every frame but I digress), it was susceptible to gyro drift, so after doing some more research I found that the solution seemed to be using gyroscope.attitude, a feature within Unity that already does a degree of sensor fusion to compensate. So when I modified my code to use that instead, I found that it didn’t update as frequently, so it was fairly choppy, but didn’t seem to have the same drift issues.

So here’s where we get to the new problem; now I want to lerp between updates, so it seems more fluid. But I’ve come up on a hitch where I don’t know how to approach it. I’m not sure whether I should be:

-Applying the gyro input to the gameobject and then lerping between gameobject positions;

-lerping between gyro updates and applying the lerp vector to the gameobject’s eulerAngles;

-lerping between a zero vector and the gyro update?;

I’m not certain, but here’s what I ended up with on my most recent attempt which was definitely a flop:

void Update()
{
    Vector3 controlRot = new Vector3(0.0f, 0.0f, gyros.attitude.z*180);
	Vector3 testRot = Vector3.Lerp (Vector3.zero, controlRot, Time.deltaTime);
	outerSphere.transform.eulerAngles += testRot;
}

Because the nature of attitude as opposed to gyroscope.rotationRate, when I use the += function it just continues to turn depending on the magnitude of the phone, similar to a steering wheel, which is to be expected, but not what I want.

You can see that I’m kind of confused here at what exactly I need to do to solve the problem. Can anybody more experienced help point me in the right direction? Thanks in advance.

It doesn’t really make sense to lerp between updates for display purposes since update is called once per frame.

However, Lerp is simple and worth understanding. In general Lerp evaluates as follows (in unity t is clamped between 0 and 1)

Lerp(from, to, t)=(1-t)*from+t*to  

so your Lerp evaluates to

Vector3.Lerp (Vector3.zero, controlRot, Time.deltaTime)=Time.deltaTime*controlRot

If you use lerp you usually want the first or/and last variable to grow. For instance

Vector3 testRot = Vector3.Lerp (testRot , controlRot, Time.deltaTime);

will make it so testRot asymptomaticly approach controlRot from its initial value

Vector3 testRot = Vector3.Lerp (Vector3.zero, controlRot, Time.time-startTime);

will make it so testRot start from Vector3.zero and linearly approach controlRot over one second