Stream Filtered Accelerometer Data
Hi,
I am trying to filter and stream filtered accelerometer data. Eventually I'd like to program the board to only store data from when the board is moving.
I very new to Java and Metawear, but from what I can tell I need to map or split the data before filtering. Can the full set of data (x, y and z) be streamed after satisfying filter conditions?
Here is the code I've got (adapted from the freefall tutorial which was super helpful!). Outputting "data.value(Acceleration.class)"in any form doesn't seem to work but doesn't give an error in the log
return accelerometer.acceleration().addRouteAsync(new RouteBuilder() {
@Override
public void configure(RouteComponent source) {
source.map(Function1.RSS).average((byte) 4).filter(ThresholdOutput.ABSOLUTE,1f,0.01f)
.multicast()
.to()
.stream(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Log.i("freefall", "move");
Log.i("freefall", String.valueOf(data.value(Acceleration.class).x()));
CONTENT = CONTENT + "\n" + data.formattedTimestamp() + "," + data.value(Acceleration.class).toString();
}
})
.end();
}
});I'm using a metawear C with the latest firmware on a samsung galaxy s 6 edge.
Thanks!
-Tom
This discussion has been closed.
Comments
return accelerometer.acceleration().addRouteAsync(new RouteBuilder() {@Override
public void configure(RouteComponent source) {
source.limit(Passthrough.CONDITIONAL, (short) 0).name("Passthrough Acceleration").stream(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Log.i("freefall", "move");
Log.i("freefall", data.toString());
}
});
}
});
public void configure(RouteComponent source) {source.map(Function1.RSS).average((byte) 4).filter(ThresholdOutput.ABSOLUTE,0.1f,0.01f)
.limit(Passthrough.CONDITIONAL, (short) 1).name("filteredAC").stream(new Subscriber()
{
public void apply(Data data, Object... env) {
Log.i("freefall", "move");
dataprocessor.edit("filteredAC", DataProcessor.PassthroughEditor.class).modify(Passthrough.ALL,(short) 1);
Log.i("freefall",data.toString());
}
});
}
private void download() {
final TextView infoText = (TextView)findViewById(R.id.info);
Log.i("freefall", "Downloading..");
logging.downloadAsync(100, new Logging.LogDownloadUpdateHandler() {
@Override
public void receivedUpdate(long nEntriesLeft, long totalEntries) {
Log.i("freefall", "Progress Update = " + nEntriesLeft + "/" + totalEntries);
}
}).continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) throws Exception {
Log.i("freefall", "Download completed");
logging.clearEntries();
return null;
}
});