The online racing simulator
GteK - LFS Accelerometer
(56 posts, started )
Quote from Bob Smith :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

Quote from Fonnybone :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?
Quote from Stuff :VB eh? I'll help with that if you don't have the time


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
Quote from Stuff :VB eh? I'll help with that if you don't have the time

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.
Doesnt work in P7. Detects LFS, but not the car!
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
Attached files
VBInSim.zip - 33.8 KB - 574 views
VBOutSim.zip - 27.9 KB - 603 views
Cool, will take a look.
Yep, thanks RayOK, i'll give it a look too when i have some time to spare
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.

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.
Attached files
VBOutSim_updated.zip - 28.1 KB - 596 views
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 That's where you guys come in to make this OutSim thing into something really cool :grouphug: Can't wait!
Quote from Bob Smith :OK if someone could finish explaining the method as mentioned in this thread: http://forum.rscnet.org/showth ... 0343&highlight=outsim , that would be great so I can go code it up.

So you're saying you managed to connect ?!

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
Quote from Fonnybone :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.
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!
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.
Attached files
VBOutSim_code.zip - 28.4 KB - 774 views
VBOutSim_exe.zip - 29.5 KB - 719 views
Quote from Bob Smith :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.

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
Eureka !

Bob, i love you. Oh and RayOK too of course

So, what's the plan now ? Anyone intend to do an app ?
How about a VB version of Gmeter ? :tired:
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.
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...

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.
Attached files
VBOS_GteK_001.zip - 37.2 KB - 613 views
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 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.
Quote from Stuff :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 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.
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:
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.

PS: Speed and Distance tests arent done yet, but the forms are there...
The graph is in 'Plot data'.
Attached files
VBOS_GteK_002.zip - 46.5 KB - 688 views
Very nice! 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.
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
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.

GteK - LFS Accelerometer
(56 posts, started )
FGED GREDG RDFGDR GSFDG