Hello
I’m trying some things with the Hydra and a gyro module (http://www.ghielectronics.com/catalog/product/331), integrating over time to see the attitude angles.
There are two funny things:
- It seems X and Z axis are interchanged.
- the up-down axis (yaw, marked X, believed to be Z) is showing almost no response as I yaw the module (both other axes are OK).
This is the (pseudo-)code I am using. It’s initial, but it does the trick for testing the module. All variables are doubles:
=====================
attitudeGyro.rollX = 0;
attitudeGyro.pitchY = 0;
attitudeGyro.yawZ = 0;
gyro.ContinuousMeasurementInterval = new System.TimeSpan(0, 0, 0, 0, 10);
gyro.Calibrate();
gyro.MeasurementComplete +=
new Gyro.MeasurementCompleteEventHandler(gyro_MeasurementComplete);
void gyro_MeasurementComplete(GTM.Seeed.Gyro sender, GTM.Seeed.Gyro.SensorData sensorData)
{
changeGyro.rollX = (sensorData.X + lastGyroAngularVelocity.rollX * 180 / System.Math.PI) / 2 * sender.ContinuousMeasurementInterval.Milliseconds / 1000 * System.Math.PI / 180; // in rad
changeGyro.pitchY = (sensorData.Y + lastGyroAngularVelocity.pitchY * 180 / System.Math.PI) / 2 * sender.ContinuousMeasurementInterval.Milliseconds / 1000 * System.Math.PI / 180; // in rad
changeGyro.yawZ = (sensorData.Z + lastGyroAngularVelocity.yawZ * 180 / System.Math.PI) / 2 * sender.ContinuousMeasurementInterval.Milliseconds / 1000 * System.Math.PI / 180; // in rad
lastGyroAngularVelocity.rollX = sensorData.X * System.Math.PI / 180; // in rad/sec
lastGyroAngularVelocity.pitchY = sensorData.Y * System.Math.PI / 180; // in rad/sec
lastGyroAngularVelocity.yawZ = sensorData.Z * System.Math.PI / 180; // in rad/sec
attitudeGyro.rollX += changeGyro.rollX;
attitudeGyro.pitchY += changeGyro.pitchY;
attitudeGyro.yawZ = changeGyro.yawZ;
Debug.Print("Roll X: " + attitudeGyro.rollX * 180 / System.Math.PI + " - Pitch Y: " + attitudeGyro.pitchY * 180 / System.Math.PI + " - Yaw Z: " + attitudeGyro.yawZ * 180 / System.Math.PI);
}
=====================
Help please: Is the module faulty or am I?
thanks