Euler angles
I'm currently working on integrating an MMC sensor via python in the attempt to read the Euler angles from the sensor and save them on a text file.
Attached is a script that I've used to setup and read the angles but it only displays the angles on the terminal.
I've tried several ways to determine how i can extract the data and save it but i dont understand how the angles are wrapped up in the lambda function.
If you could kindly assist on a possible way forward that would be greatly appreciated.
CODE:
from future import print_function
from mbientlab.metawear import MetaWear
from mbientlab.metawear.cbindings import *
from mbientlab.warble import *
from time import sleep
from mbientlab.metawear import *
from mbientlab.metawear.cbindings import *
from datetime import *
import sys
import platform
import six
hard coded the address in, just not displaying it here
device = MetaWear("xx:xx:xx:xx:xx:xx")
device.connect()
board = device.board
print("connected to")
euler_signal = libmetawear.mbl_mw_sensor_fusion_get_data_signal(board, SensorFusionData.EULER_ANGLE)
euler_callback = FnVoid_VoidP_DataP(lambda context,data:print("epoch: %s, euler %s\n" % (data.contents.epoch, parse_value(data))))
libmetawear.mbl_mw_datasignal_subscribe(euler_signal, None, euler_callback)
libmetawear.mbl_mw_sensor_fusion_enable_data(board, SensorFusionData.EULER_ANGLE)
libmetawear.mbl_mw_sensor_fusion_set_mode(board, SensorFusionMode.NDOF)
libmetawear.mbl_mw_sensor_fusion_write_config(board)
libmetawear.mbl_mw_sensor_fusion_start(board)
input("")
libmetawear.mbl_mw_sensor_fusion_stop(board)
libmetawear.mbl_mw_sensor_fusion_clear_enabled_mask(board)
libmetawear.mbl_mw_datasignal_unsubscribe(euler_signal)
device.disconnect()
sleep(1)
Comments
You need to read up on how to code in Python.
Once you are comfortable, you can modify this script by opening a file and writing the angles to that file.