Full Version: how to extract the speed of the car in runtime
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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?

Thank you in forward for your input.
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.
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.
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.
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.


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:, 0.55, 1.type not found.

ERROR:, 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.
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.
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
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):
thx for the advice. actually i am searching right now for a good socket example Wink. Gonna look at it.
so, once again thanks for your support NaN.

It's working totally fine. My quick-and-dirty-built-java-server receives everything Wink.
You're welcome. Nice to see it being of use.
This was so helpful- thank you!