![]() |
VR-Link API Documentation for HLA 1.3
|
Talk is a minimal VR-Link application.
The program simulates the flight of an F18 aircraft. The program begins by sending a fire PDU or HLA fire interaction. Then, the F18 flies north for 10 seconds, updating its position by sending DIS entity state PDUs or HLA attribute updates.
This example is an extremely simplified version of the F18 example. It publishes a stripped down aircraft. The published data can be viewed by the Listen example.
This example builds and runs in DIS, HLA1.3, HLA1516 and HLA1516e, because we use the VR-Link Protocol Independent API.
Like the listen-only example, this program creates a DtExerciseConn to provide an interface to the RTI or DIS network.
We define the entity type the F18 will use.
To be visible to other applications in the exercise, each locally-simulated entity requires a DtEntityPublisher. The entity publisher manages the generation of messages for this particular entity. It provides an entity state repository where you can set state values, and a tick() function, which causes state information to be sent to the network if necessary.
It sets up a pointer to the entity state repository, then creates a topographic view on that repository. This lets us set the entity's positional data using topographic coordinates, rather than the default geocentric coordinates. (The coordinates are hard-coded for this example.) We show an example of storing a non-positional state value in the repository.
The example sends an interaction. You can send the interaction using the exercise connection's sendStamped() function.
You can use sendStamped() to send state updates, but it is preferable to let the entity publisher send state updates for you, using data in the entity state repository.
The main loop executes twenty times per second for ten seconds. As in the listen-only example, this program sets VR-Link simulation time at the start of each iteration.
While this program's main purpose is to demonstrate the sending of data to the network, it is not a true send-only application. Incoming data is also processed with the drainInput() call. This call is required for HLA, because this is where we tick the RTI.
The program updates the F18's positional data in its entity state repositoryentity state repository and ticks the entity publisher to send the updated data onto the network. It sets topographic coordinates through a view, which VR-Link converts to geocentric coordinates.
Then, the only remaining tasks are to increment the F18's position, increment the simulation time, and sleep until it is time to begin the next iteration.