VR-Forces 4.10 Lua Function Documentation

rtdIntegrationUtil

(For high level concepts about how to use Lua to write scripted tasks, please see VR-Forces User's Guide.)

A set of utilities for executing flight subtasks when the RTD plugin is loaded. With the RTD plugin loaded, there are RTD tasks that can replace the VRF tasks for FWA entities from the RTD SMS. Also, the VRF tasks fly-heading, fly-heading-and-altitude, and fly-to-location are not available in the FWA from the RTD SMS, so RTD tasks must be used. On the other hand, FWA from the EntityLevel SMS must use the VRF movement tasks. This module defines functions that can be called from scripts instead of using vrf:startSubtask; the functions determine whether the RTD tasks are available and then set up and issue the appropriate subtask.
In the case of move-to-location, there is an RTD task, but it cannot be used like the VRF fly-to-location or move-to-location task. The VRF tasks use a fairly high "aggressiveness" which allows the aircraft to make high-G turns, while the RTD aircraft default to a wing Load Factor of only 1.2. Thus the RTD task is much more likely to abandon the task immediately if the goal is relatively close. The code here attempts to account for this difference. F USAGE EXAMPLE:


require "rtdIntegrationUtil"
airTasks = rtdIntegrationUtil.multiModelAirTasks()
taskId = airTasks.flyHeading(goalHeading) -- Starts a subtask to fly at a heading

In this version, VR-Forces 4.8 IPB2, the following is assumed about RTD:
  • fly-to-location is not implemented
  • fly-to-heading is not implemented
  • move-to-location ia implemented. Note that if the destination cannot be reached with a turn at the current maneuver parameters (i.e., load factor and speed), the task is ended immediately.
  • Function List

    flyHeading (heading, turnDirection, turnRate) Starts a subtask to fly to a heading.
    flyHeadingAndAltitude (heading, altitude, verticalSpeed, turnDirection, turnRate) Starts a subtask to fly to a heading and altitude.
    flyToLocation (aimingPoint, useFixedPitch) Starts a subtask to fly to a location.
    multiModelAirTasks () Provides a table with functions that start tasks.


    Functions

    flyHeading (heading, turnDirection, turnRate)
    Starts a subtask to fly to a heading. If this is a RTD aircraft, an RTD turn task is preferred, and fly-heading is not implemented anyway. Use FWLCGF_BankedTurn since that allows specification of L or R turn.

    Parameters:

    • heading: is the desired heading, in radians.
    • turnDirection: is the desired direction of turn: -1 = left, 0 = closest direction, 1 = right. (Note RTD aircraft will always turn in the shortest direction. If a specific direction is required, consider fly_circular_arc.)
    • turnRate: is radians/sec. If nil, then the ownship speed is used to compute a turn rate that results in a wing load factor of 1.2g.

    Return value:

      A task ID of the running task.
    flyHeadingAndAltitude (heading, altitude, verticalSpeed, turnDirection, turnRate)
    Starts a subtask to fly to a heading and altitude. If this is an RTD aircraft, an RTD turn task is preferred, and fly-heading-and-altitude is not available anyway. In order to get the AC to fly at an altitude, FWLCGF_BasicFlight has to be used, because that has an altitude parameter. However, it does not have a turn direction parameter, so the turn will always be to "closest direction".

    Parameters:

    • heading: is the desired heading, in radians.
    • altitude: is the desired altitude, in meters
    • verticalSpeed: is the desired climb or descent rate, in mps.
    • turnDirection: is the desired direction of turn: -1 = left, 0 = closest direction, 1 = right. (Note RTD aircraft will always turn in the shortest direction. If a specific direction is required, consider fly_circular_arc.)
    • turnRate: is radians/sec. If nil, then the ownship speed is used to compute a turn rate that results in a wing load factor of 1.2g.

    Return value:

      A task ID of the running task.
    flyToLocation (aimingPoint, useFixedPitch)
    Starts a subtask to fly to a location. If this is an RTD aircraft, the fly-to-location task is not available, so the RTD move-to-location task has to be used. However, this task will abort quickly if the aircraft cannot turn sharply enough to hit the destination point; so a Set must be used to set the default load factor high enough to make the maneuver.

    Parameters:

    • aimingPoint: The location3D to fly to.
    • useFixedPitch: A boolean flag indicating whether to fly at a steady climb to the aimingPoint, or to fly to the point's altitude as quickly as possible and then fly level flight the rest of the way. Not applicable for RTD models.

    Return value:

      a task Id for the task.
    multiModelAirTasks ()
    Provides a table with functions that start tasks. The tasks may be different if the entity is from the RTD SMS vs. the VR-Forces factory EntityLevel SMS.

Copyright© 2021 MAK Technologies, Inc. All rights reserved.