Andy,
The original code assumed that "dt" was in milliseconds.  The variable name 
"velocity_rpms" presumably stood for "revs per millisecond".
Your patch assumes that "dt" is in 1/120ths of a second.  Is this linked to your frame 
rate?
The meaning of "dt" needs to be consistent across the various instances of 
FGSubsystem, and I don't think it is: see my post "Propellor speed error due to 
FGSubsystem::update(multi_loop)", reproduced below.

- Julian


Andy Ross wrote:
> 
> Here's a patch to model.cxx that restores the proper rotation speed of
> the propeller spin.
> 
> It just replaces the single 1/60000 constant with one that is
> (hopefully) more clearly derivable from basic principles.  The
> original number was off by a factor of 3/25; maybe something got
> double-factored?  One thing I didn't do is grab the 120 Hz update rate
> from a real source; it's hardcoded instead.  I forget where it comes
> from.
> 
> Andy
> 
> diff -u -r1.10 model.cxx
> --- model.cxx   20 Apr 2002 15:07:47 -0000      1.10
> +++ model.cxx   30 Apr 2002 23:17:55 -0000
> @@ -527,8 +527,9 @@
>  void
>  FG3DModel::SpinAnimation::update (int dt)
>  {
> -  float velocity_rpms = (_prop->getDoubleValue() * _factor / 60000.0);
> -  _position_deg += (dt * velocity_rpms * 360);
> +  float velocity_rpms = _prop->getDoubleValue() * _factor;
> +  // 120Hz update, 60 sec/min, 360 degrees/revolution
> +  _position_deg += (dt * (1/120.0) * (1/60.0) * velocity_rpms * 360);
>    while (_position_deg < 0)
>      _position_deg += 360.0;
>    while (_position_deg >= 360.0)
> 
> --


On 21 April Julian Foad wrote:
> 
> The error in the speed of the propellor, and other things that we might not have 
>noticed yet, is caused by the handling of the variable "multi_loop" in 
>main.cxx:fgUpdateTimeDepCalcs().  After being used to update the FDM, this 
>"multi_loop" value (or the value 1 in freeze mode) is passed to the various subsystem 
>"update" methods:
> 
>     globals->get_model_mgr()->update(multi_loop);
>     globals->get_aircraft_model()->update(multi_loop);
>     globals->get_viewmgr()->update(multi_loop);
>     current_radiostack->update(multi_loop);
> 
> The model manager, at least, is expecting to receive the number of milliseconds that 
>have elapsed since the last call.  The "multi_loop" number does not seem to be that.  
>Nor does the definition of FGSubsystem::update help:
>   /**
>    * Update the subsystem.
>    *
>    * <p>FlightGear invokes this method every time the subsystem should
>    * update its state.  If the subsystem requires delta time information,
>    * it should track it itself.</p>
>    */
>   virtual void update (int dt) = 0;
> 
> That looks wrong to me.  Surely "it should track it itself" applied before the "dt" 
>parameter existed, and now the "dt" parameter is intended to provide the time 
>difference and should be defined here.
> 
> Anyone prepared to sort this out?  If "dt" is to represent milliseconds, it would be 
>a good idea to rename it "dt_ms" (in the derived classes too).  I haven't checked how 
>other classes interpret it.
> 
> - Julian

_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to