working with accelerometer

I am trying to use tha accelerometer in an APP.
the simulator can offer some random data for that....
but how did you work to get some real data to check your algorithm ?
is there an app to just "record" real data on a watch without treatment ?
May I need to write/modify my app to write accelerator data ?
  • I wrote an app that actually logs data and sends it to a server of mine via web requests. That let me play with the data in a windows application where debugging was much easier. I was then able to take snippets of data and hard code the data in my CIQ app for testing there.

    What are you trying to accomplish? In my case I was trying to detect a golf swing so 10 seconds of data was plenty. I started from the sample pitch counter.
  • In the Pitch counter sample in the SDK, there's a .fit file for that, but not sure what was used to record it. Have you tried playing back one of your own fits?
  • well, I am trying to detect an archery shot, so much like your cas of goff swing, it should be like 10 sec
  • I wrote an app that actually logs data and sends it to a server of mine via web requests. That let me play with the data in a windows application where debugging was much easier. I was then able to take snippets of data and hard code the data in my CIQ app for testing there.

    What are you trying to accomplish? In my case I was trying to detect a golf swing so 10 seconds of data was plenty. I started from the sample pitch counter.


    Is it free od downloadable ?
  • The .FIT file in the pitch counter is interesting. A couple of message records that I hadn't seen before, with ID 165 and 233. I'm guessing the record 165, which contains 3 values, is just the X, Y, and Z accelerometer parameters. Is there some kind of defined interface for .FIT file additions for the simulator? The 233 records don't seem to have any data.

    I'd be happy to share but it is a bit convoluted and would take a bit of work to adapt. To fully take advantage, you'd need a web server to handle web requests - although you could achieve the same thing with Debug.println's, just in a more manual way since the space is limited, and you'd need to manually copy the values. All my server does is write the data to a file. My Windows SwingDetect app then reads in, parses, and graphs the accelerometer data. It was definitely helpful to graph. But even just my CIQ app would be helpful since it graphs the data on the screen for X, Y, and Z.

    I just through the code for the CIQ app out on GitHub: https://github.com/ekutter/CIQTest. Feel free to use what you want.

    I didn't really do any cleanup so the code might take a little work to understand. I have a bunch of my own idiosyncrasies. Sorry.
    In the HTTP file, I did remove my server name.
    There's also a bunch of code for compressing the data down into a string 2 digit, base 52.
    It's targeted at the Fenix 5+ and 935. Enter button starts/stops the graphing. Down Button sends the data shown on the screen (which won't actually work without a server setup).


    If you are a Windows 10 developer with c# and Visual Studio experience, I'm happy to share the server side code as well.

  • Thinking a bit more about this, it actually wouldn't be that hard to create your own .FIT files, using the pitch counter as a reference. Although you'd need an app to create .FIT files. Probably could just adapt the fitfile SDK to do this. The messages with acceleromter data seem pretty simple. But if you aren't already familiar doing low level stuff with .FIT files, there will definitely be a learning curve. I have an app that reads and displays them, but I've never tried to write them.
  • You can capture this data using the SDK pretty easily. You just need to create a FIT recording session via a call to ActivityRecording.createSession(), and pass a SensorLogging.SensorLogger to tell it what data to record. The PitchCounter does this.

    mLogger = new SensorLogging.SensorLogger({
    :enableAccelerometer => true
    });
    mSession = ActivityRecording.createSession({
    :name=>"PitchCounter",
    :sport=>ActivityRecording.SPORT_GENERIC,
    :sensorLogger => mLogger
    });


    That should record data to the .FIT file at 25Hz. You should be able to use the FIT SDK tools to convert the FIT file into something you can read with other software pretty easily.

    Travis
  • Awesome. Thanks Travis. I wasn't aware of the SensorLogging interface, being able to customize which sensors got logged. That would have been a better method than my server method. Then you could easily just add a lap via button press any time you want to mark that a swing should have been detected.

    I think every few months I need to go back through all the docs/API as it's so easy to miss stuff, and new features seem to be coming along all the time.
  • thanks Travis and ekutter. I should be able to create a simple HTTP server to test, a,nd the idea to be able to log data in FIT for later use in simulator is interessting. it only implied that I have a sufficiently working app for that ! The HTTP way would allow me no test/check different alog/situation in a more easy way !
  • Awesome. Thanks Travis. I wasn't aware of the SensorLogging interface, being able to customize which sensors got logged. That would have been a better method than my server method. Then you could easily just add a lap via button press any time you want to mark that a swing should have been detected.

    I think every few months I need to go back through all the docs/API as it's so easy to miss stuff, and new features seem to be coming along all the time.


    what type of algorithm did you use in your swing detection ?