Forums

Full Version: Realistic driving experience
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm interested in using VDrift as a driving simulation. I'm aiming at simulating a usual street car on everyday roads.

It is probably is not too difficult to create a racetrack that is similar to a normal road in width and curvature. Do you think it is also possible to incorporate junctions easily or does this require changes to the track format?

The other aspect I would like to ask you about is the behavior of the physics simulation at low speeds. Since VDrift is obviously geared towards racing, I'm wondering how realistic the handling of the cars is at comparatively lower speeds. I'd probably want to start tweaking one of the existing cars to make it much less powerful.

As I understand VDrift uses a variant of the Pacejka magic formula for tire modeling. I have read that the results provided by Pacejka are not very satisfactory at lower speeds.
Maybe someone here can enlighten me if this also affects VDrift, or if there are some counter-measures implemented to correct the forces on tires at low speeds. One thing I noticed is that even when doing nothing, the car (previously standing still) always started to slowly move forward. It only actually stands still when applying the brakes.

Besides trying VDrift I also had a look at TORCS (and its fork SpeedDreams). Personally I do not feel much difference between these two simulations when racing. I learned that while TORCS uses a self-implemented 2.5D-Physics engine (simuV2), VDrift relies on the Bullet library for its physics simulation. However I'm not sure if this also includes the suspension system or if this is again a separate implementation.
I would be especially glad if someone could provide some more information on where the differecences between VDrift and TORCS lie and what kind of philosophy they are following.

Thanks a lot for reading Smile
The AI, racing logic expect closed loop tracks. But you can run the game without any roads at all, drive directly on the track mesh.

Bullet is used for collision detection and rigid body dynamics. Powertrain, suspension and tires are handled by custom code.

There is no special code to handle Pacejka related issues in the simulation. The forward rolling is one of the symptoms. It might be possible to hack around.

At some point I rewrote the simulation (sim branch) to deal with the limitations of current code. Unfortunately it turned out to be computationally too expensive to simlate multiple cars.

I still hope to get back to it, slowly working towards separating simulation from the rest of the game, to be able to go multithreaded eventually.

Recently other things had higher priority though.
Thank you for your pointers.

When driving on a normal closed circuit, is the ground contact always calculated using the mesh of the terrain directly? Or is this only used as fallback when leaving the race track?

I did a checkout of your sim branch. Unfortunately I wasn't able to compile it, receiving the following error:

Code:
src/game.cpp: In constructor ‘GAME::GAME(std::ostream&, std::ostream&)’:
src/game.cpp:126:70: error: invalid conversion from ‘bool (*)(btManifoldPoint&, const btCollisionObject*, int, int, const btCollisionObject*, int, int)’ to ‘ContactAddedCallback {aka bool (*)(btManifoldPoint&, const btCollisionObjectWrapper*, int, int, const btCollisionObjectWrapper*, int, int)}’ [-fpermissive]
  dynamics.setContactAddedCallback(&sim::Vehicle::WheelContactCallback);
                                                                      ^
In file included from src/game.h:36:0,
                 from src/game.cpp:20:
src/physics/world.h:65:7: note: initializing argument 1 of ‘void sim::World::setContactAddedCallback(ContactAddedCallback)’
  void setContactAddedCallback(ContactAddedCallback cb);
       ^
In file included from /usr/include/bullet/LinearMath/btVector3.h:21:0,
                 from /usr/include/bullet/LinearMath/btMatrix3x3.h:19,
                 from /usr/include/bullet/LinearMath/btTransform.h:21,
                 from /usr/include/bullet/LinearMath/btMotionState.h:19,
                 from src/physics/motionstate.h:23,
                 from src/track.h:27,
                 from src/game.h:29,
                 from src/game.cpp:20:
/usr/include/bullet/LinearMath/btScalar.h: At global scope:
/usr/include/bullet/LinearMath/btScalar.h:337:14: warning: ‘btInfinityMask’ defined but not used [-Wunused-variable]
  static  int btInfinityMask = 0x7F800000;
              ^
scons: *** [build/game.o] Error 1
scons: building terminated because of errors.

Compiling the latest version from the master branch was successful. One thing I noticed however is that the cars react very nervous (I'm using mouse steering). It is almost impossible to drive in a straight line, even at low speeds.
Another thing which I could observe was a very weird collision behaviour with corner curbs. Sometimes after hitting a corner curb the car was flung over almost the entire map.
(12-13-2014, 11:31 AM)mikado Wrote: [ -> ]Thank you for your pointers.

When driving on a normal closed circuit, is the ground contact always calculated using the mesh of the terrain directly? Or is this only used as fallback when leaving the race track?

I did a checkout of your sim branch. Unfortunately I wasn't able to compile it, receiving the following error:

Code:
src/game.cpp: In constructor ‘GAME::GAME(std::ostream&, std::ostream&)’:
src/game.cpp:126:70: error: invalid conversion from ‘bool (*)(btManifoldPoint&, const btCollisionObject*, int, int, const btCollisionObject*, int, int)’ to ‘ContactAddedCallback {aka bool (*)(btManifoldPoint&, const btCollisionObjectWrapper*, int, int, const btCollisionObjectWrapper*, int, int)}’ [-fpermissive]
  dynamics.setContactAddedCallback(&sim::Vehicle::WheelContactCallback);
                                                                      ^
In file included from src/game.h:36:0,
                 from src/game.cpp:20:
src/physics/world.h:65:7: note: initializing argument 1 of ‘void sim::World::setContactAddedCallback(ContactAddedCallback)’
  void setContactAddedCallback(ContactAddedCallback cb);
       ^
In file included from /usr/include/bullet/LinearMath/btVector3.h:21:0,
                 from /usr/include/bullet/LinearMath/btMatrix3x3.h:19,
                 from /usr/include/bullet/LinearMath/btTransform.h:21,
                 from /usr/include/bullet/LinearMath/btMotionState.h:19,
                 from src/physics/motionstate.h:23,
                 from src/track.h:27,
                 from src/game.h:29,
                 from src/game.cpp:20:
/usr/include/bullet/LinearMath/btScalar.h: At global scope:
/usr/include/bullet/LinearMath/btScalar.h:337:14: warning: ‘btInfinityMask’ defined but not used [-Wunused-variable]
  static  int btInfinityMask = 0x7F800000;
              ^
scons: *** [build/game.o] Error 1
scons: building terminated because of errors.

Compiling the latest version from the master branch was successful. One thing I noticed however is that the cars react very nervous (I'm using mouse steering). It is almost impossible to drive in a straight line, even at low speeds.
Another thing which I could observe was a very weird collision behaviour with corner curbs. Sometimes after hitting a corner curb the car was flung over almost the entire map.

Yeah, the sim branch might need some work. It also depends on sim data, won't run with current data master. Would be cool to get it functional again.

Against which bullet version are you linking? The recent ones 2.82? can cause some serious issues, due to bullet internal changes. There is a bug on the issue tracker, needs to be investigated more thoroughly.

The road patches ray test overrides the track mesh test. This can cause issues, but works quite well most of the time.