VR-Forces 4.2 Class Documentation
Tank Platoon Parameter Entry

This DtTankPlatoonParametersBuilder creates the entry for the tank platoon object


Header file:

/*******************************************************************************
** Copyright (c) 2004 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: tankPlatoonParametersBuilder.h,v $ $Revision: 1.3 $ $State: Exp $
*******************************************************************************/
#ifndef DtTankPlatoonParametersBuilder_H_
#define DtTankPlatoonParametersBuilder_H_
//class DtTankPlatoonParametersBuilder:
//
//Instances of DtTankPlatoonParametersBuilder are used to create and
//configure a DtVrfObjectParameters object for a tank platoon aggregate
//entity. The parameters object returned should fully specify the necessary
//parameters to create a tank platoon.
{
public:
//default constructor
//destructor
//Creates and configures parameters for a tank platoon aggregate
//entity.
protected:
//Create and configure sensors, controllers, and actuators for the given
//movingObjectParameters object. Connects appropriate components to one another.
//Create and configure subordinates entities for the given parameters object.
//Adds 4 tank subordinate entries.
//Configure local and remote subcomponent types for the given parameters object.
//Specifies the kinds of state repository, network interface, radio, etc. to
//create when an object is created using this the parameters object.
//copy constructor - not implemented
//assignment operator - not implemented
};
#endif

Implementation:

