Real time calculations in Python

Hi,

I'm trying to do some simple calculations with the live data (quaternions) that comes from the MMR+ sensor, but am unable to see how I can put it in a variable.

1) The stream_quat.py example just goes to sleep for 10 seconds (line 47) during which the data is streamed, while I want to grab the quaternion each time it is received (preferably 100 times per second) and perform a "real-time" calculation with it. How do I assign the received quaternion to one/multiple variables?

2) Also, we got MMR#1 (let's call it this quaternion "a") and MMR#2 (let's call it this quaternion "b") streaming data at slightly different intervals(due to missing data), how would I be able to do real-time calculations e.g. a*b=c when a new value for a is not always available at the same time as a new value for b?

Cheers

Comments

  • 1) This is not a MetaWear questions but rather a Python question. You need to modify the Python code to do this and use our APIs accordingly. I recommend taking a quick Python class and following up with our Python API tutorial: www.mbientlab.com/tutorials.
    Our APIs can be used to change sampling frequency, set rules for the sensors and so on.
    The stream_quat.py example is just a basic example you are expected to modify.

    2) You should always post process and fill in values with averages. For example:
    t = 1, data = x
    t = 2, no data
    t = 3, data = y
    post process:
    t = 1, data = x
    t = 2, x+y / 2
    t = 3, data = y

  • Thank you Laura.
    Still one crucial question remains: what function in your APIs can be used to grab a single quaternion value from a sensor (which is assignable to a variable) instead of a continuous stream (which is not assignable to a variable)?

  • You would want to do a single read like we do in our temperature example.

Sign In or Register to comment.