![]() |
VR-Forces 4.10 Class Documentation
|
This subclass of DtFixedWingPilotController will fly away from a radar installation if signalled to do do by the DtSimpleRadarWarningReceiver.
The new controller component, DtSimpleRadarWarningResponse (simpleRdrWrnResp.h), provides a simple response when it receives a warning from the radar warning receiver. It attempts to move toward a waypoint named Safe Haven, if an object by that name exists in the simulation.
The controller for handling the reaction to a threat detected by the radar warning receiver is intended for a fixed-wing entity. All of the movement-related controllers for fixed-wing aircraft are derived from DtFixedWingPilotController, so we derive from that class for our new controller. Among other things, we inherit the ports required to control a DtFixedWingActuatorComponent, the actuator used by the F-16 entity. Like the sensor components created in “Creating the New Sensor Components,”, the following member functions must be implemented for the component to function correctly within the component architecture:
DtFixedWingPilotController(const DtString & name, DtVrfObject* owner, DtSimManager* simManager, DtComponentDescriptor* desc=0, DtReaderWriterRegistry* parentRegistry = 0);
;;
;; Entry for US generic attack/strike fixed wing platform
;;
(US-attack-strike-fixed-wing-platform
(parameter-type "fixed-wing-entity-param")
(object-type 1 (1 2 225 2 -1 -1 -1))
. . .
(sensors
. . .
(simple-radar-warning-rx
. . .
)
)
(controllers
. . .
(simple-radar-warning-reaction-controller
. . .
)
)
(connections
. . .
;;
;; connect <component-name>:<port-name> <component-name>:<port-name>
;;
(connect simple-radar-warning-rx:emitter-list
simple-radar-warning-reaction-controller:emitter-list)
)
)
if(!safeControlPoint)
{
DtWarn("DtSimpleRadarWarningResponse::tick() :
Invalid safe control " "point %s",
mySafeControlPointName.string());
return;
}
DtVector safeLocation = safeControlPoint->vrfState()->vrfKinematicState()->localPosition();
if (myFixedWingControlPortGroup->attemptToActivate())
{
if (inVicinity(safeLocation))
{
DtInfo("DtSimpleRadarWarningResponse::tick(): we're done! "
"Resume normal activity”);
myReactingToWarning = false;
myFixedWingControlPortGroup->deactivate();
}
else
{
flyTo(safeLocation, myFixedWingEntityState->orderedSpeed());
}
}
const DtList* emitterList = myEmitterListPort->value();
if (!(emitterList->first() && emitterList->first()->data()))
{
myEmitterListPort->dataReceived();
return;
}
DtEntityIdentifier * id = (DtEntityIdentifier *)emitterList->first()->data();
DtVrfObject* emitterSystemHost = mySimManager->vrfObjectManager()->lookupVrfObject(*id);
if (!emitterSystemHost)
{
myEmitterListPort->dataReceived();
return;
}
myReactingToWarning = true;
DtInfo("Simple radar warning rx detected emitter %s”, id->string());
DtInfo("Move away from the source!”);
if (myFixedWingControlPortGroup->attemptToActivate())
{
flyTo(safeLocation, myFixedWingEntityState->orderedSpeed());
}
myEmitterListPort->dataReceived();To get your new sensor and controller components into VR-Forces you must register the creators with the component factory. See “Adding the Actuator Component to the Component Factory,” in VR-Forces Developer’s Guide for details. You do this in plugin.cxx:
app->cgf()->factoryManager()->componentFactory()->addCreatorFcn("simple-radar-warning-receiver",
DtSimpleRadarWarningReceiver::creator);
app->cgf()->factoryManager()->componentFactory()->addCreatorFcn("simple-radar-warning-response",
DtSimpleRadarWarningResponse::creator);
app->cgf()->factoryManager()->componentFactory()->addCreatorFcn("scanning-radar", DtScanningRadar::creator);
Configuring Entities to Use the New Components
Now that we have incorporated the new components into the application, we need to configure specific entities to use the new components. In our new sensor and controller classes we did not add any new parameters, so we use the existing parameter and component descriptor classes associated with each component. (For an example of adding new parameters see “Creating a New Controller,” in the VR-Forces Developer’s Guide.)
In this example, we extended the CIS generic attack/strike fixed-wing entity entity with the new radar warning receiver and corresponding response controller.
;;
;; Entry for CIS generic attack/strike fixed wing platform
;;
(CIS-attack-strike-fixed-wing-platform
(parameter-type "fixed-wing-entity-param")
(object-type 1 (1 2 222 2 -1 -1 -1))
(sensors
. . .
(simple-radar-warning-rx
;; We don't have any special parameters - the base class component
;; descriptor will suffice
(component-descriptor-type "component-descriptor")
;; This identifies the class type to create for this sensor. It
;; should match the string returned by
;; DtRadarWarningReceiver::type().
(component-type "simple-radar-warning-receiver")
)
)
(controllers
. . .
;;
;; Add our new controller component
;;
(simple-radar-warning-reaction-controller
(component-descriptor-type "fixed-wing-pilot-controller-descriptor")
(component-type "simple-radar-warning-response")
;; These are additional parameters for the descriptor class we're
;; using (DtFixedWingPilotControllerDescriptor).
(max-turning-Gs 9.)
(max-turnrate-cutoff-angle 0.5236) ;; 30. degrees
)
)
(actuators
. . .
) ;; end actuators
(connections
. . .
;;
;; Connect the sensor to the new controller
;;
(connect simple-radar-warning-rx:emitter-list simple-radar-warning-reaction-controller:emitter-list)
;;
;; Connect the new controller to the fixed wing actuator
;;
. . .
) ;; end connections
) ;; end US-attack-strike-fixed-wing-entity
A modified object parameters database (configured with the new components) is in ./examples/radarWarnRx/scenario/RadarWarnRx.opd.
Header file:
Implementation: