VR-Forces 4.2 Class Documentation
VRF Message Printer

This subclass of DtVrfMessageInterface creates and registers with the various factories to be able to create and print interactions.

How to Run

This example demonstrates how to listen for and display VR-Forces-specific interface messages.

Usage:

(Release) vrfMsgDump

(Debug) vrfMsgDumpd

To run the application:

  1. Start VR-Forces from the start menu.
  2. Start vrfMsgDump

The contents of all VR-Forces-specific interface messages (e.g. tasks, set data requests) will be displayed in the vrfMsgDump console window. As you run VR-Forces, any task or set data request messages that get created over the course of a scenario will be displayed by vrfMsgDump.


Header file:

/*******************************************************************************
** Copyright (c) 2003 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: simpleRdrWrnResp.h,v $ $Revision: 1.7 $ $State: Exp $
*******************************************************************************/
#ifndef DtSimpleRadarWarningResponse_H_
#define DtSimpleRadarWarningResponse_H_
//class DtSimpleRadarWarningResponse:
//
//Instances of DtSimpleRadarWarningResponse are an example of a controller
//that implements a reactive behavior when a it receives sensor input that
//a radar has been detected. It receives a list of emitter systems (hostile
//radar systems). It takes the first emitter in the list and flys away to
//a location in the opposite direction.
{
public:
//constructor
DtSimManager* simManager, DtComponentDescriptor* desc = NULL,
DtReaderWriterRegistry* const parentRegistry = 0);
//destructor
//This returns a string that uniquely identifies this type of component.
//(must be unique with respect to the component types defined in compTypes.h
//as well as any additional user-defined components). Returns the string
//"simple-radar-warning-response".
virtual DtString type() const;
//Calculate new control values.
virtual void tick();
//Returns a newly created instance of this class. We need to provide
//this function so that we can register this class with the component
//factory.
static DtSimComponent* creator(const DtString& name, DtVrfObject* owner,
DtSimManager* simManager, DtComponentDescriptor* desc,
DtReaderWriterRegistry* parentRegistry);
protected:
//Called by DtSimComponent::init to create myEntityListPort used to manage
//multiple sensors that might provide targets to this controller.
virtual bool createPorts();
//Looks up safe control point by name. If the object exists and it has
//a valid state repository, returns the object. Otherwise returns NULL.
virtual DtVrfObject* getControlPoint(const DtString& name);
//Returns true if we are in the vicinity of the given position. To be
//in the vicinity of the position means that we are within 5 seconds of
//the given location, given our ordered speed.
virtual bool inVicinity(const DtVector& localPosition);
protected:
//default constructor
//copy constructor, not implemented
//assignment operator, not implemented
protected:
//Port though which the list of hostile emitter systems will be received.
//true while in state of reacting to the detection of an emitter.
//Name of the safe location (a control point) we can retreat to.
};
#endif

Implementation:

/*******************************************************************************
** Copyright (c) 2003 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: simpleRdrWrnResp.cxx,v $ $Revision: 1.18 $ $State: Exp $
*******************************************************************************/
#include <vlutil/vlPrint.h>
#include "vrfcore/simMgr.h"
const DtString & name, DtVrfObject* owner, DtSimManager * simManager,
DtComponentDescriptor* desc, DtReaderWriterRegistry * const parentRegistry) :
DtFixedWingPilotController(name, owner, simManager, desc, parentRegistry),
myEmitterListPort(NULL),
myReactingToWarning(false),
mySafeControlPointName("Safe Haven")
{
}
{
{
}
}
{
return DtString("simple-radar-warning-response");
}
{
if (!(myEmitterListPort = new DtEntityListInputPort("emitter-list")))
{
return false;
}
}
{
//If dT is > 0 (we're not paused), then do the work
if (dT() > 0.)
{
//Called each frame by the deriving controllers to set up need variables,
//such as myNormalBodyVelocity and myLocalAngularVelocity.
if (!safeControlPoint)
{
DtWarn("DtSimpleRadarWarningResponse::tick() : Invalid safe control "
"point %s\n", mySafeControlPointName.string());
return;
}
DtVector safeLocation = safeControlPoint->vrfState()->
vrfKinematicState()->localPosition();
//If I'm already reacting to a previous radar warning
{
//Take control of the port group - this gives us exclusive control
//over the fixed-wing actuator until we give that control up or a
//higher priority controller overrides us
{
if (inVicinity(safeLocation))
{
//We're done
objectConsoleWarn() << "radarWarnRx Example - " <<
"We have reached the safe location! " << std::endl;
objectConsoleWarn() << "radarWarnRx Example - " <<
"Resume normal activity." << std::endl;
//Give up control of actuator's port group so other
//components may control it.
}
else
{
//Move toward the safe location
}
}
}
else
{
{
objectConsoleVerbose() << "radarWarnRx Example - " <<
"No emitter list for radar warning reaction controller" <<
std::endl;
return;
}
//Get 1st emitter system on list of emitters on the port
const DtEntityTargetList* emitterList = myEmitterListPort->value();
//If there aren't any emitters out there, there's nothing to react to
if (!(emitterList->first() && emitterList->first()->data()))
{
//Mark the data as "old"
return;
}
//We have an emitter out there
(DtEntityTargetInformation *)emitterList->first()->data();
//Look up the entity with the radar
DtVrfObject* emitterSystemHost =
if (!emitterSystemHost)
{
//Mark the data as "old"
return;
}
//We're now reacting to an emitter
objectConsoleWarn() << "radarWarnRx Example - " <<
"Simple radar warning rx detected emitter " << info->id().string() <<
"." << std::endl;
objectConsoleWarn() << "radarWarnRx Example - " <<
"Move away from the source!" << std::endl;
//Take control of port group - this gives us exclusive control
//over the fixed-wing actuator for the duration of the frame (no other
//controllers that come after this one will be able to control it).
{
//Move toward the safe location
}
//Mark the data as "old"
}
}
}
DtVrfObject* owner, DtSimManager * simManager, DtComponentDescriptor* desc,
DtReaderWriterRegistry * parentRegistry)
{
return new DtSimpleRadarWarningResponse(name, owner, simManager, desc,
parentRegistry);
}
{
lookupVrfObjectByName(mySafeControlPointName);
if (!controlPoint)
{
objectConsoleWarn() << "radarWarnRx Example - " <<
"DtSimpleRadarWarningResponse::getControlPoint() : Can't find control point " <<
name << std::endl;
return NULL;
}
if (!controlPoint->vrfState())
{
objectConsoleWarn() << "radarWarnRx Example - " <<
"Control point " << name << " does not have state repository!" << std::endl;
return NULL;
}
return controlPoint;
}
const DtVector& localPosition)
{
{
}
myFixedWingEntityState->orderedSpeed() * 25.0)) //5 seconds away...
{
return true;
}
return false;
}

Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)