View Full Version : GteK - LFS Accelerometer
Fonnybone
13th November 2005, 03:56
I've wanted to make a simple app like this for a long time and
a recent thread has given me the push to give it another try
(the Gmeter version didnt give the results expected, mostly
due to refresh rate/latency).
Here is my first version, GteK P001. P is for LFS 0.5P which is
the version it is based on. I don'T garantee it'll work on the
test patches, but tell me if you try and it does/doesn't.
To use:
1- Make sure both 'lights' are green (LFScheck, CARcheck)
2- Click connect to update velocity in real-time (10ms updaterate)
3- Select the Acceleration test (Distance test is still being worked on)
4- Select the start and end speed for your test
5- Click Ready and read message, click OK.
Once test is finished:
1- Click OK on the popup, it hides behind the LFS window (ill fix it..)
2- Results appear in the LOG (you can only read the results for now)
UPDATE: GteK P02
- Added a Refresh Rate button
- Changed the message popup to work in LFS
(LFS displays error in chat when i make it the top window for some reason)
Citywidemicke
13th November 2005, 10:25
@Fonnybone
Nice and thanks :thumb:
the_angry_angel
13th November 2005, 11:23
Looks good fonnybone! :up: Nice work, once again :)
_rod_
13th November 2005, 12:07
Thanks fonnybone, nice work!!!
seggons
13th November 2005, 12:18
Cheers Mr Bone
hrtburnout
13th November 2005, 16:48
In P9 it detects LFS but it's doesn't detects the car :(
AndroidXP
13th November 2005, 17:30
Heh, looks nice
Octavia
13th November 2005, 18:33
In P9 it detects LFS but it's doesn't detects the car :(
I have the same roblem, but I have P7 :pillepall
[RCG]Boosted
13th November 2005, 18:37
lucky me, i got lfs P2 and P9 (one for normal racing , one for slickmod and other stuff :D )
EDIT actually i found out that i doesnt work with P2....
Fonnybone
13th November 2005, 20:14
Oh well, it was to be expected. Hopefully not all test patches are different
so maybe i could make a version for those, just not for now.
Thanks for the reports though guys ;)
sil3ntwar
13th November 2005, 20:38
hmm
0-100 in:
XFGTI: 4.9
FXO GTR: 1.8
UF1000: 7.0
Either your program is wrong or these cars are too quick off the line.
FPVaaron did those cars in:
XFGTI: 8.23
FXO GTR: 2.87
UF1000: 10.74
Fonnybone
13th November 2005, 20:43
I didn't go through all the cars yet, but it has no reason to be wrong
basically. GteK reads velocity directly from LFS (the SAME data you see
on your speedo) and then i have a counter running in the back. If you
followed the steps correctly, it should be fine.
One way to check is to record a replay and start a race, both LFS and
GteK counters will start together (if you start at the green light of
course..) and checking the replay you can look at the LFS time once
you reach 100kmh. A good place to test is the drag track of course ;)
Do a few races and look at the replays to check the time @ 100kmh (time@100kmh).
sil3ntwar
13th November 2005, 20:45
sorry mate your program is totally wrong when i run it. I did a drag run and i heard the ding at 11 seconds yet your program showed 6.
XCNuse
13th November 2005, 20:51
er silent how about you give some more info than saying
"it doesnt work" ...
sil3ntwar
13th November 2005, 20:51
It appears your timer doesnt run properly when it is receiving the data from LFS. It works fine if i focus on your program but as soon as i go back to LFS it slows right down.
Ok i capped the FPS to 60 (was around 90 on the drag strip) and the timer run much better but was still off the in game timer. It could just be my cpu cant keep up or something? Its an Athlon 2500+
XCNuse:
Im still testing it to figure out exactly what isnt working.
Fonnybone
13th November 2005, 20:56
Actually, people before you seem to say it's fine, so i don't think my
"program is totally wrong". In fact i'm making tests right now and it
looks fine. The only thing i found is that it seems to stop at 96-97kmh for
some reason. I use m/s, like LFS, then convert to kmh or mph. so that
might be a small detail to fix, but the times are still realistic.
There COULD be something else making your results turn out so wrong.
After a few 0-100kmh tests and i get:
XF GTi
8.010
8.000
8.000
FXO GTR
3.290
2.960
3.340
UF1000
10.410
10.100
9.800
Seems fine to me. Maybe your PC is making the VB timers
over-active...what did you do to your PC ?! lol
Edit: Yeah, it could very well be the timer that's a problem on your PC. Short
of using the LFS time, which isn't as easy to do as it is to say, i'm not sure
how to fix this. What i COULD do is use your PC's time though ;) I'll see what i can do.
That might mean that LFS is running slow/fast on some PCs though, mmmm
the_angry_angel
13th November 2005, 21:28
Perhaps the CPU usage is too high, to allow for the timer to function correctly. Timestamping the InSim data from start to finish is a good idea :)
Perhaps you could release a test version with both methods. I've not had any issues on my backup LFS version (P9 of LFS refuses to work though).
Fonnybone
13th November 2005, 21:38
Perhaps the CPU usage is too high, to allow for the timer to function correctly. Timestamping the InSim data from start to finish is a good idea :)
Perhaps you could release a test version with both methods. I've not had any issues on my backup LFS version (P9 of LFS refuses to work though).
Hehe, interesting, this is where my l4m3r background rears it's ugly head...
The more experienced programmers out there might see what i did here.
Like mentionned in my first post, i'm trying to bypass all this InSim/OutSim
stuff since i couldn't get an acceptable refresh rate to have any useable data.
That was an issue with Gmeter, which is written in Delphi btw. I never managed
to make an InSim-OutSim app work myself in VB, else i'd be working on making
that more accurate first.
GteK just reads the velocity directly from LFS at a VERY FAST rate.
First thing i could try is to make that refresh rate user-adjustable, but
then again, this is where Gmeter started getting erratic in the results,
basically, there would be no way to get accurate results as all become
an approximation of an approximation and so on...it's still a very usefull
feature though so i'll just add it to test at least.
Reading about how changing the FPS cap affects GteK's timer, i think this is
really what's happening here. Perhaps being able to set it to match the FPS
is a better solution in getting accurate results that match those from LFS.
Whatever way i look at it, it HAS to be a timer issue.
So the basic problem here is that to be able to get the EXACT time at which
100kmh (example) is reached. There is no other need for a fast update rate really.
Short of this code being part of LFS, there is no easy way to get accurate time imo.
I just thought of something, you guys are using LFS in a window, right ?
sil3ntwar
13th November 2005, 21:51
FPS does affect the timer but only slightly. At 60fps i get around 6 seconds while at 10fps i get almost 8. Also at 60fps LFS is using 50% of the cpu.
sil3ntwar
13th November 2005, 22:05
Yes LFS was windowed but im sure i did it once in fullscreen as i thought that may have been the problem but it didnt change anything.
Just tried again and there is no difference.
Bob Smith
13th November 2005, 22:37
I never managed to make an InSim-OutSim app work myself in VB, else i'd be working on making that more accurate first.
Hmm, somebody else has asked me to make an app in VB to read OutSim values, I'll give it a go and see how far I can get.
Fonnybone
13th November 2005, 23:03
Ok, i posted an updated version for testing.
Bob, thanks for trying :) I have a few links somewhere to do
it but if i remember VB doesn't work with UDP without some
extra code to get working. Peeps1980, the one who programmed
Gmeter tried but reverted to Delphi as he was more familiar with it
and it was much simpler to get it working.
sil3ntwar
14th November 2005, 01:49
im getting the same results in both of your programs as well as gmeter which still works with s2. So it must be a problem my end if everyone has it working fine.
the_angry_angel
14th November 2005, 12:53
Like mentionned in my first post, i'm trying to bypass all this InSim/OutSim
stuff since i couldn't get an acceptable refresh rate to have any useable data.:doh: Missed that completely :(
[RCG]Boosted
14th November 2005, 20:46
still wont work, not with P9 and not with P2.
Stuff
14th November 2005, 21:36
Hmm, somebody else has asked me to make an app in VB to read OutSim values, I'll give it a go and see how far I can get.
VB eh? I'll help with that if you don't have the time :thumb:
I have a few links somewhere to do it but if i remember VB doesn't work with UDP without some extra code to get working.
I'm not sure about the Winsock control in VB6 for UDP packets but it should work? I use Winsock2 API. I even made a simple user-control encapsulate it. Self-subclassing, asynchronous (non-blocking), TCP and UDP. Anyone interested? :)
Fonnybone
14th November 2005, 22:57
VB eh? I'll help with that if you don't have the time :thumb:
I'm not sure about the Winsock control in VB6 for UDP packets but it should work? I use Winsock2 API. I even made a simple user-control encapsulate it. Self-subclassing, asynchronous (non-blocking), TCP and UDP. Anyone interested? :)
Winsock2 you say ? Mmm, anyway to get my hands on that ?
I just went on RSC to take a look at the thread with the info in question
and behold, RayOK, you are the one who initially told me this ;)
http://forum.rscnet.org/showthread.php?t=210146
Bob Smith
14th November 2005, 23:03
VB eh? I'll help with that if you don't have the time :thumb:
I suspect you're far more experienced with VB than I am (not that I'm not keen), but I've not covered programming with sockets yet at Uni so I suspect any progress I make would be slow.
wheel4hummer
14th November 2005, 23:06
Doesnt work in P7. Detects LFS, but not the car!
Stuff
15th November 2005, 04:42
OK, I was sorta "bored" so I went all out and made a simple chat program! Take a look. Use whatever you want. Ask if needed. Don't worry, be happy :)
Edit: Worked a little bit with my socket control and made a VB6 OutSim project! It just outputs the values to the form. I'm not sure if they are correct as my understanding of C++ to VB6 conversion is "rusty". Anyway, check it out too and as always, you can use the code any way you want. A little mention would be cool tho ;)
Bob Smith
15th November 2005, 11:13
Cool, will take a look.
Fonnybone
15th November 2005, 18:50
Yep, thanks RayOK, i'll give it a look too when i have some time to spare ;)
Bob Smith
16th November 2005, 00:07
That's great RayOK, given me a good start. The numbers seem perfect! So no problems there.
Anyway I tidied the interface a bit and added car speed in sensible units, see attachment. :p
However I noticed g forces are given relative to the track, not the car, so I assume it is possible to get proper longitudinal/lateral g forces by using the orientation information some how?
It's really these numbers I'm after so if someone could point out the trick, that would be great. :D
Stuff
16th November 2005, 00:43
w00t! Much better. It now makes sense, mostly. Its cool my quick set of numbers worked out. I put it together somewhat fast and didn't pay much attention to accuracy. I now see that the 3 position ints probably should be declared as longs (each 4-byte signed) instead of 4 separate bytes then multiplying for an "unsigned" result.
The speed is the cool part to me. Heck, I don't know much about physics functions so they are foreign to me :shrug:That's where you guys come in to make this OutSim thing into something really cool :grouphug: Can't wait!
Bob Smith
16th November 2005, 20:16
OK if someone could finish explaining the method as mentioned in this thread: http://forum.rscnet.org/showthread.php?t=140343&highlight=outsim , that would be great so I can go code it up. :)
Fonnybone
20th November 2005, 12:40
OK if someone could finish explaining the method as mentioned in this thread: http://forum.rscnet.org/showthread.php?t=140343&highlight=outsim , that would be great so I can go code it up. :)
So you're saying you managed to connect ?! :scratchch
As for that link you posted, it sure sparked some memories, me and peeps1980 went through all
this to create Gmeter. I have all the data somewhere. Most of it comes directly from a thread on
RSC where Scawen himself explains to me how to do it, took me a while to understand, but i
eventually got it ;)
That thing about angles has to do with matching car and track orientation if i recall.
LFS uses radian for angles btw, not degrees . The range of the car's orientation (heading in
OutSim i think) is from -3.1416 to 3.1416, trigonometry anyone? :) Once again, i have all this
info somewhere, i'll PM to you what i have as soon as i find it, like today, hopefully :P
Bob Smith
20th November 2005, 19:46
I have all the data somewhere. Most of it comes directly from a thread on
RSC where Scawen himself explains to me how to do it, took me a while to understand, but i
eventually got it ;)
...
Once again, i have all this
info somewhere, i'll PM to you what i have as soon as i find it, like today, hopefully :P
Yeah I know there are 2xPi radians in a circle ;)
OK thanks, that would be excellent. :)
Fonnybone
21st November 2005, 21:30
The thread i was talking about is not accesible, but i have it in TXT format so i'll send it along with the info. It's mostly maths, but directly from Scawen himself.
As for the rest of the info, i just found it ! I'm PMing as i write this, well, right after.
Edit: Ok, so i can't send files in PM. D'oh!
Bob Smith
23rd November 2005, 00:55
OMG that's so confusing. However the very first equation that Scawen says works perfectly for me, so I can ignore all the gibberish and it's done, hurrah!
See attached. :smileypul
Fonnybone
23rd November 2005, 04:42
OMG that's so confusing. However the very first equation that Scawen says works perfectly for me, so I can ignore all the gibberish and it's done, hurrah!
See attached. :smileypul
Yes, that's what i mean by 'i didn't get it at first, but eventually i do'.
Yes, the first equation is good, they are all the same, just written in different ways, that's how i got it ;)
I'll take a look at what you did and give you some feedback ;)
Fonnybone
23rd November 2005, 13:37
Eureka !
Bob, i love you. Oh and RayOK too of course :D
So, what's the plan now ? Anyone intend to do an app ?
How about a VB version of Gmeter ? :tired:
Bob Smith
23rd November 2005, 14:02
Heh, I could rattle up acceleration and distance timing in a day I reckon. However my purposes were getting the information for feeding into a motion simulator. I can't be starting new projects until I've finished off my current ones (GRC).
I still don't think that the distance handling is quite correct though, as when you go below 0 it jumps back round to 65,536. Surely it should just go negative if it's giving you your position relative to some place on the track? Hence I used "?" instead of "m" for now.
Fonnybone
1st December 2005, 04:26
Here's a my part so far. You guys wanna check if it works for you too ?
Works on 0.5Q also. This is one thing i looove about In/OutSim. It's not
patch dependant much. My main concern is about the config, if you look
around a bit in my version, you'll find a config window where i tried 2 ways
of getting the info, one searches the folder it's in for the LFS config.txt
file and the other uses RAM (beware, it's for 0.5P, it wont work for 0.5Q).
Both ways worked for me, but having OutSim activated in the config.txt
is essential for LFS to even send OutSim info, therefore i think it would be
best to keep the "search cfg" code and request that this app be kept in
the LFS folder. That way it can check if OutSim IS activated and warn the
user in the event it's not. Also, i didn't find the delay in the RAM and don't
really want to be messing there anyways since it would be dependant
on the patch version.
I had (still have) fun trying to understand wtf happenned to the values,
but for now, only position is still giving me problems. I'll start on the
plotting/graph tabs and make it draw it's position at regular intervals.
If it ends up drawing the track layout, then we should be all set ;)
I'm not posting the VBcode 'cause i added lots of my own modules in it
and don't really want that part to be public...:schwitz:
This should be the base of GteK i suppose, it's a VB version of Gmeter
basically. I always liked the concept of Gmeter (it was my idea after all)
and i'd like to make a VB version. I just need to learn how to make plugins
now so people can make their own plugins if they want.
Oh, btw, be sure to click the Telemetry button to see the values. Other
buttons don't do anything yet.
Stuff
1st December 2005, 05:26
In the example I posted I declared the 3 position ints as an array of 4 bytes. Then in the handler, multiplied them to get an unsigned result (0 to 4,278,190,080 I think). They actually should be declared As Long (signed) so the result can be negative (-2,147,483,648 to 2,147,483,647). My mistake on that part. Readme.txt says 3 ints, and an int in C++ is 4-byte signed (according to InSim.txt) ;)
This may be why you're getting problems with the position. Again, my mistake but don't say I didn't warn ya, as I did in my last post :razz: You would probably still get the shape of the track, it would just be shifted in some way. Better to make them Longs for accuracy and a tiny bit of speed since it doesn't have to convert and multiply. :)
Fonnybone
1st December 2005, 16:03
In the example I posted I declared the 3 position ints as an array of 4 bytes. Then in the handler, multiplied them to get an unsigned result (0 to 4,278,190,080 I think). They actually should be declared As Long (signed) so the result can be negative (-2,147,483,648 to 2,147,483,647). My mistake on that part. Readme.txt says 3 ints, and an int in C++ is 4-byte signed (according to InSim.txt) ;)
This may be why you're getting problems with the position. Again, my mistake but don't say I didn't warn ya, as I did in my last post :razz: You would probably still get the shape of the track, it would just be shifted in some way. Better to make them Longs for accuracy and a tiny bit of speed since it doesn't have to convert and multiply. :)
Hehe, yeah, that's the first thing i did actually. I changed most integers
to long (in VB...), so values should be good. I just need to verify them
and figured that plotting a graph of position @ a constant interval should
be a quick and easy way to double check ;) I DID read your post, but
since BobSmith had a go at the code in between, i didn't know who did
what exactly.
Another detail is that i'll have to move the 'ReceivedBytes' code to a
module so it can be accessed by any form. I'd rather have new forms
pop-up for the graphs (and future plug-ins/add-ons) then having them
all within the same form and having to do this lame resizing of the
form i do for now.
Stuff
1st December 2005, 17:40
Ahh good. Just making sure to avoid any silly problems later. :)
For moving the ReceivedBytes over to a module, I have a somewhat simple solution: use a class module and WithEvents to respond to the events. Goes like this..
1- If your handling code is not already in a class module, stick it in there. Normal, .bas modules won't work with WithEvents.
2- Instatiate the new class on startup.. Private myObject As Class1
Private Sub Form_Load()
Set myObject = New Class1
End Sub
3- in the class module, use WithEvents.. Private WithEvents theSocket As okSocket
'after typing this, theSocket and its events will be selectable from the dropdowns
Private Sub Class_Initialize()
Set theSocket = frmMain.OutSimSocket
End Sub
Private Sub theSocket_ReceivedBytes(lngSocket As Long, bytData As Variant, lngLength As Long)
Debug.Print "we have bytes!"
End Sub
Of course, keep the little socket control on the form. Should work for ya. If not, I will post an example too. Let me know. ;) :up:
Fonnybone
2nd December 2005, 20:49
Thanks RayOk, but it's ok, i already had it covered 5 minutes after my post.
The graphs show a perfect image of the track :) :) :) It's purrrrrrfect ;)
As for the 'OnEvent', what i did was declare the outsim type in a module
so when that copymemory code does it's job, it copies to a 'registry'
available to any form. I've already did it and it works fine :)
Here's another sample with the graph in it, again, thanks a whole lot for the help guys. :smileypul
PS: Speed and Distance tests arent done yet, but the forms are there...
The graph is in 'Plot data'.
Stuff
3rd December 2005, 00:44
Very nice! :thumb: The track plots nicely and the telemetry stuff looks good.
However, two things that I would change. You might already have plans for this but just in case. ;)
Doesn't show on my taskbar. Have to minimize stuff or move LFS to find it. Other is you can't move the popup forms. They hold the most info and once they popup under the main form, they don't popup anywhere else.
trackah123
16th December 2005, 02:14
hey guys..
does this program work with tuning dragsets.. giving out precise acceleration values and stuff.. cuz it seems a nice program but i dont even know what insim or outsim means.. and the port. how can i connect to lfs and make it work.. i have 0.5Q.. keep up the good work. im just another n00b that isnt technical at all :)
greetings : XsR^ÐRäGK!NG :thumb:
Fonnybone
17th December 2005, 05:00
trackah123, you are catching us while 'making' this app actually.
The last post is a work in progress. I am now finishing up the
distance tests and i've worked on various timing issues.
There should be a usefull version available soon. I'd like to
make a few tests and add 'data output to file' so the data
can be used afterwards (excel or something). I've also
made the port setup easier by looking for the LFS config file
and reading it directly.
trackah123
17th December 2005, 07:30
sounds great :) im looking forward to it..
for now i use that value in lfs game itself at the bottom when you press F9 you see 2 forces.. left right and up down..
Fonnybone
17th December 2005, 19:09
sounds great :) im looking forward to it..
for now i use that value in lfs game itself at the bottom when you press F9 you see 2 forces.. left right and up down..
Hehe, ya. Those are the 'g-force' meters. Gmeter (the original GteK made
by peeps1980 and myself) was the one to start this. Wether Scawen
originally wanted to include this or not in LFS i don't know, but it's there
now ;) I might still add the g-meter part in GteK, but since LFS now
displays this, i'm concentrating on performance tests and telemetry
data ;)
trackah123
17th December 2005, 21:34
would be great to see some output of gforces.. like for now i get around 0.81 - 0.83 with XRT on blackwood with 60 degrees tyre temps during launch.. but it goes so quick with the numbers .. performance test would be nice :nod:
(TR) Infinity
29th November 2006, 11:58
Have you taht programm in new version for U ???
Fonnybone
29th November 2006, 22:54
Do you have that program in new version for U ???
It's not dependant on the version really. The last posted version should still work. I haven't touched this app in a long time, still like the idea though.
(TR) Infinity
30th November 2006, 17:13
I press connect but the programm dont connects!
In Multiplayer modus i have selected 93392 must i put that into the programm to ?? When i do that the programm still dont conenct too.
Whats the problem plz ?
Hello, I am working on a motion simulator and would like to have it running with LFS.
I can see here accelerations LFS sends are expressed in world coordinates, not in car coordinates, and have to be processed.
I saw somewhere the formula to do it in a post from Scawen, maybe one year ago, but I do not manage to find it anymore. (when I saw it I was thinking "nice, it is there...I will find it easily when I need it...")
Maybe someone who have it could post it again? Thank you.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.