- Home /
Problem combining GyroDroid rotation with independent position changes
First, this is a fairly noob question, so any advice is very humbly welcome.
I am working on an Android app which uses GyroDroid along with a proprietary Java-space library to acquire something akin to GPS coordinates (it isn't actually GPS, though).
Per the GyroDroid examples, I am simply setting the transform.rotation of my camera to the rotation quaternion provided by GyroDroid. I won't get into the specifics of how the positioning works, but suffice to say it is a black box which provides a Vector3 of the proper (x,y,z) position for my camera. Similarly to GyroDroid, I just assign this Vector3 to the same camera's transform.position.
When I use either part by itself it works just as expected under extensive testing.
However, as soon as I start using both of these together strange things start to happen. After just a couple minutes of use the rotation (but not the position) will become out of sync with the real world. It behaves as if there is a sensor problem, essentially. I believe there is not a sensor problem because all I have to do is stop setting the transform's position to make it go away.
Is there some fundamental thing that I'm not understanding about how to concurrently set rotation and position when using data from GyroDroid that could cause this?
Code:
private var filterHardness = 1;
private var rotationFilter : QuaternionFilter = new QuaternionFilter(filterHardness); //a filter to smooth changes in rotation
private var currentPosition : Vector3 = Vector3.Zero();
private var enableRotation = true;
private var enablePosition = false;
...
function Update () {
if (enableRotation) transform.rotation = rotationFilter.Update(Sensor.rotationQuaternion);
if (enablePosition) transform.position = currentPosition;
}
The test cases are:
OK with enableRotation = true and enablePosition = false
OK with enableRotation = false and enablePosition = true
Unacceptable with enableRotation = true and enablePosition = true
In case it isn't clear, the background processes for BOTH the positioning system and GyroDroid are running in all cases. The enablePosition and enableRotation flags have no effect on whether both systems are initialized. Both parts use Java libraries which are loaded at startup. In other words, aside from whether I am changing the camera's transform there is no difference in the running code in any of my three test cases.
Any help sincerely appreciated!