Accelerometer multiple axeses

I am trying to evaluate the accelerometer based on multiple axises. 

pseudocode from what I'm trying to achieve is as follows:

accelModule.routeData().fromZAxis()
.split()
.branch().process(new Comparison(Comparison.Operation.LTE, -0.8))
.monitor...... turn on blue light
.branch().process(new Comparison(Comparison.Operation.GTE, 0.8))
.monitor....  turn on red light
.branch()... turn off light

I know the documentation states you can not use the "comparison" filter when using
accelModule.routeData().fromAxis

without doing a "summing" operation such as RSS() or RMS()... is there a way to evaluate the accelerometers 3 axises and make decisions accordingly?

i.e. if accelerometer.X > 1 and accelerometer.Y < 0
Do this...






Comments

  • No, the data processor does not support operations using multiple data sources.
  • Do you know if you plan on providing this support in the future?  
  • +1 
    What best practice to check axis X,Y,Z to do something "offline" ?
    For instance I need this for the MetaDice
  • Can we get X,Y,Z values from DataToken ? Or use a Processor to store the X,Y,Z values ?

    AsyncOperation<RouteManager> routeManagerResult = accelModule.routeData().fromAxes().monitor(
    new DataSignal.ActivityHandler() {
    @Override
    public void onSignalActive(Map<String, DataProcessor> processors, DataSignal.DataToken token) {
    Log.i("SIGNAL", "ACTIVE");

    ledModule.configureColorChannel(Led.ColorChannel.RED)
    .setRiseTime((short) 0).setPulseDuration((short) 400)
    .setRepeatCount((byte) 2).setHighTime((short) 200)
    .setHighIntensity((byte) 16).setLowIntensity((byte) 16)
    .commit();
    ledModule.play(true);
    }
    }
    ).commit();
  • I have found a way to accomplish something that allows this to be accomplished...  I could only get it to work using the android SDK... the IOS SDK has the primitives to perform this operation but I believe it has some bugs.

    The key was using the "Passthrough" filter.

    accelModule.routeData().fromYAxis()
    .process(new Maths(Maths.Operation.ADD, 0))
    .split()
    .branch().process(new Comparison(Comparison.Operation.LTE, 0.5)) //Left side
    .branch().process(new Comparison(Comparison.Operation.GTE, -0.5)) //Left side
    .process("temp_cond_gate", new Passthrough(Passthrough.Mode.CONDITIONAL, (short) 1))
    .process(new Time(Time.OutputMode.ABSOLUTE, 30000))
    .monitor(new DataSignal.ActivityHandler() {
    @Override
    public void onSignalActive(Map<String, DataProcessor> processors,
    DataSignal.DataToken token) {
    ledModule.stop(true);
    ledModule.configureColorChannel(Led.ColorChannel.RED)
    .setRiseTime((short) 0)
    .setPulseDuration((short) 2000).setRepeatCount((byte) -1)
    .setHighTime((short) 1000).setHighIntensity((byte) 31)
    .setLowIntensity((byte) 31).commit();
    ledModule.play(true);
    }
    }).end()
    .commit();

    accelModule.routeData().fromXAxis()
    .process(new Maths(Maths.Operation.ADD, 0))
    .split()
    .process(new Comparison(Comparison.Operation.GT, -0.75))
    .monitor(new DataSignal.ActivityHandler() {
    @Override
    public void onSignalActive(Map<String, DataProcessor> processors,
    DataSignal.DataToken token) {
    //Turn it off
    processors.get("temp_cond_gate").setState(new Passthrough.State((short) 0));
    }
    }).end()
    .commit();


    accelModule.routeData().fromXAxis()
    .process(new Maths(Maths.Operation.ADD, 0))
    .split()
    .process(new Comparison(Comparison.Operation.LT, -0.75))
    .monitor(new DataSignal.ActivityHandler() {
    @Override
    public void onSignalActive(Map<String, DataProcessor> processors,
    DataSignal.DataToken token) {
    ledModule.stop(true);

    //Turn it on
    processors.get("temp_cond_gate").setState(new Passthrough.State((short) 1));
    }
    }).end()
    .commit();


  • edited March 2016
    Apologies, I spoke too hastily.  The data processor does support multiple sources for some processors, such as comparator and math, which can be used to create feedback or feedforward loops; this is expressed with the DataToken class.  What it does not do is perform boolean logic i.e. there is no processor that transforms "X > Y " into 0/1 nor computes "0 and 1".  It is something that we can look into adding so you don't have to use funky passthrough processors.

    I drew this up earlier but it looks like you beat me to the punch =).
    https://www.dropbox.com/s/1l8tpa7kg1ol7kr/and_passthrough.jpg

    What specifically are you looking to accomplish?

    If you need access to individual XYZ values, use the "fromAxis" functions.
  • edited March 2016
    In fact with Stream code I do (but it could be much more complicated):
    public void process(Message message) {
        final CartesianFloat axes = message.getData(CartesianFloat.class);
    if (axes.x() < -0.8){
    setDice(5); // A
    } else if (axes.x() > 0.8){
    setDice(3); // B
    } else if (axes.y() < -0.8){
    setDice(4); // C
    } else if (axes.y() > 0.8){
    setDice(2); // D
    } else if (axes.z() < -0.8){
    setDice(1); // E
    } else if (axes.z() > 0.8){
    setDice(6); // F
    }
    }
    So I was looking the best way to do that logic on board to update the minor state of iBeacon. The trick of using settingsModule.startAdvertisement(); with  settingsModule.configure().setAdInterval((short)200, (byte)2); works fine
    Can I retrieve X,Y,Z and do some code logic in monitor() function ?
  • Unless I misunderstood Eric I don't believe you can not retrieve x,y,z on the acceleromter and do logic...  You would have to use feedback and forward loops as specified above.
  • edited March 2016
    @Eric  ok it almost work !

    - The settingsModule.startAdvertisement(); crash the BLE connection with the mobile but it's OK
    - I lost the X Axis:

    The stream part works with all sides but the monitor part never call sides 5 and 3 I don't understand why. 
    May be a side effect ? I assume X, Y, and Z can be triggered at the same time and override each other ? 

    But moving X and Y code still prevent 5 and 3. May be X axis is more sensitive ?

    Any ideas ?

    I also do:
    settingsModule.configure().setAdInterval((short) 200, (byte) 2);
    Don't know if it's good values ? 

    Thanks

    EDIT: I comment code Y and Z but X still doesn't trigger ? Thats weird ? (Metaware C)
    EDIT2: I also need to remove battery to get an up to date code


  • Hrm...if you reduce the data rate to say 25Hz or lower, does the chain work then?  I don't see anything wrong codewise in the firmware comparator but this is an odd occurrence.
  • Yes it workss !!!!
    Thanks
This discussion has been closed.