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

DtPathMetric calculates costs for the DtPathPlanner path planning algorithm. More...

Inheritance diagram for DtPathMetric:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DtPathMetric (DtVrfObject *entity)
 Constructor. Takes entity for which the path will be calculated.
virtual ~DtPathMetric ()
 destructor
virtual bool init ()
 Call immediately after constructor.
virtual double transitionCost (const DtPoint &startPoint, const DtPoint &endPoint) const =0
 Calculates the cost of moving directly from startPoint to endPoint.
virtual double turningCost (double cosAngle) const =0
 Returns the cost for a bend in the path of the specified cosine angle.
virtual double heuristic (const DtPoint &point, const DtPoint &goalPoint) const
 Returns the heuristic of point This is the optimistic cost from this point to the goal.
virtual DtVrfObjectentity ()
virtual const DtVrfObjectentity () const

Static Public Member Functions

static void addPathMetricCreatorFcn (const DtString &type, DtPathMetricCreatorFcn fcn)
 Factory registration and generation methods.
static DtPathMetricFactoryfactory ()
 Factory registration and generation methods.
static void setFactory (DtPathMetricFactory *factory)
 Factory registration and generation methods.
static DtPathMetriccreatePathMetric (const DtString &type, DtVrfObject *entity)
 Uses the static DtPathMetricFactory set with setFactory() to return a new instance of the derived version of DtPathMetric registered with the provided type string.

Protected Attributes

DtVrfObjectmyEntity

Static Protected Attributes

static DtPathMetricFactorytheFactory

Private Member Functions

 DtPathMetric ()
 Not implemented.
 DtPathMetric (const DtPathMetric &orig)
 Not Implemented.
DtPathMetricoperator= (const DtPathMetric &orig)
 Not Implemented.

Detailed Description

DtPathMetric calculates costs for the DtPathPlanner path planning algorithm.

DtPathMetric is an abstract base class which defines the interface for calculating transition and turning costs. Derived versions of the class do actual cost calculation.

To create a custom path metric, you must implement transitionCost() and turningCost(). You may also need to implement a new version of heuristic().

The cost values returned by metrics are only used to compare against costs returns from metrics of the same type, so you can choose any concept to be represented by the cost. The returned cost must respect these rules: -Cost must be deterministic, and repeatable. The transition cost between two points must return the same value each time it is calculated. -The return value of heuristic() must be the most optimistic cost from the point to the goal. This means that there must not be any combinations of transitionCost and turningCost that could result in a total lower cost between that point and the goal.

Any new path metrics can be registered with the DtPathMetricFactory using a string type key, and will be created based on the OPE entry.


Constructor & Destructor Documentation

Not implemented.

DtPathMetric::DtPathMetric ( const DtPathMetric orig) [private]

Not Implemented.

Constructor. Takes entity for which the path will be calculated.

virtual DtPathMetric::~DtPathMetric ( ) [virtual]

destructor


Member Function Documentation

DtPathMetric& DtPathMetric::operator= ( const DtPathMetric orig) [private]

Not Implemented.

virtual bool DtPathMetric::init ( ) [virtual]
virtual double DtPathMetric::transitionCost ( const DtPoint startPoint,
const DtPoint endPoint 
) const [pure virtual]

Calculates the cost of moving directly from startPoint to endPoint.

Implemented in DtGroundVehicleSlopeSoilPathMetric, DtGroundAggregatePathMetric, DtHumanPathMetric, DtSurfaceEntityPathMetric, and DtRailPathMetric.

virtual double DtPathMetric::turningCost ( double  cosAngle) const [pure virtual]

Returns the cost for a bend in the path of the specified cosine angle.

(in radians) The angle is specified as the cosine of the angle through which the turn is made. 1 is no turn, -1 is a reversal of direction.

Implemented in DtGroundAggregatePathMetric, DtGroundVehicleSlopeSoilPathMetric, DtHumanPathMetric, DtRailPathMetric, and DtSurfaceEntityPathMetric.

virtual double DtPathMetric::heuristic ( const DtPoint point,
const DtPoint goalPoint 
) const [virtual]

Returns the heuristic of point This is the optimistic cost from this point to the goal.

The base class implementation returns the straight line 2D distance from the point to the goal. If your metric does not use distance as a cost, this should be changed.

Note:
It is important for an A* algorithm that the heuristic always return the smallest possible cost from the point to the goal. Returning smaller than the actual cost is OK, but the worse the estimate is, the longer the search will take. Always returning 0 makes the A* search into a greedy search, but will still return the optimal path.
virtual DtVrfObject* DtPathMetric::entity ( ) [virtual]
virtual const DtVrfObject* DtPathMetric::entity ( ) const [virtual]
static void DtPathMetric::addPathMetricCreatorFcn ( const DtString type,
DtPathMetricCreatorFcn  fcn 
) [static]

Factory registration and generation methods.

Factory registration and generation methods.

static void DtPathMetric::setFactory ( DtPathMetricFactory factory) [static]

Factory registration and generation methods.

static DtPathMetric* DtPathMetric::createPathMetric ( const DtString type,
DtVrfObject entity 
) [static]

Uses the static DtPathMetricFactory set with setFactory() to return a new instance of the derived version of DtPathMetric registered with the provided type string.

Returns NULL if none is found, or factory is not set.


Member Data Documentation


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)