Records UFO moving with constant velocity with varying framerates, then replays with varying framerates and checks that replayed UFO moves with expected constant speed. If is true we also record MP UFO running in second Flightgear instance and check that it too mo
(fgfs, multiplayer=False)
| 406 | |
| 407 | |
| 408 | def test_motion(fgfs, multiplayer=False): |
| 409 | ''' |
| 410 | Records UFO moving with constant velocity with varying framerates, then |
| 411 | replays with varying framerates and checks that replayed UFO moves with |
| 412 | expected constant speed. |
| 413 | |
| 414 | If <multiplayer> is true we also record MP UFO running in second Flightgear |
| 415 | instance and check that it too moves at constant speed when replaying. |
| 416 | ''' |
| 417 | log('') |
| 418 | log('='*80) |
| 419 | log('== Record') |
| 420 | |
| 421 | aircraft = 'ufo' |
| 422 | fgfs += ' --prop:bool:/sim/time/simple-time/enabled=true' |
| 423 | if multiplayer: |
| 424 | fg = Fg( aircraft, f'{fgfs} --prop:/sim/replay/log-raw-speed-multiplayer=cgdae-t') |
| 425 | else: |
| 426 | fg = Fg( aircraft, f'{fgfs}') |
| 427 | path = f'{g_tapedir}/{fg.aircraft}-continuous.fgtape' |
| 428 | |
| 429 | fg.waitfor('/sim/fdm-initialized', 1, timeout=45) |
| 430 | |
| 431 | fg.fg['/controls/engines/engine[0]/throttle'] = 0 |
| 432 | |
| 433 | # Throttle/speed for ufo is set in fgdata/Aircraft/ufo/ufo.nas. |
| 434 | # |
| 435 | speed_max = 2000 # default for ufo; current=7. |
| 436 | fixed_speed = 100 |
| 437 | throttle = fixed_speed / speed_max |
| 438 | |
| 439 | if multiplayer: |
| 440 | fg.fg['/sim/replay/record-multiplayer'] = True |
| 441 | fg2 = Fg( aircraft, f'{fgfs} --callsign=cgdae-t --multiplay=in,4,,5033 --read-only', telnet_port=5501) |
| 442 | fg2.waitfor('/sim/fdm-initialized', 1, timeout=45) |
| 443 | fg.fg['/controls/engines/engine[0]/throttle'] = throttle |
| 444 | fg2.fg['/controls/engines/engine[0]/throttle'] = throttle |
| 445 | time.sleep(1) |
| 446 | fgt = fg.fg['/controls/engines/engine[0]/throttle'] |
| 447 | fg2t = fg2.fg['/controls/engines/engine[0]/throttle'] |
| 448 | log(f'fgt={fgt} fg2t={fg2t}') |
| 449 | else: |
| 450 | fg.fg['/controls/engines/engine[0]/throttle'] = throttle |
| 451 | |
| 452 | # Run UFO with constant speed, varying the framerate so we check whether |
| 453 | # recorded speeds are affected. |
| 454 | # |
| 455 | fg.fg['/sim/frame-rate-throttle-hz'] = 5 |
| 456 | if multiplayer: |
| 457 | fg2.fg['/sim/frame-rate-throttle-hz'] = 5 |
| 458 | |
| 459 | # Delay to let frame rate settle. |
| 460 | time.sleep(10) |
| 461 | |
| 462 | # Start recording. |
| 463 | fg.fg['/sim/replay/record-continuous'] = 1 |
| 464 | time.sleep(5) |
| 465 |
no test coverage detected