IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules Attention:

This is for the discussion and releasing of tutorials for modifying GTA. Anything that isn't a tutorial will be deleted without notification.

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


  Reply to this topicStart new topicStart Poll

 [IV] Mass, Weight, and Drag

 GTA IV Scripting and Foces
 
K^2  
Posted: Monday, May 21 2012, 00:21
Quote Post


Vidi Vici Veni
Group Icon
Group: Zaibatsu
Joined: Apr 14, 2004

us.gif

Member Award




While developing flight simulation scripts for IV:SA, I came across several odd behaviors of IV physics, at least, as experienced through ScriptHook. Recently, it became necessary to pinpoint the exact physics of weight and drag, and so I had conducted a small study. I am sharing the results of the study here, hoping that it will be helpful for people developing other mods for IV and future GTA titles.


Introduction.

Vehicles, like many other objects, follow Newtonian Physics. The principle equation is the Newton's Second Law, stating that ΣF = ma. That is, sum of all forces acting on the object is proportional to acceleration. It is, therefore, useful to know the exact value of m for a vehicle. Furthermore, in addition to any forces applied due to the engine, which can be disabled, and forces applied by the script, every vehicle is persistently acted on by two forces. These forces are weight and drag. Weight is constant, depending on mass and acceleration due to gravity. Drag varies based on vehicle velocity and drag multiplier. In general, drag can have rather complex dependence on velocity, but in simulations it is often represented with simple linear or quadratic dependence on velocity.

Based on Cerbera's detailed study Handling - Acceleration Experiments and believing that the drag model is going to be essentially the same, I have settled on quadratic drag. With that and above considerations, the goal of the study is to find the coefficients under which the expression guiding motion of the vehicle is given by a simple formula.

ma = F - kvē - mg [1]

Where F is the sum of all external forces applied to the vehicle by the script, k is the drag coefficient, m is mass of the vehicle, v is its velocity, a is the acceleration, and g is acceleration due to gravity.


Methodology.

For the testing, Shamal was used with the following handling data.

CODE
SHAMAL   8000.0 10.0 75 0.0 0.0 -0.5 0.0 1 2.00 4.0 40.0 0.4 0.60 0.7 35.0 0.65 0.60 8.0 0.10 0.5 5.0 1.3 1.3 0.05 -0.14 0.0 0.5 1.2 0.8 0.8 1.5 3.0 45000 06004000 00400000 13


The mass is set to 8 tons, corresponding to fully loaded weight of Learjet 55, and drag multiplier is left at the default value. Engine thrust, at 32kN max total, and wing lift based on aerodynamic computations are added by the script to allow flight. Flight recorder code was added to the script, logging the time, aircraft position and velocity as reported by the script, and sum of all forces applied to the aircraft by the script. The last three are vectors with 3 components each, resulting in 10 entries per simulation tick. Time was logged in milliseconds, and the rest in units natural to the engine, being meters, meters per second, and Newtons respectively.

Collected data was analyzed in several stages. First, 2000 entries corresponding to roughly 70 seconds of flight time were used, discarding the first 30 seconds of simulation that included grounded time. Grounded time was discarded since there is no reasonable way to account for interaction forces between aircraft and runway.

Next, the acceleration data was derived from velocity data. Since acceleration is not tracked by engine internally, it had to be differentiated numerically, resulting in a fair deal of noise. The differentiation method used was 8th order central finite difference equation. Such high order was used to slightly average out effects of the noise, which, unfortunately, was only somewhat successful.

Finally, data was fitted to equation [1] by minimizing absolute χē error to obtain effective mass and drag coefficient.


Data and Results.

First, it is important to note that time difference between script ticks is not consistent. Fortunately, it has no impact on forces, but it has to be taken into account any time a quantity is acquired by differentiation, as was done with acceleration in this study.

user posted image
Time vs number of ticks.

Position and velocity data logged during flight.

user posted image
Position. I was not trying to fly straight.

user posted image
Velocity. It is somewhat noisy, which results in difficulties deriving acceleration.

user posted image
Derived acceleration data. Lots of noise, but still usable.


The first round of fitting data produced g slightly over 10. Given the noise levels above and high average errors, it seems likely that the standard value g=9.8m/sē is being used by the game. Fixing the value at 9.8 and running the fits for m and k only, produced the following results.

CODE
{m -> 15773.7, k -> 15.8415}


With RMSE of roughly 20kN, or about 20% relative error. The RMSE is huge, which suggests that the values above aren't very precisely determined. Because the mass in handling is set to 8,000, and drag multiplier to 10.0, it seems plausible from above data that the values are actually 16,000 and 15.0 respectively, giving multipliers of 2.0 and 1.5 respectively.

There are two tests to this conjecture. First, we can extrapolate drag under assumptions that the above fit for the mass is correct. That is, determine what force is required to produce the observed acceleration once we take into account the weight of the object. The following drag distribution is produced.

user posted image
Extracted drag.

Here, it is plotted against aircraft velocity. In red, D=kvē model is plotted with k=15.

user posted image
Drag vs Velocity

It appears that assumption k=15 is well within error. The final test of the fits is to extract the weight of the aircraft by subtracting modeled drag and forces applied by simulation from the acceleration in z direction. In red is the expected weight under g=9.8m/sē and m=16,000kg.

user posted image
Weight

Again, there is a lot of noise, but assumptions are well within the error.


Conclusions.

Based on Cerbera's earlier studies of effects of mass and drag multiplier on handling of the vehicles, and assuming that the same qualitative behavior holds for IV simulation, it is concluded that the mass of the vehicle, as relevant to the forces applied by the ScriptHook, is twice the mass stated in the handling.dat. While the drag multiplier used by the simulation appears to be 1.5 times the multiplier stated in handling.dat. It is not clear if these discrepancies are entirely due to the engine or are in part caused by artifacts of ScriptHook, but using the above multipliers for flight computations does produce correct results.


Acknowledgments.

Thanks are due to aru for developing GTA IV C++ Script Hook and to Cerbera for previous work on vehicle handling.
PMMSN
  Top
 

 
K^2  
Posted: Thursday, Oct 4 2012, 02:51
Quote Post


Vidi Vici Veni
Group Icon
Group: Zaibatsu
Joined: Apr 14, 2004

us.gif

Member Award




On Importance of Filtering

In my original post, I have mentioned that using differentiation to get acceleration from velocity results in a very noisy acceleration data. That is to be expected. Taking derivative always amplifies any noise present, and velocity data I got from the engine was not very clean.

I have recently came across a very nice method to address that issue using Kalman Filter. I am not going to go through the details. I use a state vector that contains position, velocity, and acceleration, with acceleration being a hidden parameter. A small amount of noise is applied to the acceleration uncertainty updates to account for possible changes in acceleration. This results in very clean acceleration data that is still consistent with measurements.

Here is acceleration data before and after implementing the filter.

DerivativeKalman Filter
user posted imageuser posted image


Because the parameters extracted earlier were done so by fitting, noise played almost no role, so the actual results are still good. However, if instantaneous acceleration data was needed, filtering would make a crucial difference. As it stands, the difference is purely aesthetic.
PMMSN
  Top
 

 
Ferocious Banger  
Posted: Tuesday, Jan 29 2013, 09:26
Quote Post


Group: Epsilonist
Group Icon
Group: Members
Joined: May 17, 2012

ia.gif

XXXXX



I salute you, sir.
PM
  Top
 

 

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)

0 Members:

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG