![]() |
VR-Forces 4.0.4 Class Documentation
|
DtWeaponController is a controller that extends the DtBaseWeaponController with the ability to accept a list of targets as input. More...

Public Member Functions | |
| DtWeaponController (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0) | |
| (const DtString&,DtVrfObject*,DtSimManager*, | |
| virtual | ~DtWeaponController () |
| destructor | |
| virtual DtString | type () const |
| Returns a string identifies the class type of component. | |
| virtual bool | createMountingController () |
| Overridden to create a DtMountingController. | |
| virtual bool | init () |
| Overridden to initialize values obtained from the descriptor. | |
| virtual void | tick () |
| If the myWaitingForFire flag is set and the munition loader is still loaded, the weapon has not fired yet and the function immediately returns. | |
| virtual void | fire () |
| updates weapon interface | |
| virtual DtVrfObject * | chooseTarget () |
| Called by tick() to find a target. | |
| virtual DtVrfObject * | chooseTarget (const DtEntityTargetList &targetList) const |
| Called by acceptSensorTargettingInput to choose a target from the list of potential target entities on myTargetListPort. | |
| virtual void | tickMunitionLoader (const DtVrfObject *target) |
| This method will set the flags myLoading, myUnloading, myLoaded as the load state of the weapon changes. | |
| virtual bool | acquireTarget (const DtVrfObject *target) |
| Returns true when target has been acquired. | |
| virtual void | maneuverRequiredToAcquireTarget (DtReal requiredHeading, DtReal requiredPitch, DtReal requiredMaxSpeed) |
| Not implemented in this class. | |
| virtual bool | loadedAmmoValidForTarget (const DtVrfObject *target) const |
| Called by tick() as part of the check to see if the trigger should be pulled. | |
| virtual bool | chooseAmmo (const DtEntityType &entityType, DtSimMunition &munitionOut, DtDetonatorFuze &fuzeOut, bool setCurrentMunition=true) |
| The chooseAmmo() function is passed a pointer to a target entity and returns the best ammunition to use for the target's entity type. | |
| virtual bool | acceptSensorTargettingInput () |
| Returns true if we get a viable target from the sensor. | |
| virtual bool | inSector (DtVrfObject *entity) const |
| Sets the trigger port value to true, sets myLoaded flag to false, and depletes the resource associated with the current munition type in the entity's local state repository. | |
| virtual void | findBodyHeadingElevationToTarget (const DtVrfObject *entity, DtReal &bodyHeadingOut, DtReal &bodyElevationOut) const |
| Given a target entity, computes the body heading (azimuth) and elevation angles to the target, in the body coordinates of the entity. | |
| virtual DtVrfObject * | easier (DtVrfObject *entity1, DtVrfObject *entity2) const |
| This function takes two DtVrfObject* entities as arguments, and returns the entity that is easier for the weapon to acquire. | |
Static Public Member Functions | |
| static DtSimComponent * | creator (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0) |
| (const DtString&,DtVrfObject*,DtSimManager*, | |
Protected Member Functions | |
| virtual bool | createPorts () |
| Overridden to create the local ports. | |
| virtual void | addRangeItems () |
| Adds all items that have a range to the object state repository. | |
| DtWeaponController () | |
| default constructor; not implemented | |
| DtWeaponController (const DtWeaponController &orig) | |
| copy constructor; not implemented | |
| const DtWeaponController & | operator= (const DtWeaponController &orig) |
| assignment operator; not implemented | |
Protected Attributes | |
| DtEntityIdentifier | myCurrentTarget |
| DtMountingController * | myMountingController |
| const DtWeaponControllerDescriptor * | myWeaponCtlrDesc |
| DtWeaponComponentInterface * | myWeaponComponentInterface |
Ports and Port Groups | |
| DtEntityListInputPort * | myTargetListPort |
| Input Port Name: target-list Input Port Description: List of targets detected. | |
| DtBooleanInputPort * | myWeaponsHoldPort |
| Input Port Name: weapons-hold Input Port Description: When true, all firing of missiles is disabled. | |
DtWeaponController is a controller that extends the DtBaseWeaponController with the ability to accept a list of targets as input.
End User Description: The weapon controller accepts input from a target sensor, and provides ammunition type, load status, and trigger inputs to a weapon actuator. It also provides azimuth and elevation inputs to corresponding azimuth and elevation mount actuators (moveable components upon which a weapon may be mounted).The weapon controller designates its target as the first target that appears in the entity's sector of responsibility. Based on the target type, it loads the appropriate munition type. If a change in target occurs, requiring a change in munition type, or fuze type, or both (that is, the new target detected is of a different type than the original target), the weapon unloads the old munition, and then fuse type, or both (that is, the new target loads the new type of munition. If no target is available, and the preload-weapon parameter is set, then the first munition type specified in the munition table is loaded. The target is acquired when the azimuth and elevation of the weapon align with the azimuth and elevation to the target, within the ranges specified by the munition-maneuver-margin parameter. The controller reorients the weapon in azimuth and elevation as needed. Once a target has been acquired, the weapon is loaded, and the entity has permission to fire (given by the entity's rules of engagement, for example, “fire-at-will”), the weapon controller fires. It sets the trigger port to true, and depletes the resource associated with the munition type.
Uses Descriptor Type: DtWeaponControllerDescriptor
| DtWeaponController::DtWeaponController | ( | const DtString & | name, |
| DtVrfObject * | owner, | ||
| DtSimManager * | simManager, | ||
| DtComponentDescriptor * | desc = 0, |
||
| DtReaderWriterRegistry * | parentRegistry = 0 |
||
| ) |
(const DtString&,DtVrfObject*,DtSimManager*,
| name | Reader writer name of this component. |
| owner | The DtVrfObject that owns this component |
| simManager | The simulation manager (provides access to terrain, message interface, simulation clock). |
| desc | The component descriptor used to initialize this component. |
| parentRegistry | Pointer to the parent reader writer registry (the containing object that reads/writes this object). |
| virtual DtWeaponController::~DtWeaponController | ( | ) | [virtual] |
destructor
| DtWeaponController::DtWeaponController | ( | ) | [protected] |
default constructor; not implemented
| DtWeaponController::DtWeaponController | ( | const DtWeaponController & | orig | ) | [protected] |
copy constructor; not implemented
| virtual DtString DtWeaponController::type | ( | ) | const [virtual] |
Returns a string identifies the class type of component.
Type values are defined in compTypes.h. DtSimComponent creation functions are registered with the DtSimComponentFactory using the type values as the key.
Reimplemented from DtBaseWeaponController.
Reimplemented in DtLauncherController, and DtVerticalLauncherController.
| virtual bool DtWeaponController::createMountingController | ( | ) | [virtual] |
Overridden to create a DtMountingController.
Reimplemented from DtBaseWeaponController.
| virtual bool DtWeaponController::init | ( | ) | [virtual] |
Overridden to initialize values obtained from the descriptor.
Reimplemented from DtBaseWeaponController.
Reimplemented in DtLauncherController.
| virtual void DtWeaponController::tick | ( | ) | [virtual] |
If the myWaitingForFire flag is set and the munition loader is still loaded, the weapon has not fired yet and the function immediately returns.
Otherwise myWaitingForFire is set to false. If the output port group is activated and the simulation is not paused, chooseTarget() is called, the munition loader is ticked, and myLoadedPort is updated. If acquireTarget() and loadedAmmoValidForTarget() return true, fire() is called.
Reimplemented from DtBaseWeaponController.
Reimplemented in DtLauncherController.
| virtual void DtWeaponController::fire | ( | ) | [virtual] |
updates weapon interface
Reimplemented from DtBaseWeaponController.
Reimplemented in DtLauncherController.
| virtual DtVrfObject* DtWeaponController::chooseTarget | ( | ) | [virtual] |
Called by tick() to find a target.
Calls acceptSensorTargettingInput(), to see if it has a target. If this function returns true, it looks up the target DtObjectId in myWeaponProcessState, and then looks up the DtVrfObject* for that ID in the DtVrfObjectManager. If the entity is found, it is set in the process state repository by calling myWeaponProcessState->setCurrentTarget and then the pointer is returned. If not, the current target is set to DtEntityIdentifier::nullId(), and a NULL pointer is returned.
| virtual DtVrfObject* DtWeaponController::chooseTarget | ( | const DtEntityTargetList & | targetList | ) | const [virtual] |
Called by acceptSensorTargettingInput to choose a target from the list of potential target entities on myTargetListPort.
The target is chosen based on whether or not the target is in the sector of responsibility. Targets in-sector (the entity's sector of responsibility) are selected over out-of-sector targets. It calls inSector() to determine if a given target is in the entity's sector of responsibility. It calls easier() to choose between two given target entities. It returns a pointer to the DtVrfObject* target that best met this criteria.
| virtual void DtWeaponController::tickMunitionLoader | ( | const DtVrfObject * | target | ) | [virtual] |
This method will set the flags myLoading, myUnloading, myLoaded as the load state of the weapon changes.
The parameter is the entity object of the current target for the weapon. The loader will only perform an activity if it has a target, otherwise it remains idle.
Reimplemented in DtLauncherController.
| virtual bool DtWeaponController::acquireTarget | ( | const DtVrfObject * | target | ) | [virtual] |
Returns true when target has been acquired.
If the target cannot be acquired given the azimuthSweep or elevationRange limitations of the weapon mounting, this method will invoke the method "maneuverToAcquireTarget" method. This function returns true if a given DtSimBaseEntity* target can be acquired, false if not. It starts by calling findBodyAzimuthElevationToTargetPoint() to get the azimuth and elevation angles to the target, in terms of the body coordinate system of the entity. It then calls desiredOrientationIsInRange(), testing to see if the azimuth and elevation angles are within the angular range given by myMunitionManeuverMargin (a parameter specified in the component descriptor). If this function return false, it calls maneuverRequiredToAcquireTarget(). Note: The base class version of this function is not implemented. Derived classes may implement a version that maneuvers the entity such that it can acquire the target. Similarly, if the entity is exceeding the maximum speed at which it can fire (myFireMaxVehicleSpeed), it calls maneuverRequiredToAcquireTarget(). If the target lies within myMunitionManeuverMargin, both in azimuth and elevation, it calls setTargetAcquired() in the entity local state repository, and returns true.
Reimplemented in DtVerticalLauncherController.
| virtual void DtWeaponController::maneuverRequiredToAcquireTarget | ( | DtReal | requiredHeading, |
| DtReal | requiredPitch, | ||
| DtReal | requiredMaxSpeed | ||
| ) | [virtual] |
Not implemented in this class.
Subclasses should implement this method to tie into their entity maneuver controllers to maneuver their vehicle to line up for a shot.
| virtual bool DtWeaponController::loadedAmmoValidForTarget | ( | const DtVrfObject * | target | ) | const [virtual] |
Called by tick() as part of the check to see if the trigger should be pulled.
Returns false if the munition loader is not loaded. Otherwise it checks the ammo selection table to make sure that the currently loaded munition matches the entity type of the target parameter.
| virtual bool DtWeaponController::chooseAmmo | ( | const DtEntityType & | entityType, |
| DtSimMunition & | munitionOut, | ||
| DtDetonatorFuze & | fuzeOut, | ||
| bool | setCurrentMunition = true |
||
| ) | [virtual] |
The chooseAmmo() function is passed a pointer to a target entity and returns the best ammunition to use for the target's entity type.
Type of ammunition and availability, if any, is from the Ammo Select Table specified in the DtWeaponControllerDescriptor. The Ammo Select Table provides a list of ammunition types that are appropriate for a given target type, in order from most preferred to least preferred. The chooseAmmo() function starts at the beginning of the list of appropriate ammunition types, and returns the first one for which the resource is available. Note: Fuze types are not supported in the current version of VR-Forces; DtFuzeOther is returned for the fuze. If an entity type of DtEntityType::nullType() is passed in, the first munition in the Ammo Select Table is chosen.
If setCurrentMunition is false, then, this routine can be used to simply check to see if the munition exists for the particular entity without actually selecting it
| virtual bool DtWeaponController::acceptSensorTargettingInput | ( | ) | [virtual] |
Returns true if we get a viable target from the sensor.
Checks to see if the entity already has a target by calling DtVrfWeaponPSR::currentTarget on myWeaponProcessState. If the entity does not currently have a target, it calls chooseTarget() to try to find one. If chooseTarget returns the valid DtObjectId of a target, it sets the target in myWeaponProcessState. Otherwise it calls setTargetAquired to indicate no target was aquired. If the entity already has a target specified in myWeaponProcessState, it checks the sensor input port to see if the target has been "forgotten" by the sensor (that is, the target ID is missing from the list of target entities present on the sensor input port). If it has been forgotten, it clears the target in myWeaponProcessState, setting its targetAcquired state to false, and its current target ID to DtObjectId::nullId(). It calls dataReceived on myTargetListPort before exiting.
| virtual bool DtWeaponController::inSector | ( | DtVrfObject * | entity | ) | const [virtual] |
Sets the trigger port value to true, sets myLoaded flag to false, and depletes the resource associated with the current munition type in the entity's local state repository.
| virtual void DtWeaponController::findBodyHeadingElevationToTarget | ( | const DtVrfObject * | entity, |
| DtReal & | bodyHeadingOut, | ||
| DtReal & | bodyElevationOut | ||
| ) | const [virtual] |
Given a target entity, computes the body heading (azimuth) and elevation angles to the target, in the body coordinates of the entity.
| virtual DtVrfObject* DtWeaponController::easier | ( | DtVrfObject * | entity1, |
| DtVrfObject * | entity2 | ||
| ) | const [virtual] |
This function takes two DtVrfObject* entities as arguments, and returns the entity that is easier for the weapon to acquire.
In this base class function, it chooses the first entity argument, and returns it.
| static DtSimComponent* DtWeaponController::creator | ( | const DtString & | name, |
| DtVrfObject * | owner, | ||
| DtSimManager * | simManager, | ||
| DtComponentDescriptor * | desc = 0, |
||
| DtReaderWriterRegistry * | parentRegistry = 0 |
||
| ) | [static] |
(const DtString&,DtVrfObject*,DtSimManager*,
| name | Reader writer name of this component. |
| owner | The DtVrfObject that owns this component |
| simManager | The simulation manager (provides access to terrain, message interface, simulation clock). |
| desc | The component descriptor used to initialize this component. |
| parentRegistry | Pointer to the parent reader writer registry (the containing object that reads/writes this object). |
Reimplemented from DtBaseWeaponController.
Reimplemented in DtLauncherController, and DtVerticalLauncherController.
| virtual bool DtWeaponController::createPorts | ( | ) | [protected, virtual] |
Overridden to create the local ports.
Reimplemented from DtBaseWeaponController.
Reimplemented in DtLauncherController.
| virtual void DtWeaponController::addRangeItems | ( | ) | [protected, virtual] |
Adds all items that have a range to the object state repository.
| const DtWeaponController& DtWeaponController::operator= | ( | const DtWeaponController & | orig | ) | [protected] |
assignment operator; not implemented
DtEntityIdentifier DtWeaponController::myCurrentTarget [protected] |
Input Port Name: target-list
Input Port Description: List of targets detected.
Input Port Range:
Input Port Default Value:
Input Group Parent:
DtBooleanInputPort* DtWeaponController::myWeaponsHoldPort [protected] |
Input Port Name: weapons-hold
Input Port Description: When true, all firing of missiles is disabled.
Connecting to this port is optional. If no connection is made, it will default to false.
Input Port Range: True/False
Input Port Default Value: False
const DtWeaponControllerDescriptor* DtWeaponController::myWeaponCtlrDesc [protected] |