rotation sensor reading returns noise
Posted: Mon Jun 24, 2013 12:39 am
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
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