Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accelerometer and Gyroscope Log data and download #60

Open
MoatazHammouda opened this issue Jul 25, 2019 · 1 comment
Open

Accelerometer and Gyroscope Log data and download #60

MoatazHammouda opened this issue Jul 25, 2019 · 1 comment

Comments

@MoatazHammouda
Copy link

MoatazHammouda commented Jul 25, 2019

  • pymetawear version: 0.11.0
  • Python version: 2.7
  • Operating System: Ubuntu 18.04.2 LTS

Description

I attempted to start logging data with specific parameters for the accelerometer and the gyroscope on my MMC board. The accelerometer settings are 25 Hz and 2.0 range and the gyroscope settings are 25 Hz and 2000.0 range.

After I stop the logging, I attempt to download the logged data and that is when I get the error shown in the traceback message.

My Code

from __future__ import division
from __future__ import print_function
from __future__ import absolute_import

import time

from pymetawear.client import MetaWearClient
from pymetawear.exceptions import PyMetaWearException, PyMetaWearDownloadTimeout
import pandas as pd

client = MetaWearClient('E6:36:15:BD:D1:44', debug=False)

print("Write accelerometer settings...")
client.accelerometer.set_settings(data_rate=25.0, data_range=2.0)
client.gyroscope.set_settings(data_rate=25.0, data_range=2000.0)

client.accelerometer.high_frequency_stream = False
client.gyroscope.high_frequency_stream = False

client.accelerometer.start_logging()
client.gyroscope.start_logging()

print("Logging accelerometer and gyroscope data...")

time.sleep(10.0)

client.accelerometer.stop_logging()
client.gyroscope.stop_logging()
print("Logging stopped.")

print("Downloading accelerometer data...")
download_done = False
n = 0
data = None
while (not download_done) and n < 3:
    try:
        data = client.accelerometer.download_log()
        download_done = True
    except PyMetaWearDownloadTimeout:
        print("Download of log interrupted. Trying to reconnect...")
        client.disconnect()
        client.connect()
        n += 1
if data is None:
    raise PyMetaWearException("Download of logging data failed.")


df=pd.DataFrame(data)
df.to_csv('Accelerometer_10.csv')

time.sleep(5.0)

print("Downloading gyroscope data...")
download_done = False
n = 0
dataG = None
while (not download_done) and n < 3:
    try:
        dataG = client.gyroscope.download_log()
        download_done = True
    except PyMetaWearDownloadTimeout:
        print("Download of log interrupted. Trying to reconnect...")
        client.disconnect()
        client.connect()
        n += 1
if data is None:
    raise PyMetaWearException("Download of logging data failed.")

df2=pd.DataFrame(dataG)
df2.to_csv('Gyroscope_10.csv')

print("Disconnecting...")
client.disconnect()

What I Did

From my understanding based on the traceback error message shown below is that in the pymetawear.modules.base.py the default callback only takes one argument and that is why only the accelerometer data is downloaded and the traceback error is given.

So it would be a logical assumption that if that issue is solved then it would work. But I wanted to ask if there is another way to log the data of different sensors on the MMC and download them without going through that hassle.

Thank you.

The traceback error message:

Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 315, in 'calling callback function'
TypeError: wrapper() takes exactly 1 argument (2 given)
@krib-ula
Copy link

I am having the same issue - any suggestions for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants