View Full Version : Relation between RAF and Outsim Data
Shotglass
29th November 2005, 18:05
the main questions i have atm are:
a) whats a right-vector and whats a forward-vector (and what dimensions do the x y z components of those have)
b) in what units are heading pitch and roll expressed and how are they related to the above mentioned vectors (probably can work this out myself as soon as i know what those vectors are)
c) is speed in the raf the sum of the x y and z velocity of outsim and are those outsim velocities also of the dimension m/s
d) i guess the time in outsim resets back to 0 if it exceeds the range for an unsigned ?
e) are all those variable types standard ansi c ?
f) whats an index distance ?
Bob Smith
29th November 2005, 23:41
b) radians
c) Yes
d) Yes
Shotglass
1st December 2005, 21:58
thx so far
@ b) id like to know the max and min values for those and direction in which they are counted too
*bump*
Bob Smith
1st December 2005, 23:25
Negative Pi to positive Pi, what with there being 2*Pi radians in a full circle. IIRC negative is left.
the_angry_angel
2nd December 2005, 09:43
a) Its been a while, but I think that LFS is left handed, so the Z axis is the forwards vector (positive going into the screen), and that Y vector is across the bottom of the screen - postive on the right side (I'll have to check though, so dont hold me to that)
e) Should be. You can susbsitute BYTE with unsigned char if its not defined.
Shotglass
2nd December 2005, 11:38
Its been a while, but I think that LFS is left handed, so the Z axis is the forwards vector (positive going into the screen), and that Y vector is across the bottom of the screen - postive on the right side (I'll have to check though, so dont hold me to that)
hmmm i assumed that the coordinates all those vectors are expressed in are not in a car related system but in a static track related one and that the forward and right vector somehow characterised the relation between the system of the track and the one of the car
the_angry_angel
2nd December 2005, 12:04
Now you've said that, you've got me doubting myself. Bugger. I'll have a check when I get home from work tonight.
Fonnybone
2nd December 2005, 21:32
the main questions i have atm are:
a) whats a right-vector and whats a forward-vector (and what dimensions do the x y z components of those have)
b) in what units are heading pitch and roll expressed and how are they related to the above mentioned vectors (probably can work this out myself as soon as i know what those vectors are)
c) is speed in the raf the sum of the x y and z velocity of outsim and are those outsim velocities also of the dimension m/s
d) i guess the time in outsim resets back to 0 if it exceeds the range for an unsigned ?
e) are all those variable types standard ansi c ?
f) whats an index distance ?
Hehe, i had the same confusion myself !
a) 'Right' vector means the x axis, lateral, perpendicualar to the vehicle's
direction of travel, while the 'Forward' vector is the y axis, longitudinal,
parallel to the car's direction of travel. Both are relative to the car.
As mentionned above, LFS uses metric units, so angles are in radian,
distance is in meters, acceleration is m/sē, speed is in m/s and angular
velocity is in radian/secē (something like that, not sure about the 'ē').
Moved thread to Programmer's section
Shotglass
3rd December 2005, 05:20
'Right' vector means the x axis, lateral, perpendicualar to the vehicle's direction of travel
so its literaly the vector pointing to the right of the car ?
while the 'Forward' vector is the y axis, longitudinal parallel to the car's direction of travel. Both are relative to the car.
ok its al starting to make sense now
As mentionned above, LFS uses metric units, so angles are in radian,
distance is in meters, acceleration is m/sē, speed is in m/s and angular
velocity is in radian/secē (something like that, not sure about the 'ē').
and what kind of standardisation is used for vectors ?
Moved thread to Programmer's section
whoops didnt even think about that section when i posted :schwitz:
so if i understood al that right roll should be:
arctan(rz/(rx+ry)) + (\pi / 2)*(1 - sign(rx+ry)) + \phi_1
and pitch should be
arctan(fz/(fx+fy)) + (\pi / 2)*(1 - sign(fx+fy)) + \phi_2
with \phi_1 and \phi_2 being phases depending on where lfs sets 0 pitch and 0 roll
trouble is the raf documentation has this to say about converting fw-vector components into heading:
To work out heading from the forward-vector
-------------------------------------------
float b = FX / 32767.0f; // convert FX to a float from -1 to 1
float e = FY / 32767.0f; // convert FY to a float from -1 to 1
float heading = atan2(-b, e); // heading (anti-clockwise from above)
whats the point of the division by 32767.0f ?
Fonnybone
3rd December 2005, 07:15
I have to be in the mood to understand this stuff so i'll just post
the info i got from Scawen himself ;)
I had trouble too at first, depending how it's written, it can be disorienting :p
Just remember that Current=Forward=Longitudinal and that "Right"=Right=Lateral.
Here's how to work it out. Note, heading is anti-clockwise.
Current direction vector (xF, yF) is ( -sin(heading), cos(heading) )
"Right" direction Vector (xR, yR) is ( cos(heading), sin(heading) )
Force vector is (FX, FY)
Get the force in any direction as dot product (scalar product) of the Force Vector
and that Direction Vector :
Forward force = xF * FX + yF * FY = -sin(heading) * FX + cos(heading) * FY
Right force = xR * FX + yR * FY = cos(heading) * FX + sin(heading) * FY
Shotglass
4th December 2005, 00:50
hmmm i guess i really need a drawing of where all those vectors and axis are pointing at and how those values are calculated and normalised
Nitemare
20th December 2005, 19:26
here's a pic, how i think it is...
http://nitemare.misto.cz/vectors.gif
orientation of x, y axes is same as of world coordinates, origin of axes is in car's COG
F is a "forward-vector", R is a "right-vector"
φ = arctg(-Fx / Fy) is heading
X = F + R
...but i'm not sure what does F, R and X vectors represent - speed? acceleration?
edit: also there is no "up-vector" (at least in RAF), so i guess it's impossible to get exact amount of bodyroll?
TagForce
21st December 2005, 10:34
here's a pic, how i think it is...
orientation of x, y axes is same as of world coordinates, origin of axes is in car's COG
F is a "forward-vector", R is a "right-vector"
φ = arctg(-Fx / Fy) is heading
length (absolute value) of F is |F| = sqrt(Fx^2 + Fy^2)
X = F + R
...but i'm not sure what does F, R and X vectors represent - speed? acceleration?
edit: also there is no "up-vector" (at least in RAF), so i guess it's impossible to get exact amount of bodyroll?
There doesn't need to be an up-vector... The vectors are 3D... So, there's an X-value, a Y-value, and a Z-value that would point up. So my guess is that the Z value of the forward vector would somehow be able to give us the amount of pitch, and the Z value of the Right Vector should tell us something about roll... But I get really strange values comparing RAF output to Outsim data, so I really don't know for sure. What units does the Outsim data use, exactly? I get like 3.00 for heading in Outsim, when the RAF output heading gives -121 degrees. Which of course could be down to my really bad programming skills.
Would love Scawen to elaborate on this subject (I've decided to wait until 2006 to actually send him an email, so as not to bother him during the holidays)
Bob Smith
21st December 2005, 12:46
I get like 3.00 for heading in Outsim, when the RAF output heading gives -121 degrees.
You're comparing radians to degrees. You need to convert one of them first. :)
Nitemare
21st December 2005, 13:00
oh, i somehow thought that they are 2d... oh well..
in that case, to get the vector that is pointing "up" you need to get cross product (http://en.wikipedia.org/wiki/Cross_product), F x R
and body roll is the angle between R and it's projection on the xy plane R' = (Rx, Ry, 0)
ρ = arccos( R.R' / |R|.|R'| ) = arccos( (Rx^2 + Ry^2) / ( sqrt( Rx^2 + Ry^2 + Rz^2 ) . sqrt( Rx^2 + Ry^2 ) ) )
same thing for pitch and F
TagForce
21st December 2005, 13:06
You're comparing radians to degrees. You need to convert one of them first. :)
I'm way ahead of you... (the 121 was converted from radians to degrees)
then I get a value of 171.892 degrees instead of 3.00 radians... Which still makes no sense whatsoever, if looked at clockwise or anticlockwise... But like I said... I don't trust my programming skills, and as of now my computer to calculate anything more complex as 1+1=2... I'm having weird problems with a counter resetting to 0 in a For-loop as well...
When I get home I'll try to show you part of the datablocks that matter in this case for both RAF files and Kegetys' Ghost files (which he says is raw Outsim output).
Victor
27th December 2005, 16:04
something quoted from scawen I had lying around:
heading, pitch and roll are in radians.
acceleration is in metres per second squared.
velocity is in metres per second.
velocity and acceleration are indeed in the "world" coordinate system.
to work out a car's orientation matrix, the calculation order is : roll,
pitch, heading
to work out the acceleration or velocity in the car's coordinate system, a
programmer should create horizontal (x) forward (y) and up (z) vectors
(using the heading, pitch and roll) and take the dot product (scalar
product) of these with the acceleration or velocity vectors supplied in the
outsim packet.
Shotglass
27th December 2005, 17:13
hmmm ill try to be more specific
a) heading pitch and roll are radians ... ok but from which axis are they counted from (ie where does a vector with 0 h/p/r point to) and in which direction are they counted
b) is nites pic of the forward and right vecors correct and whats the lenght of those vectors ?
TagForce
27th December 2005, 18:29
hmmm ill try to be more specific
a) heading pitch and roll are radians ... ok but from which axis are they counted from (ie where does a vector with 0 h/p/r point to) and in which direction are they counted
b) is nites pic of the forward and right vecors correct and whats the lenght of those vectors ?
a) center of gravity of the car pointing through the middle of the hood... and at a straight angle of that to the right, and the third axis goes from the COG straight through the roof towards the heavens. All of them are fixed on the car, not the world. <-- that's in fact the force vectors... Heading pitch and roll relative to the cars 0 (stationary) point should be derived from that, I suppose.
b) As far as I can tell now, yes, or something really much like it... I have yet to do some testing. The length of the vectors is just what we need to find out to get useful information. See it like the vector points from the lower left point of a box to the upper right corner of the same box... If you know the size of the sides of each face of the box, you can draw up a triangle that precisely cuts the entire box in half, and calculate it's longest edge's length (which would be the length of the vector).
Say: X, Y, and Z are 1, 3, 5 respectively... That would mean that you can get the length of the vector A (which points to X, Y)... Knowing that one you'd be able to get the XYZ vector (which is simply the length of the final unknown length of the 0 -> X,Y -> Z triangle, which is Z -> 0)...
Yeah, I'm not a math teacher for a very good reason... Does this make any sense?
@ Victor:
Thanks... Not sure what it means yet, but I'll get it sometime real soon.
gadaga
2nd January 2006, 17:03
Dear all,
I've got my little motion platform up and running.... Need to feed it now with data from my favorate sims....
Could anyone please indicate where I can find Microsoft Visual C++ (V6)source code for a little program capable of reading and decoding the LFS UDP packets ?
Can this programm be run on the same computer that is hosting LFS ? I really hope so....
Thanks
Bob Smith
2nd January 2006, 18:09
Stuff and myself created such a program under VB6. Yes it can be run on the same PC that LFS is running on. Perhaps if you have a look at the code for that it will help you understand how to code it in C++.
http://www.lfsforum.net/showthread.php?t=3019&page=2
gadaga
3rd January 2006, 20:52
Stuff and myself created such a program under VB6. Yes it can be run on the same PC that LFS is running on. Perhaps if you have a look at the code for that it will help you understand how to code it in C++.
http://www.lfsforum.net/showthread.php?t=3019&page=2
Are you sure that the tread you've indicated contains the source code ? I can't find it.
Thanks for your help !
Nitemare
12th January 2006, 18:23
...i just made a test, and measured length of forward and right vectors throughout a lap... and it stays constant : 37220
so i think those vectors are there just to give us data on orientation of the car and nothing else...
so, how else could i get longitudial, lateral and vertical acceleration from RAF file???
...all there is in RAF is speed, distance, absolute coordinates, and orientation of the car... :shrug:
MonkOnHotTinRoof
12th January 2006, 20:15
so, how else could i get longitudial, lateral and vertical acceleration from RAF file???
You also have X force and Y force for each wheel :
DYNAMIC WHEEL INFO : size 32 bytes (C) per wheel
1 float 0 suspension deflect : compression from unloaded
1 float 4 steer : including Ackermann and toe
1 float 12 X force : force right
1 float 16 Y force : force forward
1 float 8 vertical load : perpendicular to surface
1 float 20 angular velocity : radians/s
1 float 24 lean rel. to road : radians a-c viewed from rear
4 byte 28 0 :
Nitemare
12th January 2006, 20:30
i know, but those are forces acting on tyre's contact patch... i need forces, as if they were measured by sensors mounted inside the car..
it might be possible to take forces from all four wheels and count average value of them, but that won't be very precise...
i was thinking a bit about it, and everything that is needed is to take a piece of car's trajectory, and somehow aproximate it to a circle.. then the acceleration to the centre of the circle is a = v^2 / r where v is car's velocity, and r radius of circle
Shotglass
13th January 2006, 02:15
...i just made a test, and measured length of forward and right vectors throughout a lap... and it stays constant : 37220
so they are unit vectors ... great one step further in understanding the data
so, how else could i get longitudial, lateral and vertical acceleration from RAF file???
...all there is in RAF is speed, distance, absolute coordinates, and orientation of the car... :shrug:
take the velocity vector project it along the cars coordinate system and build the time derivative (very easy since the raf output is discrete time)
edit:
then again atm i have no idea how to convert the scalar speed in the raf to a vector
Nitemare
13th January 2006, 02:26
take the velocity vector project it along the cars coordinate system and build the time derivative (very easy since the raf output is discrete time)
that is for longtitudial accelration... the tricky part is the lateral... we discussed it on czech forum and Chaos had an idea to use three points from cars trajectory (in times t-1, t and t+1) , make a triangle from them, and then make a circle that intersects all three vertexes... and then use radius of that circle in equation i wrote above...
Shotglass
13th January 2006, 03:47
no the idea is if you have a velocity vector (like you do using outsim data) in the xyz system you can poject that vector along the rfu (right forward up) axes of the cars system
then youll have longitudinal lateral and normal velocities which you can then derivate to work out the respective accel components
trouble is raf doesnt give you the velocity as a vector
colcob
13th January 2006, 10:58
Havent read the whole thread so I'm not sure if this is useful, but RAF gives you X, Y and Z position at 0.01s intervals so velocity vector is pretty easy to calculate for each timestep.
Nitemare
14th January 2006, 16:43
yup, but assuming that car is in turn and accelerating at the same time, there are two forces acting on it, one has the direction of velocity vector (tangent to the trajectory), and is a derivative of speed (let's call it aLON), the other one points into center of turn, and it is described by equation aLAT = v^2 / r
the force which i have to project to F and R vectors is then a = aLON + aLAT
anyway.. picture is worth a thousand words:
http://nitemare.misto.cz/vectors2.gif
w126
14th January 2006, 17:30
Car's accelaration is second time derivative of (X, Y, Z) vector. You can normalize right-vector and forward-vector (their length should be 1). You can also construct up-vector as their cross product. Then lateral accelaration is dot product of accelaration vector and normalized right-vector etc.
Shotglass
14th January 2006, 18:52
if youre driving around an ideal circle your scalar velocity wont change but the direction of the velocity will change a lot ... if you derive the velocity vectir youll get the cetripetal aceel as the radial component of the derivative in an (r \theta \phi) system
Nitemare
18th January 2006, 22:30
i dont understand.. how can i make a derivation of a vector?
(i suck at maths, sorry)
Peptis
20th December 2007, 23:51
Can someone please provide me with some code to use to calculate pitch and roll from a RAF file?
That is, I'm looking for something similar to this from the RAF file documentation.
To work out heading from the forward-vector
-------------------------------------------
float b = FX / 32767.0f; // convert FX to a float from -1 to 1
float e = FY / 32767.0f; // convert FY to a float from -1 to 1
float heading = atan2(-b, e); // heading (anti-clockwise from above)
I haven't done this type of mathematics for years and it's doing my head in!
Juls
23rd June 2008, 18:23
OMG, this is the Grail...I have been searching so long for this information:
" to work out a car's orientation matrix, the calculation order is : roll,
pitch, heading
to work out the acceleration or velocity in the car's coordinate system, a
programmer should create horizontal (x) forward (y) and up (z) vectors
(using the heading, pitch and roll) and take the dot product (scalar
product) of these with the acceleration or velocity vectors supplied in the
outsim packet."
Maybe it could be somewhere in documentation (maybe it is?), because rotation order has to be known to properly convert world coordinates into car coordinates. I suppose most 3D gurus know about this order...but at least for me it was not so obvious (and angles come in the opposite order in OutSim packets!)
Here is the rotation matrix with this rotation order:
http://planning.cs.uiuc.edu/node102.html
edit: in the formula above you have to switch pitch and roll angles. Apply this matrix with alpha=LFS heading, beta=LFS roll, and gamma=LFS pitch and it seems to work fine.
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.