-
I have updated an app [1] to github for Bangle.js, which connects to a Puck.js, obtains some magnetometer data, and then finds the best fitting ellipse to this data. The object cal_data consists of a matrix A, a translation vector v, and a radius r. If the calibration goes as it should, then, if you first translate any reading from the magnetometer by -v, and then multiply the vector by A, then you should land on the sphere with radius r.
The app is still in a somewhat rudimentary form, but it works.
When the app is done with data collection and analysis, it displays some numbers on the screen. First, if the three eigenvalues displayed all coincide (more or less), then the data fits on a sphere, more or less, whereas if they are very different, then the ellipse is skewed, indicating 'soft iron distortion', whereas the transation vector indicates 'hard iron distortion (whatever that means).
I should note that the app tells the Puck.js to stop giving out data after 500 readings, which might be a bit much. However, data collection can be stopped by pressing the button on the Puck.js, it should be enough to let this run for just a couple of seconds, but make sure to rotate the Puck.js around while data is being gathered. Data gathering is indicated by blinking lights on the Puck.js.
The app also saves the data on the watch. For now, I will be using it for data collection, but the code is ready to be used with any application.
Right now I am going out for a run, I'll be back soon with new data from outside.
-
Right, I will continue coding, and update here. This project might split into a couple of branches, depending on usage. One is that I managed to fit the ellipse to a sphere on my laptop using python and numpy, which does everything one might need with accuracy.
In order to be able to calibrate on the run, I wanted to have this implemented on the puck itself, so that it can calibrate itself. I ran into an issue, though, which is that I made it save some readings, and then some computations, and it ran out of memory. I figured I'd try running basically the same code on the banglejs2, sourcing the data directly from the puck via bluetooth, and this worked better. However, the code for either puck or banglejs2 is not finished, for lack of libraries, but I have started implementing a simple diagonalization procedure in javascript which won't depend on any libraries. I'd love to pack this up into an app available for the banglejs, as well as a library for the puck. I will maybe have some format related questions when it comes to that.
In any case, this is part of a project I have been thinking about, which is to use the puck as a running footpod, and get (hopefully) an accurate speed. I hope to post some code on that soon. I might take the puck with me on a run and collect data, to see what calibration is needed out there, and work from there. I certainly shouldn't calibrate the magnetometer at home, since I have two big magnets sitting on my desk.
Doing continuous calibration "on the run" like that would be great. This might be difficult while running, though, since the puck would for the most part have the same part facing up (given that I won't be doing somersaults on the way, or taking falls at regular intervals, let's hope).
-
Btw, there is a post somewhere on the forum which gives code which calibrates the magnetometer by taking maximal and minimal values of coordinats, which allows for at least centering the ellipse at the origin. I imagine this is a very good approximation of a solution, and is quite good for many applications. Fitting the data on a sphere would be even better though :D
-
-
Hello,
I am working on code which calibrates the magnetometer on the puck.js. This hasn't been done, has it? A short review of online resources shows that this can be done using elementary linear algebra (and, apparently, involves distortion coming from 'soft' and 'hard' iron nearby). As seen in the attach picture (projection to the first two coordinates) the data fits on an ellipse. This can be corrected so that the data fits on a sphere centered at zero. The readings on the picture come directly from the magnetometer on a puck.js.
I am considering writing the whole thing up, but I wanted to know if there is an easy way to acces some "standard" libraries implementing things such as matrix multiplication, diagonalization, or svd decomposition, or such things. I am now in the process of learning how to use modules in node.js, since these things have been implemented, but I'm not sure how that would translate to the puck.js interpreter. Writing the whole thing up in a couple hundred lines seems like an easier way out at this point. But if these tools are available easily, that would be great.
-
Thanks for the responses.
I decied to go for a Polar H10, actually got in with a discount for some reason. It arrived just now, and I can confirm that
bthrm
and the hrv app work. Until the two puckjs which I ordered arrive, I might play with accelerometer data coming from it, if I can figure out how.When the puckjs arrive, I'll see if I can get it to trace out my steps to measure speed and distance, it would be super cool.
if you turn it on and start running immediately, the first few minutes it won't have many satellites, and as it gets more and gets more accurate the position it reports will fluctuate.
I always wait for the "GPS" in the lower left corner of the
run+
app to turn green before starting a run (although once I ran out of patience, but usually it doesn't take long). I had a look just now at a gpx file though, and the first turn is clearly way off, but the rest is mostly not bad. There are some squiggles where I go under bridges though, which is another point for footpods, if they work.There is something called 'kalman filter' that can be used to filter GPS coordinates/speed
Uh-oh, I do know some mathematics, but not so much statistics. I might dive into this to see if I can make it work, but I won't promise anything soon. But thanks for the tip, I'll see if I get anywhere.
they basically just stream the accelerometer data to a phone and get the phone to do the analysis
Do you think the banglejs is powerful enough for this sort of analysis? As a pure mathematician, I don't have a good sense for how much computation power is enough. My sense is that, theoretically, I should be able to use acceleration and gyro data to draw the curve of my foot for each step, using calculus. But wheather the watch (or puckjs) can do the computation in real time, I have no idea.
In terms of accuracy it'll be fine - it's probably got the same exact sensor as the Sryd
I can absolutely believe that :D
I used running footpods from the days before 😱 wrist based gps
I used to use a casio with a stopwatch back in the day. I would prepare and memorize an 8k/10k/14k route on google maps, and then write down my time in a little book :D
But yes, basically any footpod would do, but it seems to me that some of them use ant+, and not bluetooth. Banglejs doesn't support ant+, does it? A quick look at the webpages of some of the companies that sell footpods indicate that they only work with their watches. Even if it is maybe possible to get it to work with other devices, I would hesitate to buy one, if I don't know whether it will give any useful data.
But it seems to me that for such a device, there would be two distinct categories. One which calculates speed (as well as cadence, etc), and then sends that data over. It seems to me that this is what stryd does. The other category would be a device which send over accelerometer data, and then the receiving device is left in charge of computing the data to be displayed and logged. It seems to me that some of the garmin devices are in this category.
The former category would certainly be a nice, quick and easy solution. Even if it wasn't open source, having a black box that gives you this data would be great tool. If the puckjs can be programmed to serve such a function, this would be the best.
As for the second category, if it works, it would also be great. But if I have to program the banglejs, then I would see no reason not to use a puckjs, as long as it is accurate.
One of the difficulties seems to be simply distinguishing these cases, since the promotional material from any company just says it works well with their watch, and you're left guessing.
whilst you'll get a smooth trace the actual points are actually slightly off by a small amount each second, so for the overall trace it's fine and smooth, but if you actually take the instant data and use that to calculate pace then it jumps back and forth due to the small distances on the calculations
This makes a lot of sense, but I am surprised to mostly see banglejs underreport speed compared to garmin. If the points are jumping to the left or right, it should think it was going faster. I think this actually happened at some point when I was going under a bridge, but only for a moment.
Any code would be welcomed, to say the least. I hope I can put a bit of work into this project, and get at least an accurate cadence. It might take some time though.
Speaking of cadence, I'll just mention one last thing. On the wrist, banglejs gives a much lower value than the garmin, and I'm pretty sure the garmin is correct, since I used to actually follow a metronome function on the garmin, to get 180 steps per minute. Also, that data is coming from the garmin run dynamics pod, which clips on the waist, and should be pretty accurate. Unfortunatly, though, it is only ant+ (I think).
-
Hi,
I recently got a banglejs2 (love it, btw), and I am in the process of replacing my garmin fr245 with it, specifically for running. My main question is about feasability of getting accurate running speed, but I'll give some context.
I have now been using both watches for a couple of week on all my runs. I have found that the gps and heartrate monitor are not as accurate on the bangle as on the garmin, which I guess is no surprie, given garmin's reputation, and the price difference. When comparing gpx tracks on the laptop using a map, the bangle gives a route more or less conforming to the one I did, but the garmin route seems to conform much better.
On one hand, the heart rate monitor seems to give very inaccurate values. I should be able to connect a polar h10 chest strap to the bangle without problem, right? As far as I can tell, people have already done this, and this should give better accuracy than any wrist based optical heart rate monitor.
On the other hand, I would be super happy to have an accurate reading of speed when running. Although the bangle and garmin give me more or less the same reading on total distance, the number that bangle gives me during the run seems to be pretty inconsistent. Although I have no clear way of measuring this at the moment, it seems to me that the speed is often underreported, and occasionally overreported. This is in comparison with the garmin, but also supported by my "feeling" when looking at the two numbers (which is weak as evidence, but ok). I have tried configuring the recorder app to use 10, 3 and 1 second intervals, but the resuls are similar.
Idea 1: Is there any software solution to get a speed on the gps that fluctuates less? In principle, running in a mostly straight line should probably give an accurate reading on speed, even if the points are shifted. I'll admit that I have no idea about that, but it's worth asking.
Idea 2: There is a company out there, called stryd, which makes footpods specifically designed to measure a host of running data, and as far as I know, it is very accurate (but expensive). I might post something on their formus to see what they say, but does anyone know if it is possible to connect a stryd to a banglejs2, and in that case, what data could be logged down on the watch? For me, speed would be top concern, but I have been logging down cadence and ground contact time on my garmin (using a garmin running dynamics pod) and continuing that would be great. Their webpage has a list of "compatible" devices, and it does include many brands, but it doesn't mention being able to connect to some device and spit data at it. I'd love to try it and see what happens, but these devices are expensive.
Idea 3: The most fun project would be to replicate the functionality of commercially available footpods using a puckjs (or any other accelerometer). In principle, I understand that intergrating acceleration gives speed, and then distance. But I have no engineering experience, so I have no clue about noise and errors. So the question is, basically:
Is a puckjs accurate enough to measure the length of a step while running?
Does anyone have experience with a project like this?
Would it involve programming more complicated than summing up the stream of numbers to integrate?
Out there, footpods are reported to give a much more responsive reading of speed than gps. People swear by it, especially for sprints. Therefore, this could be a fantastic project. I currently don't have a puckjs, but I should probably get one, even if just to play with, since one stryd (mentioned in the previous question) is about ten puckjs, in terms of money.
-
Yes, I hope to have time this week to polish this app a little bit. Is there a procedure to upload an app to the espruino repository?