Forums
how to extract the speed of the car in runtime - Printable Version

+- Forums (http://www.vdrift.net/Forum)
+-- Forum: Community (/forumdisplay.php?fid=3)
+--- Forum: Help (/forumdisplay.php?fid=5)
+--- Thread: how to extract the speed of the car in runtime (/showthread.php?tid=1635)



how to extract the speed of the car in runtime - kraessig - 05-03-2012 10:47 AM

Hi,

I am a technical assistant of the University of Salzburg and my current task is to setup up a car simulation with the special condition that we need the current speed in runtime sent to an external program for evaluation purposes.

Sadly my knowledge of C++ is not really well, so i thought i asking four help could be my best alternative.

What would be my best choice to get to these data?

An co-worker of mine found the following post in the forum but the link seems to be broken. Would this be an option?

http://vdrift.net/Forum/viewtopic.php?t=1625&highlight=speed

Thank you in forward for your input.


- NaN - 05-03-2012 11:25 AM

Hi kraessig.

What is going to be your receiver? The most simple way would be to write the velocity into an output stream I think. Then you would redirect it for further processing.

The only catch is that on windows stdout/stderr are redirected to stdout/stderr.txt by default.

In game.cpp line 898 is the cars update loop. If you are only interested in the values of the first car just do something like(to get velocity magnitude)
std::cout << cars.begin().GetSpeed() << std::endl;

To get the velocity in car space(forward direction is y-axis) you have to add a function to calculate it. Something like: quatRotate(-GetOrientation(), GetVelocity());


Maybe we should add it to the public interface.


- kraessig - 05-03-2012 11:45 AM

The receiver will be an contextual experience sampling server (written in java). This server communicates with xml-stanzas sent over TCP.

So basically i am searching for a way to send the current speed of the car to this server, so we can process the received data for an study.

VDrift itself will most likely run on a Windows machine.


- NaN - 05-03-2012 12:12 PM

Just had a look. You have to recompile SDLmain.lib with NO_STDIO_REDIRECT. Then you can use the line I've posted to output current car speed. Just add the xml bits to it.

Use netcat(I think there is a windows version) to send it over tcp to your server.

VDrift log info(between game runs) is also fed into stdout. Make sure to ignore it.


- kraessig - 05-10-2012 07:23 AM

first of all i want to thank you for your great support in my case Smile

Right now i am struggling to build the project the first time (i didn't alter any code at the moment).

Building the project throws some warnings (39 times) but no errors.

The loading screen starts (but plain black) with all the options, but it wont load a race. It just shows the loading bar and exits back to the practice race start screen.

stderr.txt:

ERROR: You don't have an NVIDIA or ATI/AMD card. This game may not run correctly or at all.
ERROR: Couldn't load spinning car: 350Z
ERROR: Loading log: 350Z.car.camera.0, 0.55, 1.type not found.

ERROR: 350Z.car.camera.0, 0.55, 1.type not found.
ERROR: Error loading car: 350Z
ERROR: Unable to load car 350Z

I have switched the shaders on off because my Graphics Cards is Intel Onboard. My normal installation of the games runs this way.

Thanks for your input in advance.


- NaN - 05-10-2012 07:40 AM

When compiling from source make sure to pull the latest vdrift data.

And maybe also delete the settings folder .vdrift or C:\Users\{user}\Documents\VDrift after update.


- kraessig - 05-10-2012 08:15 AM

thanks for the advice ... it seems as if i accidentally downloaded the wrong data sets. Now it works Wink Finally i can start working on the problem itself Big Grin


- NaN - 05-10-2012 09:02 AM

The stdout stuff seems to be a bit more involved as you have to create a console.

I think it might be simpler to use an existing socket wrapper/implementation like this one(just follow the client example): http://www.adp-gmbh.ch/win/misc/sockets.html#header


- kraessig - 05-10-2012 10:56 AM

thx for the advice. actually i am searching right now for a good socket example Wink. Gonna look at it.


- kraessig - 05-10-2012 11:47 AM

so, once again thanks for your support NaN.

It's working totally fine. My quick-and-dirty-built-java-server receives everything Wink.


- NaN - 05-10-2012 12:06 PM

You're welcome. Nice to see it being of use.


RE: - cac1234 - 02-22-2017 09:34 AM

This was so helpful- thank you!