This example shows how describes how command-line/MTL parameters could be added to a VR-Link application.
It shows how to specify behavior-specific parameters either by parsing command-line arguments or parsing an MTL file.
Subclassing the VRL Application Initializer
DtLauncherInitializer derives from DtVrlApplicationInitializer and describes how command line/MTL parameters could be added to a VR-Link application. The DtVrlApplicationInitializer contains default behavior for protocol specific parameters, so we can specify behavior particular to the F18 application in the derived DtLauncherInitializer class. Within the new Launcher Initializer class, we add a parseCmdLine() function to handle parsing the command line arguments specified in this class and DtVrlApplicationInitializer. Additionally, we need to register the new variables so they can be parsed correctly when loadMtlFile() is called (defined in DtVrlApplicationInitializer) with an MTL file name. This will parse the MTL file specified and set those variables registered.
How to Run the Example
- Launch a simulation viewer such as VR-Vantage or VR-Forces for the protocol of choice. It is recommended to view this using the Ground_DB II.mtf terrain
- Launch the launcher example from the VR-Link install's bin64 directory for the same protocol.
- In the viewer, notice that the Scud missile launcher launches the missile with the specified parameters.
Example Code
Main Application
int main( int argc, char* argv[] )
{
#if DtDIS
init.setDisVersionToSend( 7 );
#else
init.setFedFileName( DtDefaultRpr2Fom );
init.setExecName( "MAK-One-2024" );
init.setRprFomVersion( 2.0 );
init.setRprFomRevision( 1 );
#endif
init.parseCmdLine();
#ifdef DtHLA_1516_EVOLVED
init.addFomModule("NETN-BASE.xml");
init.addFomModule("NETN-Physical.xml");
init.addFomModule("NETN-METOC.xml");
init.addFomModule("NETN-MRM.xml");
init.addFomModule("MAK-Physical-2_evolved.xml");
init.addFomModule("MAK-Aerodrome-1_evolved.xml");
init.addFomModule("MAK-METOC-1_evolved.xml");
init.addFomModule("MAK-VRFExt-9_evolved.xml");
init.addFomModule("MAK-DIGuy-7_evolved.xml");
init.addFomModule("MAK-LgrControl-2_evolved.xml");
init.addFomModule("MAK-VRFAggregate-6_evolved.xml");
init.addFomModule("MAK-DynamicTerrain-2_evolved.xml");
init.addFomModule("MAK-VRLExt-3_evolved.xml");
init.addFomModule("RPR-Enumerations_Experimental_IFF.xml");
init.addFomModule("RPR-MAK_Experimental_IFF-3.xml");
#endif
static int stationList[] = {512, 0};
topoView.setLocation(
DtVector(0,0,-0.75));
while(simTime <= init.lifeTime())
{
if (simTime > init.erectorStartTime() &&
simTime < init.erectorStopTime())
{
(float) (0.15 * (simTime - init.erectorStartTime())));
}
else
{
}
if (simTime > init.missileSwapTime() &&
simTime < (init.missileSwapTime() + .05))
{
if (!scud)
{
scud =
new Missile(&exConn, &launcher, init);
}
}
if (simTime > init.fireTime() &&
simTime < (init.fireTime() + 0.05))
{
}
if (simTime > init.damageTime())
{
}
launcher.tick();
if (scud)
{
}
simTime += dt;
}
return 0;
}
Launcher Initializer Header
Launcher Initializer Header
#ifndef launcherInit_H_
#define launcherInit_H_
{
public:
private:
public:
protected:
protected:
};
#endif
Launcher Initializer Source
myLispFileName(mySettings, "&lispFile", "launcher.mtl", "LISP File Name",
myLifeTime(mySettings, "lifeTime", 120.0, "Life Time",
myErectorStartTime(mySettings, "erectorStartTime", 10.0, "Time To Start Erector",
myErectorStopTime(mySettings, "erectorStopTime", 15.0, "Time To Stop Erector",
myFireTime(mySettings, "fireTime", 23.0, "Time To Fire",
myMissileSwapTime(mySettings, "missileSwapTime", 23.0, "Missile Swap Time",
myMissileMoveTime(mySettings, "missileMoveTime", 23.0, "Missile Move Time",
myMissileStopTime(mySettings, "missileStopTime", 45.0, "Missile Stop Time",
myDamageTime(mySettings, "damageTime", 45.0, "Damage Time",
myRefLatitude(0.0),
myRefLongitude(0.0)
{
}
{
}
{
}
{
{
}
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
Defining the Missile
Missile Header
Missile Source
myMissileMoveTime(init.missileMoveTime()),
myMissileStopTime(init.missileStopTime()),
initPosition( 0.0, 0.0, 0.0 )
{
DtDcm erectNeutral2erect;
DtVector neutralErectorWRTlauncher(-6.64, -0.73, -1.65);
DtVector missileWRTerector(5.21, 0.70, -0.7688);
missileWRTneutralErector);
DtVecAdd(missileWRTneutralErector, neutralErectorWRTlauncher,
initPosition);
initPosition = (missileWRTneutralErector + neutralErectorWRTlauncher);
myTopoView->setLocation(initPosition);
myTopoView->setOrientation(initAngles);
myPub->tick();
}
{
}
{
}
{
}
{
{
}
{
}
}
{
}