![]() |
VR-Forces 4.0.4 Class Documentation
|
DtPathMetric calculates costs for the DtPathPlanner path planning algorithm. More...

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 DtVrfObject * | entity () |
| virtual const DtVrfObject * | entity () const |
Static Public Member Functions | |
| static void | addPathMetricCreatorFcn (const DtString &type, DtPathMetricCreatorFcn fcn) |
| Factory registration and generation methods. | |
| static DtPathMetricFactory * | factory () |
| Factory registration and generation methods. | |
| static void | setFactory (DtPathMetricFactory *factory) |
| Factory registration and generation methods. | |
| static DtPathMetric * | createPathMetric (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 | |
| DtVrfObject * | myEntity |
Static Protected Attributes | |
| static DtPathMetricFactory * | theFactory |
Private Member Functions | |
| DtPathMetric () | |
| Not implemented. | |
| DtPathMetric (const DtPathMetric &orig) | |
| Not Implemented. | |
| DtPathMetric & | operator= (const DtPathMetric &orig) |
| Not Implemented. | |
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.
| DtPathMetric::DtPathMetric | ( | ) | [private] |
Not implemented.
| DtPathMetric::DtPathMetric | ( | const DtPathMetric & | orig | ) | [private] |
Not Implemented.
| DtPathMetric::DtPathMetric | ( | DtVrfObject * | entity | ) |
Constructor. Takes entity for which the path will be calculated.
| virtual DtPathMetric::~DtPathMetric | ( | ) | [virtual] |
destructor
| DtPathMetric& DtPathMetric::operator= | ( | const DtPathMetric & | orig | ) | [private] |
Not Implemented.
| virtual bool DtPathMetric::init | ( | ) | [virtual] |
Call immediately after constructor.
Reimplemented in DtGroundAggregatePathMetric, DtGroundVehicleSlopeSoilPathMetric, DtRailPathMetric, DtSurfaceEntityPathMetric, and DtHumanPathMetric.
| 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.
| 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.
| static DtPathMetricFactory* DtPathMetric::factory | ( | ) | [static] |
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.
DtVrfObject* DtPathMetric::myEntity [protected] |
DtPathMetricFactory* DtPathMetric::theFactory [static, protected] |