{"id":420,"date":"2013-08-02T09:49:42","date_gmt":"2013-08-02T09:49:42","guid":{"rendered":"http:\/\/blog.daft-ideas.co.uk\/?p=420"},"modified":"2013-08-02T09:49:42","modified_gmt":"2013-08-02T09:49:42","slug":"uav-reading-sensor-data-part-ii","status":"publish","type":"post","link":"https:\/\/blog.daft-ideas.co.uk\/2013\/08\/02\/uav-reading-sensor-data-part-ii\/","title":{"rendered":"UAV, reading sensor data Part II"},"content":{"rendered":"
In our previous adventure, Matt and I The next step is for us to compare the outputs from the Gyro and the Accelerometer. This is currently impossible, given that the\u00a0Accelerometer is transformed into meaningul readings (degrees) already, and the gyro is just a load of “rate of change” readings.<\/p>\n We can get the orientation readings from the Gyro like this:<\/p>\n Now that we’ve done this, we can measure an axis from both the Gyro and the Accelerometer at the same time, and overlay them on top of one another in gnu plot.<\/p>\n Like so:<\/p>\ndefeated the dragon and rescued a fake princess who turned into a giant spider\u00a0<\/del> managed to get some meaningful data from both the gyrometer and the accelerometer. We also made some pretty graphs.<\/p>\n \/\/Create variables for outputs\r\n float xGyroRate, yGyroRate, zGyroRate, xGyroRate2, yGyroRate2, zGyroRate2;\r\n long Time;\r\n \/\/Read the x,y and z output rates from the gyroscope & correct for some innacuracy; convert to seconds\r\n xGyroRate = (gyroReadX())\/57.5;\r\n yGyroRate = (gyroReadY())\/57.5;\r\n zGyroRate = (gyroReadZ())\/57.5;\r\n \/\/Determine how long it's been moving at this 'rate', in seconds\r\n Time = (millis()-previousMillis);\r\n \/\/Multiply rates by duration\r\n xGyroRate2 = -(xGyroRate\/Time)\/4;\r\n yGyroRate2 = -(yGyroRate\/Time)\/4;\r\n zGyroRate2 = -(zGyroRate\/Time)\/4;\r\n \/\/Add to cumulative figure\r\n if (((xGyroRate2)>(gyroLPF))||((xGyroRate2)<(-gyroLPF))) CumulatGyroX += (xGyroRate2); if (yGyroRate2>gyroLPF||yGyroRate2<-gyroLPF) CumulatGyroY += (yGyroRate2); if (zGyroRate2>gyroLPF||zGyroRate2<-gyroLPF)\r\n CumulatGyroZ += (zGyroRate2);<\/pre>\n