VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F18 Example

The f18 program simulates a simple HLA or DIS vehicle.

By default, that vehicle is n F/A18 flying in a circle, just off the coast of California, USA, but you can control the entity type, location and route.

The f18 generates predictable HLA entity update messages (or DIS entity state PDUs), so it is a useful tool for debugging applications that receive and interpret these messages. It can also fire munitions and react to detonations.


The F18 is composed of two major classes:

The F18 example is contained in several major files:

The main application:

/****************************************************************************
* Copyright (c) 2014 VT MAK
* All rights reserved.
****************************************************************************/
#include "multiF18Init.h"
#include <stdlib.h>
#include <iostream>
#ifndef _WIN32
#include <sys/socket.h>
#endif
// *****************************************************************
// *************************** GLOBALS *****************************
// *****************************************************************
DtTime timeOutInterval = 12.0; // seconds
DtTime timeThreshold = 5.0; // seconds
double translationThreshold = 1.0; // meters
double rotationThreshold = DtDeg2Rad( 3.0 ); // radians
#if VXWORKS
#define main realMain
#endif
// *****************************************************************
// *************************** MAIN *******************************
// *****************************************************************
int main( int argc, char* argv[] )
{
// Used for error handling
DtINIT_MINIDUMPER( "Parallel-F18" );
try
{
// get the PID so we can run multiple F18's
int pid = DtGetPid();
DtString pidStr( pid );
// get the Application name
DtString appName = "VR-Link F18 " + pidStr;
DtF18Initializer initializer( argc, argv, appName );
initializer.setApplicationNumber( pid );
DtString defaultF18Name( initializer.f18Name() );
defaultF18Name += " " + pidStr;
initializer.setF18Name( defaultF18Name );
#ifdef DtHLA
initializer.setFederateType( defaultF18Name );
#endif
initializer.parseCmdLine();
// Create an instance of our simulator
DtMultiVehicleFed simulator;
// Set up default static values
// This is the only DIS specific code in this file.
#if DtDIS
DtEntityPublisher::setDfltTimeThreshold( timeThreshold );
// MUST use async I/O in parallel mode for thread saftey
// Sync I/O in DIS not yet thread safe
initializer.setUseAsynchIO(true);
#endif
// Connect to the exercise or RTI
simulator.initializeExConn(DtTime(timeThreshold), &initializer);
// initialize the fleet
simulator.initializeFleet(0, initializer.count(), &initializer);
// Simulation loop
int forever = 1;
while( forever ) // to keep cfront quiet
{
// process incoming data
simulator.drainInput(initializer.deltaTime());
// Perform simulation for the current time frame
simulator.simulate();
// Publish simulation changes
simulator.publish();
// wait for real time to catch up to simulated time
simulator.sleep(initializer.deltaTime());
}
simulator.dismantleFleet(); // Dismantle the fleet of vehicles
simulator.dismantleExConn(); // Dismantle exercise connection
}
DtCATCH_AND_WARN(std::cout);
return 0;
}

Document ID: Generated on Wed Jan 7 13:31:29 EST 2015 from SVN revision 149162
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)