Download from an already existing logger

edited February 2019 in Python

Hello,
I'm trying to download from a current running logger after it's already been initialized when running another script. I used the mbl_mw_logger_lookup_id function to find and access the logger if it exists. I made a script that initializes a logger if it doesn't exist and downloads the data without stopping the logger. When running the same script a second time it should access the same logger and download from it, but it isn't working properly. It seems to be downloading the data because the longer I leave it logging (downtime between running the same script) the longer it takes to download, but the data is not being printed or put into a list. I'm sure that I've tried this method before and it worked, maybe I'm doing something different than from before? I've attached the script and would appreciate any help with this.

Comments

  • The board state is lost once your script terminates so mbl_mw_logger_lookup_id isn't going to ever return anything. You either have to serialize the board state after setting up the loggers, or use anonymous logging:
    https://mbientlab.com/tutorials/WPython.html#logging-anonymously

  • edited February 2019

    I tried the anonymous logging example which works, but it doesn't work with fused data (gyro and acc). I get the error:

    terminate called after throwing an instance of 'std::out_of_range'
    what(): _Map_base::at
    Aborted (core dumped)

    The error seems to occur here:
    libmetawear.mbl_mw_metawearboard_create_anonymous_datasignals(d.board, None, handler_fn)

    If possible, how would I modify the example to handle fused data?

  • edited February 2019

    Hrm, the API has not been thoroughly tested to support logging fused data. Data fusing is intended for streaming as the connection can become unstable from time to time.

    Since you are logging, you don't have to worry about maintaining a stable connection, so you can record individual sensors separately.

  • Thank you, that worked for me. For the record I was able to log fused data and download from it repeatedly in a script. I don't know how to implement that with anonymous logging so I'll try to work with this method. One difference that I have now is that the download time is now a bit over half the log time, with the logging fused data script it was about 1/3, with both sensors at 50 Hz. Is there a way to reduce the amount download time without adjusting the frequency of the sensors?

  • edited February 2019

    @mvela1 said:
    Thank you, that worked for me. For the record I was able to log fused data and download from it repeatedly in a script. I don't know how to implement that with anonymous logging so I'll try to work with this method.

    It works until you have have to rebuild the object state, which is what deserializing and anonymous logging does.

    One difference that I have now is that the download time is now a bit over half the log time, with the logging fused data script it was about 1/3, with both sensors at 50 Hz. Is there a way to reduce the amount download time without adjusting the frequency of the sensors?

    That is expected given how the logger stores data.

  • edited February 2019

    @Eric
    Alright, thank you for helping me with this issue. Also, is there a way to have the board save the data in float32 instead of float64?

Sign In or Register to comment.