VR-Forces 4.0.4 Class Documentation
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
DtSurfaceEntityPilotController Class Reference

The DtSurfaceEntityPilotController provides basic movement capabilities for surface entities and creates the ports needed to control surface entity actuators. More...

Inheritance diagram for DtSurfaceEntityPilotController:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DtSurfaceEntityPilotController (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString&,DtVrfObject*,DtSimManager*,
virtual ~DtSurfaceEntityPilotController ()
 Destructor.
virtual DtString type () const
 Returns a string identifies the class type of component.
virtual bool init ()
 Calls down to the base class and then caches a pointer to the state repository in mySurfaceEntityState.
virtual void tick ()
 Overridden to check for valid myProcessState pointer.
virtual void clearTask ()
 Calls down to the base class and then calls allowDeactivation() on mySurfaceControlPortGroup.
virtual bool createSurfaceControlPortGroup ()
 Creates the surface control output port group.
virtual bool createThrottlePort ()
 Creates the throttle output port and adds it to mySurfaceControlPortGroup.
virtual bool createRudderPort ()
 Creates the rudder output port and adds it to mySurfaceControlPortGroup.
virtual
DtConstrainedAnalogOutputPort
throttlePort () const
 Throttle port accessor.
virtual
DtConstrainedAnalogOutputPort
rudderPort () const
 Rudder port accessor.
virtual void sailTo (const DtVector &destination, double speed)
 Sets the controls needed to sail towards the given destination at the given speed.
virtual void driftTo (const DtVector &destination, double speed)
 Sets the controls needed to sail towards the given destination at the given speed for as long as possible until the engines are cut at a point which allows the ship to drift to the desired destination.
virtual double calculateControlForTurn (double yawAngle)
 Calculates the rudder control for a given turn angle.
virtual double calculateControlForThrottle (double desiredSpeed)
 Calculates the throttle control needed to reach the desired speed.
virtual double calculateControlForThrottle (double desiredSpeed, double distance)
 Calculates the throttle control needed to reach the desired speed without overshooting the given distance.
virtual void emergencyStop ()
 Uses the throttle to stop the vessel as quickly as possible.

Static Public Member Functions

static DtSimComponentcreator (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 (const DtString&,DtVrfObject*,DtSimManager*,

Protected Member Functions

virtual bool createPortGroups ()
 Overridden to call createSurfaceControlPortGroup().
virtual bool createPorts ()
 Overridden to call createThrottlePort() and createRudderPort().
virtual void lookupAndCacheProcessSR ()
 This function looks up a process state repository in the process state repository manager by name, and caches a pointer to it in

myProcessState.


virtual bool postAddComponentsInit ()
 Calls lookupAndCacheProcessSR(), to look up our process state repository after all of the components have been created and loaded.
virtual bool decideToGiveUpTask () const
 If the entity is embarked and the target of the current movement task is not embarked on the same object return true, and otherwise return a call to the base class.
 DtSurfaceEntityPilotController ()
 default constructor; not implemented
 DtSurfaceEntityPilotController (const DtSurfaceEntityPilotController &orig)
 copy constructor; not implemented
const
DtSurfaceEntityPilotController
operator= (const DtSurfaceEntityPilotController &orig)
 assignment operator; not implemented

Protected Attributes

DtSurfaceEntityStateRepositorymySurfaceEntityState
DtSurfaceEntityPilotControllerDescriptormyDescriptor
double myLastDistanceSquared
double myDistanceSquared
DtSurfaceMovementPSRmyProcessState
 Pointer to a process state repository used to store state data associated with this component.
Ports and Port Groups
DtBooleanInputPortmySmallVelocityClampedInputPort
 Input Port Name: clamp-small-vel-zero
Input Port Description:
Input Port Range:
Input Port Default Value: True
.
DtOutputPortGroupmySurfaceControlPortGroup
 Output Port Group Name: surface-control
Output Port Group Description:
DtConstrainedAnalogOutputPortmyThrottlePort
 Output Port Name: throttle
Output Port Description:
Output Port Range: -1.0 to 1.0
Output Port Default Value:
Output Group Parent: surface-control.
DtConstrainedAnalogOutputPortmyRudderPort
 Output Port Name: rudder
Output Port Description:
Output Port Range: -1.0 to 1.0
Output Port Default Value:
Output Group Parent: surface-control.

Detailed Description

The DtSurfaceEntityPilotController provides basic movement capabilities for surface entities and creates the ports needed to control surface entity actuators.

End User Description: DtSurfaceEntityPilotController (surfEntPltCtl.h) provides elements that are common to all controllers which perform movement tasks for surface entities.

DtSurfaceEntityPilotController creates the throttle and rudder output ports used by all the surface entity movement controllers and provides accessors for them.

The most important control functions offered by the DtSurfaceEntityPilotController are sailTo() and driftTo(), both of which provide actuator inputs to move a ship to a given location at a given speed. The difference between the two is that driftTo() attempts to judge when to cut the throttle in order to drift to a stop at the given location, whereas sailTo() will accelerate to and maintain the given speed at all times.

DtSurfaceEntityPilotController also offers a function called emergencyStop() which will use reverse thrust in an attempt to stop the ship as quickly as possible. Some of the movement controllers will call this function when they overshoot a target.

The control functions listed in the previous paragraphs use three functions to determine the port input values they need to use. For rudder control, calculateControlForTurn() determines how much rudder to apply to turn to a given angle based on the current speed. For throttle control, there are two versions of calculateControlForThrottle(). Both use a speed parameter to determine how much throttle to apply, however one also takes a distance parameter which prevents the controller from using too much throttle when trying to drift to a stop at the given distance.

Uses Descriptor Type: DtSurfaceEntityPilotControllerDescriptor


Constructor & Destructor Documentation

DtSurfaceEntityPilotController::DtSurfaceEntityPilotController ( const DtString name,
DtVrfObject owner,
DtSimManager simManager,
DtComponentDescriptor desc = 0,
DtReaderWriterRegistry parentRegistry = 0 
)

(const DtString&,DtVrfObject*,DtSimManager*,

Parameters:
nameReader writer name of this component.
ownerThe DtVrfObject that owns this component
simManagerThe simulation manager (provides access to terrain, message interface, simulation clock).
descThe component descriptor used to initialize this component.
parentRegistryPointer to the parent reader writer registry (the containing object that reads/writes this object).
(const DtString&,DtVrfObject*,DtSimManager*, DtComponentDescriptor*,DtReaderWriterRegistry* parentRegistry) Attempts to cast the given DtComponentDescriptor to a DtSurfaceEntityPilotControllerDescriptor and cache it in myDescriptor. If this fails a warning is printed to the object console.

Destructor.

Deletes all ports and port groups

default constructor; not implemented

copy constructor; not implemented


Member Function Documentation

virtual DtString DtSurfaceEntityPilotController::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.

Returns:
DtSurfaceEntityPilotControllerType

Implements DtTaskControllerComponent.

Reimplemented in DtSurfaceEntityMoveAlongController, DtSurfaceEntityPatrolRouteController, DtSurfaceEntityPatrolBetweenController, DtSurfaceEntityMoveToLocationController, DtSurfaceEntityFollowEntityController, and DtSurfaceEntityMoveToController.

Calls down to the base class and then caches a pointer to the state repository in mySurfaceEntityState.

Reimplemented from DtControllerComponent.

Reimplemented in DtSurfaceEntityMoveAlongController.

virtual void DtSurfaceEntityPilotController::tick ( ) [virtual]

Overridden to check for valid myProcessState pointer.

If it is null a warning is printed to the object console.

Reimplemented from DtSimComponent.

Reimplemented in DtSurfaceEntityFollowEntityController, and DtSurfaceEntityMoveToController.

virtual void DtSurfaceEntityPilotController::clearTask ( ) [virtual]

Calls down to the base class and then calls allowDeactivation() on mySurfaceControlPortGroup.

Reimplemented from DtSingleTaskControllerComponent.

Creates the surface control output port group.

Creates the throttle output port and adds it to mySurfaceControlPortGroup.

Creates the rudder output port and adds it to mySurfaceControlPortGroup.

Throttle port accessor.

Rudder port accessor.

virtual void DtSurfaceEntityPilotController::sailTo ( const DtVector destination,
double  speed 
) [virtual]

Sets the controls needed to sail towards the given destination at the given speed.

The rudder port is set based on the angle to the given destination by calling calculateControlForTurn and putting the result on the rudder port. The throttle port is set based on the given speed by calling calculateControlForThrottle with the desired speed, but without a target distance. This means that the ship will attempt to be moving at the given speed when it reaches the destination vector.

virtual void DtSurfaceEntityPilotController::driftTo ( const DtVector destination,
double  speed 
) [virtual]

Sets the controls needed to sail towards the given destination at the given speed for as long as possible until the engines are cut at a point which allows the ship to drift to the desired destination.

The rudder port is set based on the angle to the given destination by calling calculateControlForTurn and putting the result on the rudder port. The throttle port is set based on the given speed by calling calculateControlForThrottle() with the desired speed and the distance from the ship to the destination vector. This means that the ship will attempt to drift to a stop at the destination vector.

virtual double DtSurfaceEntityPilotController::calculateControlForTurn ( double  yawAngle) [virtual]

Calculates the rudder control for a given turn angle.

Calculates the rudder control needed to turn towards the given angle based on the current speed, current yaw rate, maximum yaw rate, and maximum yaw acceleration. The result is clamped to a range between -1.0 and 1.0.

virtual double DtSurfaceEntityPilotController::calculateControlForThrottle ( double  desiredSpeed) [virtual]

Calculates the throttle control needed to reach the desired speed.

Calculates the throttle control needed to reach the desired speed based on the current speed and throttle value. The result is clamped to a range between -1.0 and 1.0.

virtual double DtSurfaceEntityPilotController::calculateControlForThrottle ( double  desiredSpeed,
double  distance 
) [virtual]

Calculates the throttle control needed to reach the desired speed without overshooting the given distance.

Calculates the throttle control needed to reach the desired speed. Limits the throttle based on the given distance so the ship does not overshoot the target. The result is clamped to a range between -1.0 and 1.0.

Uses the throttle to stop the vessel as quickly as possible.

Applies thrust in the opposite direction of the vessel's movement until the actuator clamps the speed to zero.

static DtSimComponent* DtSurfaceEntityPilotController::creator ( const DtString name,
DtVrfObject owner,
DtSimManager simManager,
DtComponentDescriptor desc = 0,
DtReaderWriterRegistry parentRegistry = 0 
) [static]

(const DtString&,DtVrfObject*,DtSimManager*,

Parameters:
nameReader writer name of this component.
ownerThe DtVrfObject that owns this component
simManagerThe simulation manager (provides access to terrain, message interface, simulation clock).
descThe component descriptor used to initialize this component.
parentRegistryPointer to the parent reader writer registry (the containing object that reads/writes this object).
(const DtString&,DtVrfObject*,DtSimManager*, DtComponentDescriptor*,DtReaderWriterRegistry* parentRegistry)

Returns:
New instance of this class.

Reimplemented in DtSurfaceEntityMoveToController, DtSurfaceEntityFollowEntityController, DtSurfaceEntityMoveAlongController, DtSurfaceEntityMoveToLocationController, DtSurfaceEntityPatrolBetweenController, and DtSurfaceEntityPatrolRouteController.

virtual bool DtSurfaceEntityPilotController::createPortGroups ( ) [protected, virtual]

Overridden to call createSurfaceControlPortGroup().

Reimplemented from DtSimComponent.

virtual bool DtSurfaceEntityPilotController::createPorts ( ) [protected, virtual]

Overridden to call createThrottlePort() and createRudderPort().

Reimplemented from DtSimComponent.

virtual void DtSurfaceEntityPilotController::lookupAndCacheProcessSR ( ) [protected, virtual]

This function looks up a process state repository in the process state repository manager by name, and caches a pointer to it in

myProcessState.

The name (if it exists) is given in the component descriptor (DtComponentDescriptor::processStateRepositoryName). If the name does not exist, it uses the appropriate default name defined in procSRTypes.h. Another component is responsible for creating and destroying the process state repository.

Calls lookupAndCacheProcessSR(), to look up our process state repository after all of the components have been created and loaded.

Returns:
true if myProcessState is not null

Reimplemented from DtSimComponent.

virtual bool DtSurfaceEntityPilotController::decideToGiveUpTask ( ) const [protected, virtual]

If the entity is embarked and the target of the current movement task is not embarked on the same object return true, and otherwise return a call to the base class.

Reimplemented from DtSingleTaskControllerComponent.

const DtSurfaceEntityPilotController& DtSurfaceEntityPilotController::operator= ( const DtSurfaceEntityPilotController orig) [protected]

assignment operator; not implemented


Member Data Documentation

Input Port Name: clamp-small-vel-zero
Input Port Description:
Input Port Range:
Input Port Default Value: True
.

Output Port Group Name: surface-control
Output Port Group Description:

Output Port Name: throttle
Output Port Description:
Output Port Range: -1.0 to 1.0
Output Port Default Value:
Output Group Parent: surface-control.

Output Port Name: rudder
Output Port Description:
Output Port Range: -1.0 to 1.0
Output Port Default Value:
Output Group Parent: surface-control.

Pointer to a process state repository used to store state data associated with this component.

This process state repository is shared with other components. Another component is responsible for creating and destroying the process state repository. This state is saved and restored as part of a scenario (or checkpoint).


The documentation for this class was generated from the following file:

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)