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

MC02 is an complex DDM extension to RPR which creates all sorts of regions for different types of entities.

This is a talk program which uses a subset of the MC02 DDM standard to publish entities in a DDM area related to their force type instead of their geographic location, like the DDMTalk example. This program only works in HLA and is closely related to the Talk example.


/****************************************************************************
* Copyright (c) 2014 VT MAK
* All rights reserved.
****************************************************************************/
#include <vl/topoView.h>
#include "mc02Regions.h"
int main( int argc, char* argv[] )
{
// Used for error handling
DtINIT_MINIDUMPER( "MC02-Talk" );
// Create a connection to the exercise or federation execution.
DtVrlApplicationInitializer appInit(argc, argv, "VR-Link MC02 Talk");
appInit.setExecName("VR-LinkMC02");
appInit.setFedFileName("VR-LinkMC02.fed");
//require for mc02 to send messages
appInit.setUseAdvisories(false);
appInit.parseCmdLine();
DtExerciseConn exConn(appInit);
//force ignoreAdvisories
exConn.ignoreAdvisories();
DtEntityPublisher* blueF18 = 0;
DtEntityPublisher* redF18 = 0;
DtDDMRegionSP blueRegion;
DtDDMRegionSP redRegion;
try
{
DtBoost::shared_ptr<DtBlueAirRegion> baRegion(new DtBlueAirRegion(&exConn));
blueRegion = baRegion;
baRegion->notifyRtiOfUpdate();
DtDDMRegionSet blueRegSet;
blueRegSet.insert(baRegion);
blueF18 = new DtEntityPublisher(f18Type, &exConn, DtDrDrmRvw, DtForceFriendly,
DtEntityPublisher::guiseSameAsType(), "Blue F18", &blueRegSet);
DtBoost::shared_ptr<DtRedAirRegion> raRegion(new DtRedAirRegion(&exConn));
redRegion = raRegion;
raRegion->notifyRtiOfUpdate();
DtDDMRegionSet redRegSet;
redRegSet.insert(raRegion);
redF18 = new DtEntityPublisher(f18Type, &exConn, DtDrDrmRvw, DtForceOpposing,
DtEntityPublisher::guiseSameAsType(), "Red F18", &redRegSet);
}
catch (DtException& regionException)
{
DtWarn << "Caught exception: " << regionException << std::endl;
}
// Hold on to its state repository, where we can set data.
DtEntityStateRepository *blueEsr = blueF18->entityStateRep();
// Create a topographic view on the state repository, so we
// can set position information in topographic coordinates.
double refLatitude = DtDeg2Rad( 35.699760);
double refLongitude = DtDeg2Rad(-121.326577);
DtTopoView blueTopoView(blueEsr, refLatitude, refLongitude);
DtTopoView redTopoView(redEsr, refLatitude, refLongitude);
// We can use the ESR to set state.
blueEsr->setMarkingText("Blue");
redEsr->setMarkingText("Red");
// Initialize VR-Link time.
DtClock* clock = exConn.clock();
DtVector bluePosition(0, 0, -100);
DtVector redPosition(20, 0, -100);
DtVector32 velocity(20, 0, 0);
// Main loop
DtTime dt = 0.05;
DtTime simTime = 0;
while (simTime <= 10.0)
{
// Tell VR-Link the current value of simulation time.
clock->setSimTime(simTime);
// Process any incoming messages.
exConn.drainInput();
// Set the current position information.
blueTopoView.setLocation(bluePosition);
redTopoView.setLocation(redPosition);
blueTopoView.setVelocity(velocity);
redTopoView.setVelocity(velocity);
// Call tick, which insures that any data that needs to be
// updated is sent.
blueF18->tick();
redF18->tick();
// Set up for next iteration.
bluePosition[0] += velocity[0] * dt;
redPosition[0] += velocity[0] * dt;
simTime += dt;
// Wait till real time equals simulation time of next step.
DtSleep(simTime - clock->elapsedRealTime());
}
return 0;
}


Document ID: Generated on Mon Feb 6 18:36:34 EST 2017 from SVN revision 173107
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)