Code Update: Recording up and running!
Weekly update:
This week, we wrote a basic skeleton code app for Android OS. The focus of the app is to pull sensor data from our chosen device, reading from our list of chosen sensors. We started by building an app with 5 buttons: one button is linked to record each scenario we tell it to. So for example: when a button is pressed, the app begins recording the data from the sensors, the user then performs the action, and when the action is finished, the user pushes the button again and the recording stops. While the app is recording, the code locks the recording to that action, so you can't press multiple buttons as it would confuse the sensors and corrupt the data. The final step of our initial app is to take the data we have recorded from our session, and then write the output to a file, specifically an ARFF file (Attribute Relation File Format). Before writing to the file, we must first output the data in a format that ARFF accepts and that Weka (our statistics program) can understand.The code:
Our ARRF file will require the logged data to be in a specific format, ie: in lines where each line represents a recorded measurement and consists of 7 values. 3 floats from the gyroscope, 3 floats from the Accelerometer, and a string at the end of the line to tell the learner which action we are training. With this in mind, we decided to create a subclass called Reading with data fields representing each of the 7 values and a toString method for storing each measurement. To record the data we get the sensor type and values from the sensor event, store it in a temporary variable and then look for another measurement of the other type of sensor. If that measurement was recorded within 100ms of the previous measurement, so at about the same time, then we can use both of these measurements to instantiate a Reading object. We then add these to an arraylist for writing later. To write we needed to add a button that would take the contents of the arraylist and write it to a file, formatted correctly for use in the ARFF. This was relatively simple because we had the formatting done in the ToString method of the Reading class. We just needed to append these to a string and write with a filewriter. At the current stage this data is being stored in a text file, with the idea being that we will manually create the ARRF file and copy the data produced from the text file. The code was worked on by Oli, Sam and Al.We are currently just picking a value if it was within 100ms of the last one, there’s no consideration for which value is the best. If training the model doesn’t go well, we could potentially implement some kind of filter for this selection process.
The next step:
Next we need to manually go and record the data using our app and load this into Weka in order to train our model. Sam and James met up on Friday to do this however had a little bit of trouble with importing the framework and getting that up and running. To troubleshoot, we will ideally all meet up in the next day or so and come up with a solution.
Blog post written by Sam and Alex
Comments
Post a Comment