Tuesday, September 27, 2016

Correcting longitudinal/lateral skew in accelerometer data traces.


Hmm. The title does not convey the importance of the subject. How about
"How to make your data to stop lying to you"?

I promised to cover the subject in Truths and lies of your basic racing datalogger.

 

What is actually the problem here?


As described in that post, there are 2 ways to get your acceleration values: one is through accelerometer's signal ("Proper Acceleration"), and another, through taking a second order derivative of your movement along or across your direction of travel ("GPS Acceleration", for the lack of a better term). As demonstrated in that post, "GPS Acceleration" can only be considered an approximation of what is actually going on. In most cases, very poor approximation indeed, requiring heavy post processing to result in anything resembling actual acceleration, as experienced by your race car and yourself or your driver.

"Proper Acceleration" measurement can have its own problems, it turns out. Here are 2 race cars. In the one on the left, accelerometer is positioned "square" with Longitudinal and Lateral axis of the car (yellow and white axis are aligned). Life is good.

In the one on the right, the accelerometer is rotated (yellow and white axis are not aligned) Now, when the car experiences Longitudinal acceleration, some component of it gets picked up by accelerometer's Longitudinal axis, and some - by its Lateral axis! Same for Lateral acceleration.


So, when you go and examine your data after the fact, you now see that your car has non-zero lateral acceleration when it is driving down the straight!

Here's an example:


Something is clearly not right. The car is driving down the straight yet it shows up to 0.1 G of Proper Lateral acceleration.
Of course, you can add an offset, of, say, -0.1 G, but now it's off in other sections. And, this also means that Longitudinal acceleration is off as well, without any clear indications of how much.

Your logger may offer a tool to calibrate itself to re-align the axis. To be honest, I have seen more cases where it did not work, than the ones where it did, so this is not my preferred way of resolving this issue.

By the way, you may ask, what's the big deal?

Well. I am glad you asked.

If we are talking about basic data logger that only records GPS and accelerometer data, and your Longitudinal and Lateral acceleration data is skewed - even by few degrees - here  are types of analysis you cannot do, since your results will range from meaningless to dangerously misleading:

  • Everything except staring at GPS Speed trace and your lap/segment times.

And here are types of analysis you can still do with skewed accelerometer data:

  • Staring at your GPS Speed trace
  • Lap/Segment times

I hope you enjoy staring at your GPS Trace... You can actually get a lot of useful info out of  Segment times analysis, so there's that.

Do you want to look at brake application profile? Engine performance? Cornering grip? Sorry, your results will be off, possibly to the point your analysis is hurting more than helping. Garbage in, garbage out, and all that.

Luckily, this is fairly straightforward problem to fix


