Odd values returned by map(ADD, String)
Hi,
I have a problem with results of map(Function2.ADD) while using it with named data route on Metawear C. Basically I would like to add absolute values of x and y retrieved from the acceloremeter. Retrieving, splitting and calculating absolute values work OK, but when I feed these values to the ADD function using feedback mechanism I am getting odd values (see logcat below):
I/MainActivity: x=0.096191406
I/MainActivity: y=0.026367188
I/MainActivity: x+y=5648.1226 [class java.lang.Float]
I/MainActivity: x=0.119628906
I/MainActivity: y=0.036132812
I/MainActivity: x+y=5648.156 [class java.lang.Float]
I/MainActivity: y=0.026367188
I/MainActivity: x+y=5648.1226 [class java.lang.Float]
I/MainActivity: x=0.119628906
I/MainActivity: y=0.036132812
I/MainActivity: x+y=5648.156 [class java.lang.Float]
It looks like there is something wrong happening with type casting at some point. At the same time when I change ADD to SUBTRACT the returned values (x-y) are correct. Please advise what am I doing wrong (the code below)? Thanks!
source.split().index(0).map(Function1.ABS_VALUE).name("xAxisAbs").stream(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Log.i("MainActivity", "x=" + data.value(Float.class).toString());
}
});
source.split().index(1).map(Function1.ABS_VALUE).name("yAxisAbs").stream(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Log.i("MainActivity", "y=" + data.value(Float.class).toString());
}
});
source.split().index(0).map(Function1.ABS_VALUE).map(Function2.ADD, "yAxisAbs").stream(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Log.i("MainActivity", "x+y=" + data.value(Float.class).toString() + " " + Arrays.toString(data.types()));
}
});
This discussion has been closed.
Comments