The online racing simulator
Relation between RAF and Outsim Data
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 ?
b) radians
c) Yes
d) Yes
thx so far

@ b) id like to know the max and min values for those and direction in which they are counted too

*bump*
Negative Pi to positive Pi, what with there being 2*Pi radians in a full circle. IIRC negative is left.
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.
Quote from the_angry_angel :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
Now you've said that, you've got me doubting myself. Bugger. I'll have a check when I get home from work tonight.
Quote from Shotglass :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
Quote from Fonnybone :'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 ?

Quote :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

Quote :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 ?

Quote :Moved thread to Programmer's section

whoops didnt even think about that section when i posted

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 ?
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
Just remember that Current=Forward=Longitudinal and that "Right"=Right=Lateral.

Quote :
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


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
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
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?
Quote from Nitemare :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)
Quote from TagForce :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.
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, 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
Quote from Bob Smith :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).
something quoted from scawen I had lying around:

Quote :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.

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 ?
Quote from Shotglass :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.
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
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
Quote from Bob Smith :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 !
...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...
Quote from Nitemare :
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 :
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
1

FGED GREDG RDFGDR GSFDG