We will be using math channels, and applying some high school geometry.(https://en.wikipedia.org/wiki/Rotation_(mathematics) - see "two dimensions section"). You remember your two dimensional vector rotations, don't you?

OK, here's how to set it up.


 Let's use AiM Race Analysis. After all, AiM solo is nearly 100% likely to be mis-oriented to the axis of the car it is mounted on... When you make something too easy, you run the risk of making it too easy to get it wrong.

By the way, this assumes that the accelerometer is, at least, aligned vertically (i.e. not tilted up/down, or, Euclid forbid, is lying down "on its face").

If not, the principles are similar, but you will have to correct in 3 dimension. Easy, right?


So, here we go.

Step 1.

Load up the session and create 2 “X-Y Plots”: Click “X-Y Plot” button, then select “create new”, instead of “activate existing”. Do it twice.



Step 2.

 Now, click on the windows resize button, to make the UI allow you to lay out all windows (instead of default single-tabbed-window view). For reasons we will never understand, that button is called "Restore-Down"...
 
 

Step 3.

 Now, it will look like RA just had a stroke. Don't panic, and calmly arrange 2 XY plot windows next to each other, don't worry about anything that may be hiding under them (don't worry if what's in the actual plot windows looks different, at this point)

 

 Step 4.

 Right click on the right plot, and go to "Plot Settings" (NOT "Settings"!)

 

Step 5.

 Select "GPS_LatAcc", or whatever it is called on your AiM logger as X axis.

Step 6.

Make sure you have same X-Y Plot selected (click anywhere within plot area). Now, in the "Measure list", on the left, select "GPS_LonAcc", and un-select everything else.

 Now, the right hand plot should look like this:
If it does not, and you are not able to make it look similar to this, I would recommend that you look through AiM tutorial/help files on X-Y Plots or call your AiM dealer and ask for help. I personally find that UI bewildering and illogical, not to mention outdated by about 30 years (just an opinion, ya'll), so I am not the best person to explain the basics of it to others...Err. Good luck. If you are REALLY stuck on this, email me.
OK, now we are going to create some math channels. If you never created AiM math channel, I highly recommend that you watch this video first, which walks through the basics of creating a calculated gear math channel:
 
 
Anyway, we are going to create 3 channels:

A. "G Angle Correction"

Set it as per this screenshot, I highlighted fields you will need to configure:
 
In "Formula", enter "0" instead of "-9", for now. everything else as shown.

B.  Corrected_lat_acc:

 
"Formula" value to copy/paste:
Longitudinal_a*sin(DEG2RAD*G Angle Correction)+Lateral_acc*cos(DEG2RAD*G Angle Correction)
Note: If your accelerometer has Longitudinal and Lateral acceleration values named differently than "Longitudinal_a" and "Lateral_acc", you will have to update those names, obviously. Use whichever ones you see in the "Identifier" list on the right (what, you mean it was not obvious that "IDENTIFIER" means  "LOGGED OR CALCULATED CHANNEL in Italian?!" Jeez...)

C. Corrected_long_acc:



"Formula" value to copy/paste:
Longitudinal_a*cos(DEG2RAD*G Angle Correction)-Lateral_acc*sin(DEG2RAD*G Angle Correction)

 Note: See above regarding channel names.
 

OK. Now you can leave math menu and finally configure X-Y plot on the left.

Basically, you are doing same exact thing as steps 4,5, and 6 above, but now use Corrected_lat_acc as X axis value, and Corrected_long_acc as the ONLY selected measure for the left hand plot.
 
Whew. If you had done everything right, and Pinocchio did not play any tricks on you along the way, you are going to see 2 "Friction Circle" plots, one of which is "rotated":
 


 
 
In the other post, I mentioned that GPS Acceleration values should not be trusted. Well, I was not entirely correct there. They can be trusted in terms of generalizes trends/distribution - i.e. as a baseline to understand how much "skew" we have in our accelerometer data. I am sorry, Pinocchio. I hope you can find it in your hard, wooden heart to forgive me.
Where was I? Ah OK. If you entered "0" in the G Angle Correction math formula, AND the left friction circle plot is not rotated relative to the right one, you are all set. You do not have any skew in your accelerometer data. Don't be mad at me for wasting your time, you have 2 new shiny friction circle plots to play with!
If the left one IS rotated, now comes the fun part. Go back to Maths menu, and enter a different value into G Angle Correction formula. Let's say, -20!
 
 
 
Well?
 
 
Oops, too much. Go back and back that value off a bit. It may take a few tries. Eventually, you should get something that looks like this:
 
 
Sweet!
 
All you have to do now, is use Corrected_long_acc and  Corrected_lat_acc in your analysis!
By the way, before you do anything else, go back to Maths, copy all 3 channels to "General" tab, and set checkbox for all of them to be inserted into new files automatically. This way, you will not have to repeat all this for every log file. Obviously, if you change orientation of your logger, or load someone else's file, you will need to go and adjust that value. Use "double friction circle" view to check alignment in new files and you should be golden.
Oh, to go back to "classic" RA view, just hit "Maximize" button on any of the windows...
 
 

Here's how much difference this can make:

 
Highlighted are the sections where data skew was creating a pattern that was outright wrong for what was actually going on with the car. This was about 9 degree rotation of the logger relative to the car.
 
Here's more extreme example, where the logger is rotated nearly 20 degrees:
 
Hopefully, these examples drive the point home, regarding how critical it is to
1. Check if your accelerometer is aligned with car's axis
2. Create corrected channels if it is not, and use ONLY those channels for your analysis.
 
 
 

No comments:

Post a Comment