Menu

#2420 Error in AI velocity computation for audio

2020.4
New
nobody
None
Low
2021-02-10
2020-11-15
No

The computation of velocity in src/AIModel/AIBase.cxx (lines 336-339) is most likely wrong since the components do not use the same units:

        SGVec3d velocity;
        velocity = SGVec3d( speed_north_deg_sec, speed_east_deg_sec,
                            pitch*speed );
        _fx->set_velocity( velocity );

The first 2 components in the SGVec3d constructor are expressed in deg/s while the last one is given in kts*deg.

In addition the members speed_north_deg_sec and speed_east_deg_sec are seldomly updated (the only 2 classes that update them are AIBallistic and AIShip.

Discussion

  • Bertrand Coconnier

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -7,4 +7,4 @@
     ```
     The first 2 components in the `SGVec3d` constructor are expressed in deg/s while the last one is given in kts*deg.
    
    -In addition the members `speed_north_deg_sec` and `speed_east_deg_sec` are seldomly updated (the only 2 classes that update them are `AIBallistic` and `AIShip.
    +In addition the members `speed_north_deg_sec` and `speed_east_deg_sec` are seldomly updated (the only 2 classes that update them are `AIBallistic` and `AIShip`.
    
     
  • James Turner

    James Turner - 2021-02-10

    @colingeniet As one fo the few people that I definitiely know is using AIBallistic: can you confirm for the cases you know of, this would either improve them, or make no difference?

     
  • Colin Geniet

    Colin Geniet - 2021-02-10

    This piece of code only sets the velocity vector for the sound effect, so it should not change anything for the AI models themselves. The 'deg_sec' units seem very suspicious to me.

    From this line (simgear/sound/sample_group.cxx, line 292), I guess the velocity vector is supposed to be in ft/s.

           velocity = toVec3f( hlOr.backTransform(_velocity*SG_FEET_TO_METER) );
    

    So using _get_speed_{east,north}_fps() and _getVS_fps() would already be better. However the first two use speed_{east,north}_deg_sec internally, so it won't help if this is not updated.

     
  • James Turner

    James Turner - 2021-02-10

    What a mess :) I;d orefer FGFSX::set_velocity used metric already, but deg/sec is particularly weird. Ho hum.

     
  • Colin Geniet

    Colin Geniet - 2021-02-10

    Oh, and _getVS_fps is even worse, because it is based on the attribute vs, which AIBase and I think AIAircraft consider as ft/min, while the rest consider it as ft/sec (or don't update it at all).

     
  • James Turner

    James Turner - 2021-02-10

    Oh dear, so many bugs lurking in this code.

     

Log in to post a comment.

MongoDB Logo MongoDB