I'm trying to monitor the angle of the iphone as it turns. I'm using mobilesensorreading("rotation rate", true) and the data that comes back is just noise. The accelerometer, and heading works, but just noise from the gyro's. Any suggestions?
Code:
on updateScreen
if sRunning is true then
put the long seconds into tFrame
put tFrame into field "time"
--Get sensor readings
put mobileSensorReading("Acceleration",true) into tAccelArray
put mobileSensorReading("Heading",true) into tHeadingArray
put mobileSensorReading("Rotation Rate",true) into tRotArray
--Calculate time period
put tFrame- gOldTimeStamp into deltaTime
--calc change in rotation
put 180/pi*tRotArray[z]* deltaTime into deltaAlt
put 180/pi*tRotArray[x]* deltaTime into deltaAz
--add change to last angle
put gCurrentRotAz + deltaAz into gCurrentRotAz
put gCurrentRotAlt + deltaAlt into gCurrentRotAlt
--update time
put tframe into gOldTimeStamp
--calculate angles using accelerometer
put 180/pi *atan2(tAccelArray[z],tAccelArray[y]) into newAlt
put 180/pi *atan2(tAccelArray[x],tAccelArray[y]) into newAz
--update screen
put round(gCurrentRotAz,1) into field "RotAz"
put round(gCurrentRotAlt,1) into field "RotAlt"
put round(newAlt,1) into field "AccelAlt"
put round(newAz,1) into field "AccelAz"
put tHeadingArray["true heading"] into field "Heading"
put round(tHeadingArray["true heading"],1)&&round(tAvRot[Az],4)&&round(deltaAz,4)&&round(gCurrentRotAz,2)&return before field "log"
end if
end updateScreen
rotation sensor reading returns noise
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: rotation sensor reading returns noise
Does your device have rotation sensors? Check with mobilesensoravailable("rotation rate")
Re: rotation sensor reading returns noise
Yes it has rotation sensors. If I use the on rotationRateChanged xValue, yValue, zValue structure, I get reasonable data. However this only updates when the rotation rate changes. I should be able to get the rotation rate on a periodic basis.
Re: rotation sensor reading returns noise
To get a 'sensor' reading when you want it instead of waiting for the periodic updates... use 'mobileGetSensorReading'... then you can call the change in the rate of rotation when you want it and set your own time periods if you employ the 'send' command as well...
Re: rotation sensor reading returns noise
How would one use the "send" command?