/*******************************************************************************
** Copyright (c) 2004 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: tankPlatoonParametersBuilder.cxx,v $ $Revision: 1.13 $ $State: Exp $
*******************************************************************************/
#include <vlutil/vlPrint.h>
#include <vlpi/disEnums.h>
#include <vrfExtProtocol/objTypeEnums.h>
#include "vrfobjparam/pathMoveDesc.h"
{
}
{
}
{
//Aggregates should be configured with a derived kind of DtVrfObjectParameters
//type, DtAggregateObjectParameters.
"tank-platoon-param");
parameters->init();
//Set the state repository user extention and type (required). For this example,
//just create the default (we're not extending the state repository in any
//special way).
DtVrfStateRepositoryUserExtension stateRepositoryUserExtension(0);
parameters->setStateRepositoryUserExtension(stateRepositoryUserExtension);
//By default, we use an extended DtEntityType in our represention of
//force-level pseudo-aggregate type in VR-Forces.
//See objTypeEnums.h for the complete set of extended types.
DtRwObjectType objectType("object-type",
DtObjectTypePseudoAggregate,
DtAggregateKindMilitaryHierarchy,
DtPlatformDomainLand,
-1,
DtAggregateCategoryPlatoon,
-1,
-1,
-1);
parameters->setObjectType(objectType);
//Configure pseudo-aggregates with 3-D bounding geometry (a rectangular
//bounding volume).
parameters->setFormation(DtOtherAggregateFormation);
parameters->setForceType(DtForceOther);
parameters->setCategory("");
parameters->setEchelonLevel("Plt");
parameters->setOrganized(true);
parameters->setMinTickPeriod(0.0);
parameters->setMinTickPeriodVariance(0.0);
//Add a formation to the formation table.
DtFormation columnFormation;
columnFormation.addPosition(0, -1, DtVector(0.0, 0.0, 0.0));
columnFormation.addPosition(1, 0, DtVector(-25.0, 0.0, 0.0));
columnFormation.addPosition(2, 1, DtVector(-25.0, 0.0, 0.0));
columnFormation.addPosition(3, 2, DtVector(-25.0, 0.0, 0.0));
parameters->formationTable()->addFormation(DtColumnFormation, columnFormation);
//Create and connect sensors, controllers, and actuators.
//Create subordinate entries (they specify the type and
//initial location of subordinate entities to create when an
//object of this type (a tank platoon) is created.
//Configure local and remote subcomponent types.
//Specifies the kinds of state repository, network interface, radio, etc. to
//create when an object is created using this the parameters object.
return parameters;
}
{
//For each component, be sure to give it a unique name in the constructor.
//Remember to call setComponentType(<component type string>) for each
//descriptor. <component type string> is the type of DtSimComponent to
//create (types are defined in compTypes.h).
DtFormationControllerDescriptor formationControllerDesc("formation-controller");
formationControllerDesc.init();
formationControllerDesc.setComponentType("aggregate-formation-controller");
DtAggregateMoveIntoFormationDescriptor moveIntoFormationDescriptor(
"move-into-formation-controller");
moveIntoFormationDescriptor.setComponentType("aggregate-move-into-formation-controller");
moveIntoFormationDescriptor.setStopMovingUponArrival(true);
moveIntoFormationDescriptor.setTurnToHeadingUponArrival(true);
DtComponentDescriptor turnToHeadingControllerDesc("turn-to-heading-controller");
turnToHeadingControllerDesc.setComponentType("aggregate-turn-to-heading-controller");
DtComponentDescriptor moveToControllerDesc("move-to-controller");
moveToControllerDesc.setComponentType("aggregate-move-to-controller");
DtComponentDescriptor moveToLocationControllerDesc("move-to-location-controller");
moveToLocationControllerDesc.setComponentType("aggregate-move-to-location-controller");
DtComponentDescriptor patrolBetweenControllerDesc("patrol-between-controller");
patrolBetweenControllerDesc.setComponentType("aggregate-patrol-between-controller");
DtComponentDescriptor patrolAlongControllerDesc("aggregate-patrol-along-controller");
patrolAlongControllerDesc.setComponentType("aggregate-patrol-along-controller");
DtAggregateMoveAlongDescriptor moveAlongControllerDesc("move-along-controller");
moveAlongControllerDesc.setComponentType("aggregate-move-along-controller");
moveAlongControllerDesc.setCatchUpFactor(1.5);
moveAlongControllerDesc.setSlowDownFactor(0.1);
moveAlongControllerDesc.setInPositionTolerance(0.2);
moveAlongControllerDesc.setEvaluationInterval(1.0);
moveAlongControllerDesc.setGenerateRoutesWithRoundedCorners(true);
moveAlongControllerDesc.setVertexSpacingAlongRoundedCorners(20.0);
DtPathMovementControllerDescriptor pathMovementControllerDesc("path-movement");
pathMovementControllerDesc.setComponentType("path-movement-controller");
DtComponentDescriptor setControllerDesc("pseudo-aggregate-set-controller");
setControllerDesc.setComponentType("pseudo-aggregate-set-controller");
DtComponentDescriptor organizationControllerDesc("pseudo-aggregate-organization-controller");
organizationControllerDesc.setComponentType("pseudo-aggregate-organization-controller");
DtComponentDescriptor waitControllerDesc("pseudo-aggregate-wait-controller");
waitControllerDesc.setComponentType("pseudo-aggregate-wait-controller");
//Get a handle to the list of controllers and add the desired controller
//component desriptors to it. The order in which descriptors are added
//will be the order that the controllers in an actual entity will be
//ticked. This can affect priority (see section 5.2.2., "Configuring
//the Priority of Components" in the VR-Forces Configuration Guide).
controllerList.addComponentDescriptor(formationControllerDesc);
controllerList.addComponentDescriptor(moveIntoFormationDescriptor);
controllerList.addComponentDescriptor(turnToHeadingControllerDesc);
controllerList.addComponentDescriptor(moveToControllerDesc);
controllerList.addComponentDescriptor(moveToLocationControllerDesc);
controllerList.addComponentDescriptor(patrolBetweenControllerDesc);
controllerList.addComponentDescriptor(patrolAlongControllerDesc);
controllerList.addComponentDescriptor(moveAlongControllerDesc);
controllerList.addComponentDescriptor(pathMovementControllerDesc);
controllerList.addComponentDescriptor(setControllerDesc);
controllerList.addComponentDescriptor(organizationControllerDesc);
controllerList.addComponentDescriptor(waitControllerDesc);
DtActuatorComponentDescriptor aggregateActuator("aggregate-actuator");
aggregateActuator.setComponentType("aggregate-actuator");
DtActuatorComponentDescriptor damageActuatorDesc("pseudo-aggregate-damage-actuator");
damageActuatorDesc.setComponentType("pseudo-aggregate-damage-actuator");
//Get a handle to the list of actuators and add the desired actuator
//component desriptors to it.
parameters.actuatorDescriptorList();
actuatorList.addComponentDescriptor(aggregateActuator);
actuatorList.addComponentDescriptor(damageActuatorDesc);
}
{
//Configure the platoon with 4 tank subordinates, with
//initial positions specified in body coordinates of the
//platoon.
DtVrfSubObjectParameterList subordinates("subordinate-objects");
DtVrfSubObjectParameterEntry sub1("sub-object");
sub1.setObjectType(DtObjectType(1, 1, 1, 225, 1, 1, 3, 0));
sub1.setPositionOffset(DtVector(0.0, 0.0, 0.0));
sub1.setHeadingOffset(0.0);
DtVrfSubObjectParameterEntry sub2("sub-object");
sub2.setObjectType(DtObjectType(1, 1, 1, 225, 1, 1, 3, 0));
sub2.setPositionOffset(DtVector(-20.0, -20.0, 0.0));
sub2.setHeadingOffset(0.0);
DtVrfSubObjectParameterEntry sub3("sub-object");
sub3.setObjectType(DtObjectType(1, 1, 1, 225, 1, 1, 3, 0));
sub3.setPositionOffset(DtVector(-40.0, -40.0, 0.0));
sub3.setHeadingOffset(0.0);
DtVrfSubObjectParameterEntry sub4("sub-object");
sub4.setObjectType(DtObjectType(1, 1, 1, 225, 1, 1, 3, 0));
sub4.setPositionOffset(DtVector(-20.0, 20.0, 0.0));
sub4.setHeadingOffset(0.0);
subordinates.addSubObjectEntry(sub1);
subordinates.addSubObjectEntry(sub2);
subordinates.addSubObjectEntry(sub3);
subordinates.addSubObjectEntry(sub4);
parameters.setSubordinateObjects(subordinates);
}
DtVrfObjectParameters& parameters)
{
//Set up local sub component types for the entry. These types
//are used to direct what kinds of state repositories and network interfaces
//should be created for locally simulated tank platoons
//within our VR-Forces back-end.
//All pseudo-aggregates should specify a state repository type of type
//vrf-moving-object-state-repository (DtVrfMovingObjectStateRepository) (or
//a derived type).
local->setSimStateRepositoryType("vrf-aggregate-state-repository");
//Specify a network interface of type pseudo-aggregate-local-entity-net-interface
//(DtSimPseudoAggregateLocalEntityNetInterface).
local->setNetworkInterfaceType("pseudo-aggregate-local-entity-net-interface");
//Pseudo-aggregates are configured with components (sensors,
//controllers, actuators),so they must be configured with a
//component-manager (DtSimComponentManager).
local->setComponentManagerType("component-manager");
//Pseudo-aggregates can be tasked, so they must be configured with a
//pseudo-aggregate-task-manager (DtSimPseudoAggregateTaskManager).
local->setTaskManagerType("local-task-manager");
//Set up remote sub component types for the entry. These types
//are used to direct what kinds of state repositories and network interfaces
//should be created for remotely simulated tank platoons (either by another
//VR-Forces back-end or some other simulator).
remoteVrfSubComponentTypes();
//All pseudo-aggregates should specify a state repository type of type
//vrf-moving-object-state-repository (DtVrfMovingObjectStateRepository) (or
//a derived type).
remote->setSimStateRepositoryType("vrf-moving-object-state-repository");
//Specify a network interface of type vrf-aggregate-remote-entity-net-interface
//(DtVrfAggregateRemoteEntityNetInterface).
remote->setNetworkInterfaceType("vrf-aggregate-remote-entity-net-interface");
remote->setTaskManagerType("");
}

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)